batman-adv: Support for complex compat patches
Subsystems (2)
Sven Eckelmann
maintainerv2 cover batman-adv: Support for complex compat patches
Hi,
some patches (like patch 3+4) require special code modifications that cannot be handled (reasonable) with the compat headers. One of these patches (3) is already in linux-next and thus should also be in batman-adv.git.
I am proposing in this patchset two different solutions. The first one is the easiest and most likely the best for the upcoming release. It uses a simple shell script to patch the problematic lines in a copy of the source code. The second solution uses parts of the first solution but replaces the simple shell script with unified and semantic patch files. Patch 5-11 should therefore be used as an example how coccinelle/spatch can be used to clean up some of the "interesting" hacks in the compat headers.
Changes in v2:
- remove second replacement.sh line which basically does nothing (thanks Linus)
- added patch 4 to also mark batadv_netlink_ops as const
- introduce patch 5-11 to show usage of coccinelle
(I personally recommend patch 9 to get familiar with the idea)
Kind regards,
Sven
Sven Eckelmann
maintainerPATCH v2 1/11 batman-adv: Introduce compat-patches support
compat-includes/compat.h can usually be used to solve compatibility problems with older kernels. This works well for functions, defines/enums and sometimes even structures that were introduced.
But this can fail when structs changed. Some of these can be solved in crude ways but sometimes it is unavoidable to have a version specific code. Unfortunately, this kind of code is not acceptable in the kernel and thus the compat infrastructure of the external module has to do add it automatically before the source is compiled.
This process works by creating a build directory which is prefilled with the source from net/batman-adv/. The patches from compat-patches/ will be applied on top of this copy and then the code is compiled.
---
v2:
- no change
--- .gitignore | 10 ++++------ Makefile | 31 +++++++++++++++++++++++++++---- compat-patches/README | 23 +++++++++++++++++++++++ compat-sources/Makefile | 6 +++--- 4 files changed, 57 insertions(+), 13 deletions(-) create mode 100644 compat-patches/README
.gitignore +4 -6
@@ -1,10 +1,8 @@ +/build/ /compat-autoconf.h /compat-autoconf.h.tmp /compat-sources/**/.* /compat-sources/**/*.o -/net/batman-adv/.* -/net/batman-adv/batman-adv.ko -/net/batman-adv/batman-adv.mod.c -/net/batman-adv/modules.order -/net/batman-adv/Module.symvers -/net/batman-adv/*.o +/modules.order +/Module.symvers +/.tmp_versions
Makefile +27 -4
@@ -33,6 +33,7 @@ export CONFIG_BATMAN_ADV_MCAST=y export CONFIG_BATMAN_ADV_BATMAN_V=n PWD:=$(shell pwd) +BUILD_DIR=$(PWD)/build KERNELPATH ?= /lib/modules/$(shell uname -r)/build # sanity check: does KERNELPATH exist? ifeq ($(shell cd $(KERNELPATH) && pwd),)
@@ -41,6 +42,14 @@ 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 +CP := cp -fpR + +SOURCE = $(wildcard net/batman-adv/*.[ch]) net/batman-adv/Makefile +SOURCE_BUILD = $(wildcard $(BUILD_DIR)/net/batman-adv/*.[ch]) $(BUILD_DIR)/net/batman-adv/Makefile +SOURCE_STAMP = $(BUILD_DIR)/net/batman-adv/.compat-prepared REVISION= $(shell if [ -d "$(PWD)/.git" ]; then \ echo $$(git --git-dir="$(PWD)/.git" describe --always --dirty --match "v*" |sed 's/^v//' 2> /dev/null || echo "[unknown]"); \
@@ -57,7 +66,7 @@ endif include $(PWD)/compat-sources/Makefile -obj-y += net/batman-adv/ +obj-y += build/net/batman-adv/ export batman-adv-y
@@ -76,18 +85,32 @@ BUILD_FLAGS := \ CONFIG_BATMAN_ADV_BATMAN_V=$(CONFIG_BATMAN_ADV_BATMAN_V) \ INSTALL_MOD_DIR=updates/ -all: config +all: config $(SOURCE_STAMP) $(MAKE) -C $(KERNELPATH) $(BUILD_FLAGS) modules clean: $(RM) compat-autoconf.h* - $(MAKE) -C $(KERNELPATH) $(BUILD_FLAGS) clean + $(RM) -r $(BUILD_DIR) -install: config +install: config $(SOURCE_STAMP) $(MAKE) -C $(KERNELPATH) $(BUILD_FLAGS) modules_install depmod -a config: $(PWD)/gen-compat-autoconf.sh $(PWD)/compat-autoconf.h +$(SOURCE_STAMP): $(SOURCE) compat-patches/* + $(MKDIR) $(BUILD_DIR)/net/batman-adv/ + @$(RM) $(SOURCE_BUILD) + @$(CP) $(SOURCE) $(BUILD_DIR)/net/batman-adv/ + @set -e; \ + patches="$$(ls -1 compat-patches/|grep '.patch$$'|sort)"; \ + for i in $${patches}; do \ + echo ' COMPAT_PATCH '$${i};\ + cd $(BUILD_DIR); \ + $(PATCH) ../compat-patches/$${i}; \ + cd - > /dev/null; \ + done + touch $(SOURCE_STAMP) + .PHONY: all clean install config
compat-patches/README new file +23 -0
@@ -0,0 +1,23 @@ +WARNING +======= + +Please avoid using the compat-patches/ to implement support for old kernels. +This should be the last resort. + + * it is nearly always possible to use compat-includes/ to do the same with a + lot less problems + + * maintaining these patches is *censored* + +GENERATING A PATCH +================== + +If it not possible to avoid a patch then please make the patch as small as +possible. Even refactor the code which has to be patched to reduce the +size/number of the changes. + +Please use git-format-patches to generate them and order same inside via the +XXXX- prefix of the patch name. + + git format-patch --abbrev=7 -U3 --diff-algorithm=histogram --no-signature \ + --format=format:'From: %an <%ae>%nDate: %aD%nSubject: [PATCH] %B' -1
compat-sources/Makefile +3 -3
@@ -1,3 +1,3 @@ -batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += ../../compat-sources/net/core/skbuff.o -batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += ../../compat-sources/net/ipv4/igmp.o -batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += ../../compat-sources/net/ipv6/mcast_snoop.o +batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += ../../../compat-sources/net/core/skbuff.o +batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += ../../../compat-sources/net/ipv4/igmp.o +batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += ../../../compat-sources/net/ipv6/mcast_snoop.o
Signature · 1 line
2.9.3
Re: [B.A.T.M.A.N.] [next, v2, 01/11] batman-adv: Introduce compat-patches support
Quoted 18 lines · On Sonntag, 9. Oktober 2016 08:57:28 CEST Sven Eckelmann wrote:
compat-includes/compat.hcan usually be used to solve compatibility problems with older kernels. This works well for functions, defines/enums and sometimes even structures that were introduced.But this can fail when structs changed. Some of these can be solved in crude ways but sometimes it is unavoidable to have a version specific code. Unfortunately, this kind of code is not acceptable in the kernel and thus the compat infrastructure of the external module has to do add it automatically before the source is compiled.
This process works by creating a build directory which is prefilled with the source from
net/batman-adv/. The patches from compat-patches/ will be applied on top of this copy and then the code is compiled.Signed-off-by Sven Eckelmann <[email protected]>---
v2:
- no change
Quoted 7 lines
--- .gitignore | 10 ++++------ Makefile | 31 +++++++++++++++++++++++++++---- compat-patches/README | 23 +++++++++++++++++++++++ compat-sources/Makefile | 6 +++--- 4 files changed, 57 insertions(+), 13 deletions(-) create mode 100644 compat-patches/README
Applied in 66ac14a09445b6066de6a8ae4382d8f981466ae3 [1].
Kind regards,
Sven
[1] https://git.open-mesh.org/batman-adv.git/commit/66ac14a09445b6066de6a8ae4382d8f981466ae3
Sven Eckelmann
maintainerPATCH v2 2/11 batman-adv: Use simple script to patch minor compat problems
In reply to Sven EckelmannUnified diff base patches have the problem that they fix only a single line and depend on the surrounding. This approach can fail relative often when the surrounding code will be changed often. Thus semantic patches (like spatch from coccinelle) or simple find+replace scripts are better for this approach.
Introduce a simple script file which will store these kind of find+replace instructions.
---
v2:
- no change
--- Makefile | 3 ++- compat-patches/replacements.sh | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100755 compat-patches/replacements.sh
Makefile +2 -1
@@ -99,7 +99,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/ @$(RM) $(SOURCE_BUILD) @$(CP) $(SOURCE) $(BUILD_DIR)/net/batman-adv/
@@ -111,6 +111,7 @@ $(SOURCE_STAMP): $(SOURCE) compat-patches/* $(PATCH) ../compat-patches/$${i}; \ cd - > /dev/null; \ done + compat-patches/replacements.sh touch $(SOURCE_STAMP) .PHONY: all clean install config
compat-patches/replacements.sh new file +3 -0
@@ -0,0 +1,3 @@ +#! /bin/sh + +set -e
Signature · 1 line
2.9.3
Re: [B.A.T.M.A.N.] [next, v2, 02/11] batman-adv: Use simple script to patch minor compat problems
Quoted 10 lines · On Sonntag, 9. Oktober 2016 08:57:29 CEST Sven Eckelmann wrote:
Unified diff base patches have the problem that they fix only a single line and depend on the surrounding. This approach can fail relative often when the surrounding code will be changed often. Thus semantic patches (like spatch from coccinelle) or simple find+replace scripts are better for this approach.
Introduce a simple script file which will store these kind of find+replace instructions.
Signed-off-by Sven Eckelmann <[email protected]>
Quoted 8 lines
---
v2:
- no change--- Makefile | 3 ++- compat-patches/replacements.sh | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100755 compat-patches/replacements.sh
Applied in 17018a99bc68f49ea1da199c9c1b290e3b2c42ed [1].
Kind regards,
Sven
[1] https://git.open-mesh.org/batman-adv.git/commit/17018a99bc68f49ea1da199c9c1b290e3b2c42ed
Sven Eckelmann
maintainerPATCH v2 3/11 batman-adv: make netlink attributes const
In reply to Sven EckelmannFrom: stephen hemminger <[email protected]>
---
v2:
- remove second replacement line which basically does nothing (thanks Linus)
--- compat-patches/replacements.sh | 5 +++++ net/batman-adv/netlink.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-)
compat-patches/replacements.sh +5 -0
@@ -1,3 +1,8 @@ #! /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 struct genl_multicast_group batadv_netlink_mcgrps/' \ + build/net/batman-adv/netlink.c
net/batman-adv/netlink.c +2 -2
@@ -62,11 +62,11 @@ enum batadv_netlink_multicast_groups { BATADV_NL_MCGRP_TPMETER, }; -static struct genl_multicast_group batadv_netlink_mcgrps[] = { +static const struct genl_multicast_group batadv_netlink_mcgrps[] = { [BATADV_NL_MCGRP_TPMETER ] = { .name =BATADV_NL_MCAST_GROUP_TPMETER }, }; -static struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR ] = { +static const struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR ] = { [BATADV_ATTR_VERSION ] = { .type =NLA_STRING }, [BATADV_ATTR_ALGO_NAME ] = { .type =NLA_STRING }, [BATADV_ATTR_MESH_IFINDEX ] = { .type =NLA_U32 },
Signature · 1 line
2.9.3
Re: [B.A.T.M.A.N.] [next, v2, 03/11] batman-adv: make netlink attributes const
Quoted 5 lines · On Sonntag, 9. Oktober 2016 08:57:30 CEST Sven Eckelmann wrote:
From: stephen hemminger <[email protected]>
Signed-off-by Stephen Hemminger <[email protected]>[[email protected]: Add compat-patch script]Signed-off-by Sven Eckelmann <[email protected]>
Quoted 8 lines
---
v2:
- remove second replacement line which basically does nothing (thanks Linus)--- compat-patches/replacements.sh | 5 +++++ net/batman-adv/netlink.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-)
Applied in 801d51e947da78bc542b30ee8e6971f941f8f66b [1]. It was slightly modified to use __genl_const from https://patchwork.open-mesh.org/patch/16730/
Kind regards,
Sven
[1] https://git.open-mesh.org/batman-adv.git/commit/801d51e947da78bc542b30ee8e6971f941f8f66b
Sven Eckelmann
maintainerPATCH v2 4/11 batman-adv: Mark batadv_netlink_ops as const
In reply to Sven EckelmannThe genl_ops don't need to be written by anyone and thus can be moved in a ro memory range.
---
v2:
- new patch
--- compat-patches/replacements.sh | 1 + net/batman-adv/netlink.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
compat-patches/replacements.sh +1 -0
@@ -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 struct genl_multicast_group batadv_netlink_mcgrps/' \ + -e 's/^static const struct genl_ops batadv_netlink_ops/static struct genl_ops batadv_netlink_ops/' \ build/net/batman-adv/netlink.c
net/batman-adv/netlink.c +1 -1
@@ -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 ,
Signature · 1 line
2.9.3
Sven Eckelmann
maintainerPATCH v2 5/11 batman-adv: Add support for coccinelle in compat-patches
In reply to Sven EckelmannThe 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.
---
v2:
- new patch
--- Makefile | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
Makefile +18 -5
@@ -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)
Signature · 1 line
2.9.3
Sven Eckelmann
maintainerPATCH v2 6/11 batman-adv: compat: Port netlink port hack to coccinelle
In reply to Sven Eckelmann---
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
compat-include/linux/netlink.h +7 -13
@@ -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) */
compat-include/net/genetlink.h +11 -0
@@ -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>
compat-patches/0001-netlink-portid.cocci new file +17 -0
@@ -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)
compat.h +0 -6
@@ -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) \
Signature · 1 line
2.9.3
Sven Eckelmann
maintainerPATCH v2 7/11 batman-adv: compat: Move netlink const compat to coccinelle
In reply to Sven Eckelmann---
v2:
- new patch
--- compat-include/net/genetlink.h | 6 ++++++ compat-patches/0002-genl-const.INFO | 15 +++++++++++++++ compat-patches/0002-genl-const.cocci | 10 ++++++++++ compat-patches/replacements.sh | 9 --------- 4 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 compat-patches/0002-genl-const.INFO create mode 100644 compat-patches/0002-genl-const.cocci delete mode 100755 compat-patches/replacements.sh
compat-include/net/genetlink.h +6 -0
@@ -163,6 +163,12 @@ batadv_genl_register_family_with_ops_grps(struct genl_family *family,return batadv_genl_register_family (family); } +#define __genl_const + +#else + +#define __genl_const const +#endif /* < KERNEL_VERSION(3, 13, 0) */ #endif /* _NET_BATMAN_ADV_COMPAT_NET_GENETLINK_H_ */
compat-patches/0002-genl-const.INFO new file +15 -0
@@ -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
compat-patches/0002-genl-const.cocci new file +10 -0
@@ -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 +)
compat-patches/replacements.sh deleted +0 -9
@@ -1,9 +0,0 @@ -#! /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 struct genl_multicast_group batadv_netlink_mcgrps/' \ - -e 's/^static const struct genl_ops batadv_netlink_ops/static struct genl_ops batadv_netlink_ops/' \ - build/net/batman-adv/netlink.c
Signature · 1 line
2.9.3
Sven Eckelmann
maintainerPATCH v2 8/11 batman-adv: compat: Remove replacement script
In reply to Sven Eckelmann---
v2:
- new patch
--- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Makefile +1 -2
@@ -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
Signature · 1 line
2.9.3
Sven Eckelmann
maintainerPATCH v2 9/11 batman-adv: compat: Replace IFF_NO_QUEUE with coccinelle
In reply to Sven Eckelmann---
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
compat-patches/0003-iff-no-queue.cocci new file +9 -0
@@ -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
compat.h +0 -6
@@ -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_ */
Signature · 1 line
2.9.3
Sven Eckelmann
maintainerPATCH v2 10/11 batman-adv: compat: Move get_link_net patch to coccinelle
In reply to Sven Eckelmann---
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
compat-patches/0004-get_link_net.cocci new file +13 -0
@@ -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 + }
compat.h +0 -7
@@ -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_ */
Signature · 1 line
2.9.3
Sven Eckelmann
maintainerPATCH v2 11/11 batman-adv: compat: Move vid api wrapper to coccinelle
In reply to Sven Eckelmann---
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
compat-include/linux/netdevice.h +6 -0
@@ -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 )
compat-patches/0005-vid-callbacks.cocci new file +74 -0
74 lines not on this page · raw message
compat.h +0 -54
66 lines not on this page · raw message
Signature · 1 line
2.9.3