Skip to contentSkip to conversation

batman-adv: Revert coccinelle compat support

PATCH In review Sven Eckelmann 3 participants 11 messages Oct 31, 2016 – Nov 8, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

cover batman-adv: Revert coccinelle compat support

Hi,

it seems that the coccinelle package in Debian Jessie is not able to parse semantic patches [1]. This basically breaks the batman-adv build on many stable systems and thus makes the out-of-tree module unusable on these systems.

I have currently no better idea than reverting these patches.

Kind regards,
Sven

PS: Linus, do you want to try to get rid of replacement.sh?

[1] https://www.open-mesh.org/issues/303

#1 lore raw

PATCH 1/6 batman-adv: Revert "compat: Move vid api wrapper to coccinelle"

The coccinelle in Debian Jessie seems to be broken. It fails to parse the patches and thus makes it impossible to use the out-of-tree module in these systems. Therefore drop it for now.

This reverts commit 7f40f382af1125698ad149d1b743c2de70a5ad5c.

---
 compat-include/linux/netdevice.h        |  6 ---
 compat-patches/0005-vid-callbacks.cocci | 74 ---------------------------------
 compat.h                                | 54 ++++++++++++++++++++++++
 3 files changed, 54 insertions(+), 80 deletions(-)
 delete mode 100644 compat-patches/0005-vid-callbacks.cocci
compat-include/linux/netdevice.h +0 -6
index 0536549..e71e614 100644
@@ -28,12 +28,6 @@
 
 #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)
compat-patches/0005-vid-callbacks.cocci deleted +0 -74

74 lines not on this page · raw message

compat.h +54 -0

66 lines not on this page · raw message

Signature · 1 line
2.10.1
#2 lore raw

PATCH 2/6 batman-adv: Revert "compat: Move get_link_net patch to coccinelle"

In reply to Sven Eckelmann

The coccinelle in Debian Jessie seems to be broken. It fails to parse the patches and thus makes it impossible to use the out-of-tree module in these systems. Therefore drop it for now.

This reverts commit 3b79cd3d9b3eb920d17233b5270ee7162d55587e.

---
 compat-patches/0004-get_link_net.cocci | 13 -------------
 compat.h                               |  7 +++++++
 2 files changed, 7 insertions(+), 13 deletions(-)
 delete mode 100644 compat-patches/0004-get_link_net.cocci
compat-patches/0004-get_link_net.cocci deleted +0 -13
deleted file mode 100644
index 7520bb6..0000000
@@ -1,13 +0,0 @@
-@@
-identifier netdev, fallback_net;
-@@
-
- static struct net *batadv_getlink_net(const struct net_device *netdev,
-				       struct net *fallback_net)
- {
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
-+	return fallback_net;
-+#else
- ...
-+#endif
- }
compat.h +7 -0
index 2865eeb..245621f 100644
@@ -145,4 +145,11 @@ 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_ */
Signature · 1 line
2.10.1
#3 lore raw

PATCH 3/6 batman-adv: Revert "compat: Replace IFF_NO_QUEUE with coccinelle"

In reply to Sven Eckelmann

The coccinelle in Debian Jessie seems to be broken. It fails to parse the patches and thus makes it impossible to use the out-of-tree module in these systems. Therefore drop it for now.

This reverts commit 541c087012bd6b57d37f041aedc4d0b4440a96d1.

---
 compat-patches/0003-iff-no-queue.cocci | 9 ---------
 compat.h                               | 6 ++++++
 2 files changed, 6 insertions(+), 9 deletions(-)
 delete mode 100644 compat-patches/0003-iff-no-queue.cocci
compat-patches/0003-iff-no-queue.cocci deleted +0 -9
deleted file mode 100644
index 9c95b85..0000000
@@ -1,9 +0,0 @@
-@@
-expression E;
-@@
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)
- E->priv_flags |= IFF_NO_QUEUE;
-+#else
-+E->tx_queue_len = 0;
-+#endif
compat.h +6 -0
index 245621f..78de7ea 100644
@@ -152,4 +152,10 @@ 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_ */
Signature · 1 line
2.10.1
#4 lore raw

PATCH 4/6 batman-adv: Revert "compat: Move netlink const compat to coccinelle"

In reply to Sven Eckelmann

The coccinelle in Debian Jessie seems to be broken. It fails to parse the patches and thus makes it impossible to use the out-of-tree module in these systems. Therefore drop it for now.

This reverts commit 2f9f52d1dfc417201028cc65f91aaddc5eaf493a.

---
 Makefile                             |  3 ++-
 compat-patches/0002-genl-const.INFO  | 15 ---------------
 compat-patches/0002-genl-const.cocci | 10 ----------
 compat-patches/replacements.sh       |  9 +++++++++
 4 files changed, 11 insertions(+), 26 deletions(-)
 delete mode 100644 compat-patches/0002-genl-const.INFO
 delete mode 100644 compat-patches/0002-genl-const.cocci
 create mode 100755 compat-patches/replacements.sh
Makefile +2 -1
index e9c499f..67f1988 100644
@@ -108,7 +108,7 @@ install: config $(SOURCE_STAMP)
 config:
 	$(PWD)/gen-compat-autoconf.sh $(PWD)/compat-autoconf.h
 
-$(SOURCE_STAMP): $(SOURCE) compat-patches/*
+$(SOURCE_STAMP): $(SOURCE) compat-patches/* compat-patches/replacements.sh
 	$(MKDIR) $(BUILD_DIR)/net/batman-adv/
 	@$(LN) ../Makefile $(BUILD_DIR)/Makefile
 	@$(RM) $(SOURCE_BUILD)
@@ -126,6 +126,7 @@ $(SOURCE_STAMP): $(SOURCE) compat-patches/*
 			$(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
compat-patches/0002-genl-const.INFO deleted +0 -15
deleted file mode 100644
index 192c5c6..0000000
@@ -1,15 +0,0 @@
-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
compat-patches/0002-genl-const.cocci deleted +0 -10
deleted file mode 100644
index 36c71d6..0000000
@@ -1,10 +0,0 @@
-@@
-attribute __genl_const;
-@@
-(
--const struct genl_multicast_group
-+__genl_const struct genl_multicast_group
-|
--const struct genl_ops
-+__genl_const struct genl_ops
-)
compat-patches/replacements.sh new file +9 -0
new file mode 100755
index 0000000..7dcb953
@@ -0,0 +1,9 @@
+#! /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
Signature · 1 line
2.10.1
#5 lore raw

Re: [B.A.T.M.A.N.] [PATCH 4/6] batman-adv: Revert "compat: Move netlink const compat to coccinelle"

Quoted 7 lines · Sven Eckelmann

The coccinelle in Debian Jessie seems to be broken. It fails to parse the patches and thus makes it impossible to use the out-of-tree module in these systems. Therefore drop it for now.

This reverts commit 2f9f52d1dfc417201028cc65f91aaddc5eaf493a.

Quoted 10 lines
---
 Makefile                             |  3 ++-
 compat-patches/0002-genl-const.INFO  | 15 ---------------
 compat-patches/0002-genl-const.cocci | 10 ----------
 compat-patches/replacements.sh       |  9 +++++++++
 4 files changed, 11 insertions(+), 26 deletions(-)
 delete mode 100644 compat-patches/0002-genl-const.INFO
 delete mode 100644 compat-patches/0002-genl-const.cocci
 create mode 100755 compat-patches/replacements.sh

684d4cad930d97902 ("batman-adv: Remove replacement compat script") needs to be reverted first before this patch applies cleanly, doesn't it?

#6 lore raw

Re: [B.A.T.M.A.N.] [PATCH 4/6] batman-adv: Revert "compat: Move netlink const compat to coccinelle"

Quoted 3 lines · Linus Lüssing

684d4cad930d97902 ("batman-adv: Remove replacement compat script") needs to be reverted first before this patch applies cleanly, doesn't it?

Ah, sorry, no, just noticed you rebased it on master + "batman-adv: Install module in $INSTALL_MOD_DIR/updates/net/batman-adv".

Cherry-picking that commit onto master first helped.

#7 lore raw

PATCH 5/6 batman-adv: Revert "compat: Port netlink port hack to coccinelle"

In reply to Sven Eckelmann

The coccinelle in Debian Jessie seems to be broken. It fails to parse the patches and thus makes it impossible to use the out-of-tree module in these systems. Therefore drop it for now.

This reverts commit 57ed6cbca85a0a681a0fa8b4690259429f3ea9a5.

---
 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, 19 insertions(+), 35 deletions(-)
 delete mode 100644 compat-patches/0001-netlink-portid.cocci
compat-include/linux/netlink.h +13 -7
index ca2bdf0..4f2185d 100644
@@ -26,13 +26,19 @@
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)
 
-#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
+#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))
 
 #endif /* < KERNEL_VERSION(3, 7, 0) */
 
compat-include/net/genetlink.h +0 -11
index b057e6c..2e8e17a 100644
@@ -24,17 +24,6 @@
 #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>
compat-patches/0001-netlink-portid.cocci deleted +0 -17
deleted file mode 100644
index 5fc504e..0000000
@@ -1,17 +0,0 @@
-@@
-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)
compat.h +6 -0
index 78de7ea..d987577 100644
@@ -67,6 +67,12 @@ 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) \
Signature · 1 line
2.10.1
#8 lore raw

PATCH 6/6 batman-adv: Revert "Add support for coccinelle in compat-patches"

In reply to Sven Eckelmann

The coccinelle in Debian Jessie seems to be broken. It fails to parse the patches and thus makes it impossible to use the out-of-tree module in these systems. Therefore drop it for now.

This reverts commit cd6361c9f4ea19e1318c6549f863a21921154896.

---
 Makefile | 23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)
Makefile +5 -18
index 67f1988..b852a17 100644
@@ -40,19 +40,11 @@ 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 --very-quiet
 CP := cp -fpR
 LN := ln -sf
 
@@ -114,17 +106,12 @@ $(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 -e '.patch$$' -e '.cocci$$'|sort)"; \
+	patches="$$(ls -1 compat-patches/|grep '.patch$$'|sort)"; \
 	for i in $${patches}; do \
-		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; \
+		echo '  COMPAT_PATCH '$${i};\
+		cd $(BUILD_DIR); \
+		$(PATCH) ../compat-patches/$${i}; \
+		cd - > /dev/null; \
 	done
 	compat-patches/replacements.sh
 	touch $(SOURCE_STAMP)
Signature · 1 line
2.10.1
#9 lore raw
In reply to Sven Eckelmann

Hi Sven,

Quoted 6 lines · Sven Eckelmann

Hi,

it seems that the coccinelle package in Debian Jessie is not able to parse semantic patches [1]. This basically breaks the batman-adv build on many stable systems and thus makes the out-of-tree module unusable on these systems.

Urgh, what a shame :-(

Quoted 7 lines

I have currently no better idea than reverting these patches.

Kind regards,
Sven

PS: Linus, do you want to try to get rid of replacement.sh?

Have only looked at the one const case so far, but can have a look at the others too, sure.

#10 lore raw
In reply to Sven Eckelmann
Quoted 8 lines · CET Sven Eckelmann

Hi,

it seems that the coccinelle package in Debian Jessie is not able to parse semantic patches [1]. This basically breaks the batman-adv build on many stable systems and thus makes the out-of-tree module unusable on these systems.

I have currently no better idea than reverting these patches.

Commited in be1dd23..c941add

Thanks,
Simon