* [B.A.T.M.A.N.] [PATCH v3 0/8] batman-adv: Support for complex compat patches
@ 2016-10-18 13:57 Sven Eckelmann
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 1/8] batman-adv: Mark batadv_netlink_ops as const Sven Eckelmann
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: Sven Eckelmann @ 2016-10-18 13:57 UTC (permalink / raw)
To: b.a.t.m.a.n
[-- Attachment #1: Type: text/plain, Size: 504 bytes --]
Hi,
here is the updated patchset to get complex compat patches support in batman-
adv. The initial three patches of the last patchset [1] are already part of
batman-adv.git next. This part is mostly about getting coccinelle/spatch to
work.
Changes in v3:
- rebased to get it working on top of current master
- use __genl_const for batadv_netlink_ops to keep it in ro memory for
kernel >= 3.13
Kind regards,
Sven
[1] https://lists.open-mesh.org/pipermail/b.a.t.m.a.n/2016-October/016375.html
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* [B.A.T.M.A.N.] [PATCH v3 1/8] batman-adv: Mark batadv_netlink_ops as const
2016-10-18 13:57 [B.A.T.M.A.N.] [PATCH v3 0/8] batman-adv: Support for complex compat patches Sven Eckelmann
@ 2016-10-18 13:57 ` Sven Eckelmann
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 2/8] batman-adv: Add support for coccinelle in compat-patches Sven Eckelmann
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Sven Eckelmann @ 2016-10-18 13:57 UTC (permalink / raw)
To: b.a.t.m.a.n
The genl_ops don't need to be written by anyone and thus can be moved in a
ro memory range.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
v3:
- use __genl_const to keep it in ro memory for kernel >= 3.13
v2:
- new patch
---
compat-patches/replacements.sh | 1 +
net/batman-adv/netlink.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/compat-patches/replacements.sh b/compat-patches/replacements.sh
index 669b0ff..7dcb953 100755
--- a/compat-patches/replacements.sh
+++ b/compat-patches/replacements.sh
@@ -5,4 +5,5 @@ set -e
# for kernel < 3.13 to make netlink compat code work
sed -i \
-e 's/^static const struct genl_multicast_group batadv_netlink_mcgrps/static __genl_const struct genl_multicast_group batadv_netlink_mcgrps/' \
+ -e 's/^static const struct genl_ops batadv_netlink_ops/static __genl_const struct genl_ops batadv_netlink_ops/' \
build/net/batman-adv/netlink.c
diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c
index 64cb6ac..aee20a3 100644
--- a/net/batman-adv/netlink.c
+++ b/net/batman-adv/netlink.c
@@ -534,7 +534,7 @@ batadv_netlink_dump_hardifs(struct sk_buff *msg, struct netlink_callback *cb)
return msg->len;
}
-static struct genl_ops batadv_netlink_ops[] = {
+static const struct genl_ops batadv_netlink_ops[] = {
{
.cmd = BATADV_CMD_GET_MESH_INFO,
.flags = GENL_ADMIN_PERM,
--
2.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [B.A.T.M.A.N.] [PATCH v3 2/8] batman-adv: Add support for coccinelle in compat-patches
2016-10-18 13:57 [B.A.T.M.A.N.] [PATCH v3 0/8] batman-adv: Support for complex compat patches Sven Eckelmann
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 1/8] batman-adv: Mark batadv_netlink_ops as const Sven Eckelmann
@ 2016-10-18 13:57 ` Sven Eckelmann
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 3/8] batman-adv: compat: Port netlink port hack to coccinelle Sven Eckelmann
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Sven Eckelmann @ 2016-10-18 13:57 UTC (permalink / raw)
To: b.a.t.m.a.n
The kernel and backports already uses spatch from coccinelle for
development and backporting purposes. Thus we can cleanup many current
hacks using semantic patches. These are also a lot less frail than
traditional unified diffs.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
v3:
- no changes
v2:
- new patch
---
Makefile | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index 7ef2569..99e67da 100644
--- a/Makefile
+++ b/Makefile
@@ -40,11 +40,19 @@ ifeq ($(shell cd $(KERNELPATH) && pwd),)
$(warning $(KERNELPATH) is missing, please set KERNELPATH)
endif
+ifeq ($(origin SPATCH), undefined)
+ SPATCH = spatch
+ ifeq ($(shell which $(SPATCH) 2>/dev/null),)
+ $(error $(SPATCH) (coccinelle) not found)
+ endif
+endif
+
export KERNELPATH
RM ?= rm -f
MKDIR := mkdir -p
PATCH_FLAGS = --batch --fuzz=0 --forward --strip=1 --unified --version-control=never -g0 --remove-empty-files --no-backup-if-mismatch --reject-file=-
PATCH := patch $(PATCH_FLAGS) -i
+SPATCH_FLAGS := --in-place --relax-include-path --use-coccigrep
CP := cp -fpR
SOURCE = $(wildcard net/batman-adv/*.[ch]) net/batman-adv/Makefile
@@ -104,12 +112,17 @@ $(SOURCE_STAMP): $(SOURCE) compat-patches/* compat-patches/replacements.sh
@$(RM) $(SOURCE_BUILD)
@$(CP) $(SOURCE) $(BUILD_DIR)/net/batman-adv/
@set -e; \
- patches="$$(ls -1 compat-patches/|grep '.patch$$'|sort)"; \
+ patches="$$(ls -1 compat-patches/|grep -e '.patch$$' -e '.cocci$$'|sort)"; \
for i in $${patches}; do \
- echo ' COMPAT_PATCH '$${i};\
- cd $(BUILD_DIR); \
- $(PATCH) ../compat-patches/$${i}; \
- cd - > /dev/null; \
+ echo ' COMPAT_PATCH '$${i}; \
+ if echo $${i}|grep '.patch$$'; then \
+ cd $(BUILD_DIR); \
+ $(PATCH) ../compat-patches/$${i}; \
+ cd - > /dev/null; \
+ fi; \
+ if echo $${i}|grep '.cocci$$'; then echo $$(pwd); \
+ $(SPATCH) $(SPATCH_FLAGS) --dir $(BUILD_DIR) --sp-file compat-patches/$${i} > /dev/null; \
+ fi; \
done
compat-patches/replacements.sh
touch $(SOURCE_STAMP)
--
2.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [B.A.T.M.A.N.] [PATCH v3 3/8] batman-adv: compat: Port netlink port hack to coccinelle
2016-10-18 13:57 [B.A.T.M.A.N.] [PATCH v3 0/8] batman-adv: Support for complex compat patches Sven Eckelmann
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 1/8] batman-adv: Mark batadv_netlink_ops as const Sven Eckelmann
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 2/8] batman-adv: Add support for coccinelle in compat-patches Sven Eckelmann
@ 2016-10-18 13:57 ` Sven Eckelmann
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 4/8] batman-adv: compat: Move netlink const compat " Sven Eckelmann
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Sven Eckelmann @ 2016-10-18 13:57 UTC (permalink / raw)
To: b.a.t.m.a.n
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
v3:
- no changes
v2:
- new patch
---
compat-include/linux/netlink.h | 20 +++++++-------------
compat-include/net/genetlink.h | 11 +++++++++++
compat-patches/0001-netlink-portid.cocci | 17 +++++++++++++++++
compat.h | 6 ------
4 files changed, 35 insertions(+), 19 deletions(-)
create mode 100644 compat-patches/0001-netlink-portid.cocci
diff --git a/compat-include/linux/netlink.h b/compat-include/linux/netlink.h
index 4f2185d..ca2bdf0 100644
--- a/compat-include/linux/netlink.h
+++ b/compat-include/linux/netlink.h
@@ -26,19 +26,13 @@
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)
-#include <net/scm.h>
-
-struct batadv_netlink_skb_parms {
- struct ucred creds; /* Skb credentials */
- union {
- __u32 portid;
- __u32 pid;
- };
- __u32 dst_group;
-};
-
-#undef NETLINK_CB
-#define NETLINK_CB(skb) (*(struct batadv_netlink_skb_parms *)&((skb)->cb))
+#define netlink_notify_portid(__notify) (__notify->pid)
+#define NETLINK_CB_PORTID(__skb) NETLINK_CB(__skb).pid
+
+#else
+
+#define netlink_notify_portid(__notify) (__notify->portid)
+#define NETLINK_CB_PORTID(__skb) NETLINK_CB(__skb).portid
#endif /* < KERNEL_VERSION(3, 7, 0) */
diff --git a/compat-include/net/genetlink.h b/compat-include/net/genetlink.h
index 72a8991..6a287e6 100644
--- a/compat-include/net/genetlink.h
+++ b/compat-include/net/genetlink.h
@@ -24,6 +24,17 @@
#include <linux/version.h>
#include_next <net/genetlink.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)
+
+#define genl_info_snd_portid(__genl_info) (__genl_info->snd_pid)
+
+#else
+
+#define genl_info_snd_portid(__genl_info) (__genl_info->snd_portid)
+
+#endif /* < KERNEL_VERSION(3, 7, 0) */
+
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
#include <linux/export.h>
diff --git a/compat-patches/0001-netlink-portid.cocci b/compat-patches/0001-netlink-portid.cocci
new file mode 100644
index 0000000..5fc504e
--- /dev/null
+++ b/compat-patches/0001-netlink-portid.cocci
@@ -0,0 +1,17 @@
+@@
+struct netlink_notify *notify;
+@@
+-notify->portid
++netlink_notify_portid(notify)
+
+@@
+struct genl_info *info;
+@@
+-info->snd_portid
++genl_info_snd_portid(info)
+
+@@
+expression skb;
+@@
+-NETLINK_CB(skb).portid
++NETLINK_CB_PORTID(skb)
diff --git a/compat.h b/compat.h
index d987577..78de7ea 100644
--- a/compat.h
+++ b/compat.h
@@ -67,12 +67,6 @@ static int __batadv_interface_kill_vid(struct net_device *dev, __be16 proto,\
#endif /* < KERNEL_VERSION(3, 3, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)
-
-#define snd_portid snd_pid
-
-#endif /* < KERNEL_VERSION(3, 7, 0) */
-
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0)
#define batadv_interface_set_mac_addr(x, y) \
--
2.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [B.A.T.M.A.N.] [PATCH v3 4/8] batman-adv: compat: Move netlink const compat to coccinelle
2016-10-18 13:57 [B.A.T.M.A.N.] [PATCH v3 0/8] batman-adv: Support for complex compat patches Sven Eckelmann
` (2 preceding siblings ...)
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 3/8] batman-adv: compat: Port netlink port hack to coccinelle Sven Eckelmann
@ 2016-10-18 13:57 ` Sven Eckelmann
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 5/8] batman-adv: Remove replacement compat script Sven Eckelmann
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Sven Eckelmann @ 2016-10-18 13:57 UTC (permalink / raw)
To: b.a.t.m.a.n
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
v3:
- removed compat-include/linux/netlink.h changes which are already in master
v2:
- new patch
---
compat-patches/0002-genl-const.INFO | 15 +++++++++++++++
compat-patches/0002-genl-const.cocci | 10 ++++++++++
compat-patches/replacements.sh | 6 ------
3 files changed, 25 insertions(+), 6 deletions(-)
create mode 100644 compat-patches/0002-genl-const.INFO
create mode 100644 compat-patches/0002-genl-const.cocci
diff --git a/compat-patches/0002-genl-const.INFO b/compat-patches/0002-genl-const.INFO
new file mode 100644
index 0000000..192c5c6
--- /dev/null
+++ b/compat-patches/0002-genl-const.INFO
@@ -0,0 +1,15 @@
+Newer kernels make generic netlink ops and multicast groups
+const, but older can't have that. We therefore introduce
+__genl_const, which can be defined depending on the kernel.
+
+What kernel versions require this?
+
+XXX: try to SmPLify
+
+The struct genl_ops gave the *option* to make it const via:
+mcgrof@ergon ~/linux (git::master)$ git describe --contains f84f771d9
+v3.13-rc1~33^2~32^2~2
+
+The struct genl_multicast_group was *forced* to be const via:
+mcgrof@ergon ~/linux (git::master)$ git describe --contains 2a94fe48f
+v3.13-rc1~33^2^2
diff --git a/compat-patches/0002-genl-const.cocci b/compat-patches/0002-genl-const.cocci
new file mode 100644
index 0000000..36c71d6
--- /dev/null
+++ b/compat-patches/0002-genl-const.cocci
@@ -0,0 +1,10 @@
+@@
+attribute __genl_const;
+@@
+(
+-const struct genl_multicast_group
++__genl_const struct genl_multicast_group
+|
+-const struct genl_ops
++__genl_const struct genl_ops
+)
diff --git a/compat-patches/replacements.sh b/compat-patches/replacements.sh
index 7dcb953..c7875c0 100755
--- a/compat-patches/replacements.sh
+++ b/compat-patches/replacements.sh
@@ -1,9 +1,3 @@
#! /bin/sh
set -e
-
-# for kernel < 3.13 to make netlink compat code work
-sed -i \
- -e 's/^static const struct genl_multicast_group batadv_netlink_mcgrps/static __genl_const struct genl_multicast_group batadv_netlink_mcgrps/' \
- -e 's/^static const struct genl_ops batadv_netlink_ops/static __genl_const struct genl_ops batadv_netlink_ops/' \
- build/net/batman-adv/netlink.c
--
2.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [B.A.T.M.A.N.] [PATCH v3 5/8] batman-adv: Remove replacement compat script
2016-10-18 13:57 [B.A.T.M.A.N.] [PATCH v3 0/8] batman-adv: Support for complex compat patches Sven Eckelmann
` (3 preceding siblings ...)
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 4/8] batman-adv: compat: Move netlink const compat " Sven Eckelmann
@ 2016-10-18 13:57 ` Sven Eckelmann
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 6/8] batman-adv: compat: Replace IFF_NO_QUEUE with coccinelle Sven Eckelmann
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Sven Eckelmann @ 2016-10-18 13:57 UTC (permalink / raw)
To: b.a.t.m.a.n
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
v3:
- no changes
v2:
- new patch
---
Makefile | 3 +--
compat-patches/replacements.sh | 3 ---
2 files changed, 1 insertion(+), 5 deletions(-)
delete mode 100755 compat-patches/replacements.sh
diff --git a/Makefile b/Makefile
index 99e67da..7eea0ab 100644
--- a/Makefile
+++ b/Makefile
@@ -107,7 +107,7 @@ install: config $(SOURCE_STAMP)
config:
$(PWD)/gen-compat-autoconf.sh $(PWD)/compat-autoconf.h
-$(SOURCE_STAMP): $(SOURCE) compat-patches/* compat-patches/replacements.sh
+$(SOURCE_STAMP): $(SOURCE) compat-patches/*
$(MKDIR) $(BUILD_DIR)/net/batman-adv/
@$(RM) $(SOURCE_BUILD)
@$(CP) $(SOURCE) $(BUILD_DIR)/net/batman-adv/
@@ -124,7 +124,6 @@ $(SOURCE_STAMP): $(SOURCE) compat-patches/* compat-patches/replacements.sh
$(SPATCH) $(SPATCH_FLAGS) --dir $(BUILD_DIR) --sp-file compat-patches/$${i} > /dev/null; \
fi; \
done
- compat-patches/replacements.sh
touch $(SOURCE_STAMP)
.PHONY: all clean install config
diff --git a/compat-patches/replacements.sh b/compat-patches/replacements.sh
deleted file mode 100755
index c7875c0..0000000
--- a/compat-patches/replacements.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#! /bin/sh
-
-set -e
--
2.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [B.A.T.M.A.N.] [PATCH v3 6/8] batman-adv: compat: Replace IFF_NO_QUEUE with coccinelle
2016-10-18 13:57 [B.A.T.M.A.N.] [PATCH v3 0/8] batman-adv: Support for complex compat patches Sven Eckelmann
` (4 preceding siblings ...)
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 5/8] batman-adv: Remove replacement compat script Sven Eckelmann
@ 2016-10-18 13:57 ` Sven Eckelmann
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 7/8] batman-adv: compat: Move get_link_net patch to coccinelle Sven Eckelmann
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Sven Eckelmann @ 2016-10-18 13:57 UTC (permalink / raw)
To: b.a.t.m.a.n
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
v3:
- no changes
v2:
- new patch
---
compat-patches/0003-iff-no-queue.cocci | 9 +++++++++
compat.h | 6 ------
2 files changed, 9 insertions(+), 6 deletions(-)
create mode 100644 compat-patches/0003-iff-no-queue.cocci
diff --git a/compat-patches/0003-iff-no-queue.cocci b/compat-patches/0003-iff-no-queue.cocci
new file mode 100644
index 0000000..9c95b85
--- /dev/null
+++ b/compat-patches/0003-iff-no-queue.cocci
@@ -0,0 +1,9 @@
+@@
+expression E;
+@@
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)
+ E->priv_flags |= IFF_NO_QUEUE;
++#else
++E->tx_queue_len = 0;
++#endif
diff --git a/compat.h b/compat.h
index 78de7ea..245621f 100644
--- a/compat.h
+++ b/compat.h
@@ -152,10 +152,4 @@ static int __batadv_interface_kill_vid(struct net_device *dev, __be16 proto,\
#endif /* < KERNEL_VERSION(4, 0, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
-
-#define IFF_NO_QUEUE 0; dev->tx_queue_len = 0
-
-#endif /* < KERNEL_VERSION(4, 3, 0) */
-
#endif /* _NET_BATMAN_ADV_COMPAT_H_ */
--
2.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [B.A.T.M.A.N.] [PATCH v3 7/8] batman-adv: compat: Move get_link_net patch to coccinelle
2016-10-18 13:57 [B.A.T.M.A.N.] [PATCH v3 0/8] batman-adv: Support for complex compat patches Sven Eckelmann
` (5 preceding siblings ...)
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 6/8] batman-adv: compat: Replace IFF_NO_QUEUE with coccinelle Sven Eckelmann
@ 2016-10-18 13:57 ` Sven Eckelmann
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 8/8] batman-adv: compat: Move vid api wrapper " Sven Eckelmann
2016-10-24 11:06 ` [B.A.T.M.A.N.] [PATCH v3 0/8] batman-adv: Support for complex compat patches Simon Wunderlich
8 siblings, 0 replies; 10+ messages in thread
From: Sven Eckelmann @ 2016-10-18 13:57 UTC (permalink / raw)
To: b.a.t.m.a.n
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
v3:
- no changes
v2:
- new patch
---
compat-patches/0004-get_link_net.cocci | 13 +++++++++++++
compat.h | 7 -------
2 files changed, 13 insertions(+), 7 deletions(-)
create mode 100644 compat-patches/0004-get_link_net.cocci
diff --git a/compat-patches/0004-get_link_net.cocci b/compat-patches/0004-get_link_net.cocci
new file mode 100644
index 0000000..1ae3192
--- /dev/null
+++ b/compat-patches/0004-get_link_net.cocci
@@ -0,0 +1,13 @@
+@@
+identifier netdev, fallback_net;
+@@
+
+ static const struct net *batadv_getlink_net(const struct net_device *netdev,
+ const struct net *fallback_net)
+ {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
++ return fallback_net;
++#else
+ ...
++#endif
+ }
diff --git a/compat.h b/compat.h
index 245621f..2865eeb 100644
--- a/compat.h
+++ b/compat.h
@@ -145,11 +145,4 @@ static int __batadv_interface_kill_vid(struct net_device *dev, __be16 proto,\
#endif /* < KERNEL_VERSION(3, 15, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
-
-/* WARNING for batadv_getlink_net */
-#define get_link_net get_xstats_size || 1 || netdev->rtnl_link_ops->get_xstats_size
-
-#endif /* < KERNEL_VERSION(4, 0, 0) */
-
#endif /* _NET_BATMAN_ADV_COMPAT_H_ */
--
2.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [B.A.T.M.A.N.] [PATCH v3 8/8] batman-adv: compat: Move vid api wrapper to coccinelle
2016-10-18 13:57 [B.A.T.M.A.N.] [PATCH v3 0/8] batman-adv: Support for complex compat patches Sven Eckelmann
` (6 preceding siblings ...)
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 7/8] batman-adv: compat: Move get_link_net patch to coccinelle Sven Eckelmann
@ 2016-10-18 13:57 ` Sven Eckelmann
2016-10-24 11:06 ` [B.A.T.M.A.N.] [PATCH v3 0/8] batman-adv: Support for complex compat patches Simon Wunderlich
8 siblings, 0 replies; 10+ messages in thread
From: Sven Eckelmann @ 2016-10-18 13:57 UTC (permalink / raw)
To: b.a.t.m.a.n
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
v3:
- no changes
v2:
- new patch
---
compat-include/linux/netdevice.h | 6 +++
compat-patches/0005-vid-callbacks.cocci | 74 +++++++++++++++++++++++++++++++++
compat.h | 54 ------------------------
3 files changed, 80 insertions(+), 54 deletions(-)
create mode 100644 compat-patches/0005-vid-callbacks.cocci
diff --git a/compat-include/linux/netdevice.h b/compat-include/linux/netdevice.h
index fb5b519..0de9d78 100644
--- a/compat-include/linux/netdevice.h
+++ b/compat-include/linux/netdevice.h
@@ -28,6 +28,12 @@
#include <linux/netdev_features.h>
+#define __vid_api_returntype void
+
+#else
+
+#define __vid_api_returntype int
+
#endif /* < KERNEL_VERSION(3, 3, 0) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0)
diff --git a/compat-patches/0005-vid-callbacks.cocci b/compat-patches/0005-vid-callbacks.cocci
new file mode 100644
index 0000000..2cebc0e
--- /dev/null
+++ b/compat-patches/0005-vid-callbacks.cocci
@@ -0,0 +1,74 @@
+@ add_assignment @
+identifier batadv_interface_add_vid, batadv_netdev_ops;
+@@
+
+ struct net_device_ops batadv_netdev_ops = {
+ .ndo_vlan_rx_add_vid = batadv_interface_add_vid,
+ };
+
+@ kill_assignment @
+identifier batadv_interface_kill_vid, batadv_netdev_ops;
+@@
+
+ struct net_device_ops batadv_netdev_ops = {
+ .ndo_vlan_rx_kill_vid = batadv_interface_kill_vid,
+ };
+
+@ add_vid @
+identifier add_assignment.batadv_interface_add_vid;
+type be16;
+identifier dev, proto, vid;
+@@
+
+-batadv_interface_add_vid
++batadv_interface_add_vid_orig
+ (struct net_device *dev, be16 proto,
+ unsigned short vid)
+ { ... }
+
++static __vid_api_returntype batadv_interface_add_vid(struct net_device *dev,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
++ be16 proto,
++#endif
++ unsigned short vid)
++{
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0)
++ be16 proto = htons(ETH_P_8021Q);
++#endif
++
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
++ batadv_interface_add_vid_orig(dev, proto, vid);
++#else
++ return batadv_interface_add_vid_orig(dev, proto, vid);
++#endif
++}
+
+
+@ kill_vid @
+identifier kill_assignment.batadv_interface_kill_vid;
+type be16;
+identifier dev, proto, vid;
+@@
+
+-batadv_interface_kill_vid
++batadv_interface_kill_vid_orig
+ (struct net_device *dev, be16 proto,
+ unsigned short vid)
+ { ... }
+
++static __vid_api_returntype batadv_interface_kill_vid(struct net_device *dev,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
++ be16 proto,
++#endif
++ unsigned short vid)
++{
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0)
++ be16 proto = htons(ETH_P_8021Q);
++#endif
++
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
++ batadv_interface_kill_vid_orig(dev, proto, vid);
++#else
++ return batadv_interface_kill_vid_orig(dev, proto, vid);
++#endif
++}
diff --git a/compat.h b/compat.h
index 2865eeb..d59fb5f 100644
--- a/compat.h
+++ b/compat.h
@@ -42,31 +42,6 @@
#endif /* < KERNEL_VERSION(3, 9, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
-
-#define batadv_interface_add_vid(x, y, z) \
-__batadv_interface_add_vid(struct net_device *dev, __be16 proto,\
- unsigned short vid);\
-static void batadv_interface_add_vid(struct net_device *dev, unsigned short vid)\
-{\
- __batadv_interface_add_vid(dev, htons(ETH_P_8021Q), vid);\
-}\
-static int __batadv_interface_add_vid(struct net_device *dev, __be16 proto,\
- unsigned short vid)
-
-#define batadv_interface_kill_vid(x, y, z) \
-__batadv_interface_kill_vid(struct net_device *dev, __be16 proto,\
- unsigned short vid);\
-static void batadv_interface_kill_vid(struct net_device *dev,\
- unsigned short vid)\
-{\
- __batadv_interface_kill_vid(dev, htons(ETH_P_8021Q), vid);\
-}\
-static int __batadv_interface_kill_vid(struct net_device *dev, __be16 proto,\
- unsigned short vid)
-
-#endif /* < KERNEL_VERSION(3, 3, 0) */
-
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0)
#define batadv_interface_set_mac_addr(x, y) \
@@ -95,35 +70,6 @@ static int __batadv_interface_tx(struct sk_buff *skb, \
#endif /* < KERNEL_VERSION(3, 9, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0)
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)
-
-#define batadv_interface_add_vid(x, y, z) \
-__batadv_interface_add_vid(struct net_device *dev, __be16 proto,\
- unsigned short vid);\
-static int batadv_interface_add_vid(struct net_device *dev, unsigned short vid)\
-{\
- return __batadv_interface_add_vid(dev, htons(ETH_P_8021Q), vid);\
-}\
-static int __batadv_interface_add_vid(struct net_device *dev, __be16 proto,\
- unsigned short vid)
-
-#define batadv_interface_kill_vid(x, y, z) \
-__batadv_interface_kill_vid(struct net_device *dev, __be16 proto,\
- unsigned short vid);\
-static int batadv_interface_kill_vid(struct net_device *dev,\
- unsigned short vid)\
-{\
- return __batadv_interface_kill_vid(dev, htons(ETH_P_8021Q), vid);\
-}\
-static int __batadv_interface_kill_vid(struct net_device *dev, __be16 proto,\
- unsigned short vid)
-
-#endif /* >= KERNEL_VERSION(3, 3, 0) */
-
-#endif /* < KERNEL_VERSION(3, 10, 0) */
-
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 15, 0)
/* the expected behaviour of this function is to return 0 on success, therefore
--
2.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH v3 0/8] batman-adv: Support for complex compat patches
2016-10-18 13:57 [B.A.T.M.A.N.] [PATCH v3 0/8] batman-adv: Support for complex compat patches Sven Eckelmann
` (7 preceding siblings ...)
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 8/8] batman-adv: compat: Move vid api wrapper " Sven Eckelmann
@ 2016-10-24 11:06 ` Simon Wunderlich
8 siblings, 0 replies; 10+ messages in thread
From: Simon Wunderlich @ 2016-10-24 11:06 UTC (permalink / raw)
To: b.a.t.m.a.n
[-- Attachment #1: Type: text/plain, Size: 388 bytes --]
On Tuesday, October 18, 2016 3:57:03 PM CEST Sven Eckelmann wrote:
> Hi,
>
> here is the updated patchset to get complex compat patches support in
> batman- adv. The initial three patches of the last patchset [1] are already
> part of batman-adv.git next. This part is mostly about getting
> coccinelle/spatch to work.
>
> Changes in v3:
Applied in d4d360d..7f40f38
Thanks,
Simon
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2016-10-24 11:06 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-18 13:57 [B.A.T.M.A.N.] [PATCH v3 0/8] batman-adv: Support for complex compat patches Sven Eckelmann
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 1/8] batman-adv: Mark batadv_netlink_ops as const Sven Eckelmann
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 2/8] batman-adv: Add support for coccinelle in compat-patches Sven Eckelmann
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 3/8] batman-adv: compat: Port netlink port hack to coccinelle Sven Eckelmann
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 4/8] batman-adv: compat: Move netlink const compat " Sven Eckelmann
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 5/8] batman-adv: Remove replacement compat script Sven Eckelmann
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 6/8] batman-adv: compat: Replace IFF_NO_QUEUE with coccinelle Sven Eckelmann
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 7/8] batman-adv: compat: Move get_link_net patch to coccinelle Sven Eckelmann
2016-10-18 13:57 ` [B.A.T.M.A.N.] [PATCH v3 8/8] batman-adv: compat: Move vid api wrapper " Sven Eckelmann
2016-10-24 11:06 ` [B.A.T.M.A.N.] [PATCH v3 0/8] batman-adv: Support for complex compat patches Simon Wunderlich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).