[OpenWrt-Devel] [PATCH] kernel: 3.18: Fix patch 644 dependency chain

Maxime Ripard maxime.ripard at free-electrons.com
Fri Nov 7 05:56:00 EST 2014


This patch introduces some code that is compiled in whenever
CONFIG_BRIDGE_NETFILTER is built, with the code called from code compiled under
CONFIG_BRIDGE, CONFIG_BRIDGE_IGMP_SNOOPING or CONFIG_BRIDGE_NF_EBTABLES.

Unfortunately, these options aren't setting explicitly the dependency they now
have on CONFIG_BRIDGE_NETFILTER, for obvious reasons for CONFIG_BRIDGE.

However, this is not working really well when CONFIG_BRIDGE_NETFILTER is built
as a module, since code statically compiled will now use a function that is not
in the kernel image, which makes the linker grumpy.

Solve this by removing the option to build CONFIG_BRIDGE_NETFILTER as a module,
and protect our function definition by an IS_BUILTIN instead of a IS_ENABLED
macro. This fixes the issue for CONFIG_BRIDGE and CONFIG_BRIDGE_IGMP_SNOOPING.

Fixing CONFIG_BRIDGE_NF_EBTABLES has to be handled a bit differently, since it
directly references a variable that will not be declared if
CONFIG_BRIDGE_NETFILTER is not set. Protect the variable affectations by an
ifdef to make sure this doesn't happen.

Signed-off-by: Maxime Ripard <maxime.ripard at free-electrons.com>
---
 .../644-bridge_optimize_netfilter_hooks.patch      | 43 +++++++++++++++-------
 1 file changed, 30 insertions(+), 13 deletions(-)

diff --git a/target/linux/generic/patches-3.18/644-bridge_optimize_netfilter_hooks.patch b/target/linux/generic/patches-3.18/644-bridge_optimize_netfilter_hooks.patch
index bbfcaa402d33..f4e6020b3e56 100644
--- a/target/linux/generic/patches-3.18/644-bridge_optimize_netfilter_hooks.patch
+++ b/target/linux/generic/patches-3.18/644-bridge_optimize_netfilter_hooks.patch
@@ -96,22 +96,17 @@
  	if (vlan_tx_tag_present(skb))
 --- a/net/bridge/br_private.h
 +++ b/net/bridge/br_private.h
-@@ -769,15 +769,29 @@ static inline int br_vlan_enabled(struct
+@@ -778,6 +778,24 @@ static inline void br_nf_core_fini(void)
+ #define br_netfilter_rtable_init(x)
+ #endif
  
- /* br_netfilter.c */
- #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
++#if IS_BUILTIN(CONFIG_BRIDGE_NETFILTER)
 +extern int brnf_call_ebtables;
- int br_nf_core_init(void);
- void br_nf_core_fini(void);
- void br_netfilter_rtable_init(struct net_bridge *);
 +bool br_netfilter_run_hooks(void);
- #else
- static inline int br_nf_core_init(void) { return 0; }
- static inline void br_nf_core_fini(void) {}
- #define br_netfilter_rtable_init(x)
++#else
 +#define br_netfilter_run_hooks()	false
- #endif
- 
++#endif
++
 +static inline int
 +BR_HOOK(uint8_t pf, unsigned int hook, struct sk_buff *skb,
 +	struct net_device *in, struct net_device *out,
@@ -139,17 +134,39 @@
  
 --- a/net/bridge/netfilter/ebtables.c
 +++ b/net/bridge/netfilter/ebtables.c
-@@ -2414,11 +2414,13 @@ static int __init ebtables_init(void)
+@@ -2414,11 +2414,19 @@ static int __init ebtables_init(void)
  	}
  
  	printk(KERN_INFO "Ebtables v2.0 registered\n");
++
++#if IS_BUILTIN(CONFIG_BRIDGE_NETFILTER)
 +	brnf_call_ebtables = 1;
++#endif
++
  	return 0;
  }
  
  static void __exit ebtables_fini(void)
  {
++#if IS_BUILTIN(CONFIG_BRIDGE_NETFILTER)
 +	brnf_call_ebtables = 0;
++#endif
  	nf_unregister_sockopt(&ebt_sockopts);
  	xt_unregister_target(&ebt_standard_target);
  	printk(KERN_INFO "Ebtables v2.0 unregistered\n");
+--- a/net/Kconfig
++++ b/net/Kconfig
+@@ -177,11 +177,11 @@ config NETFILTER_ADVANCED
+ 	  If unsure, say Y.
+ 
+ config BRIDGE_NETFILTER
+-	tristate "Bridged IP/ARP packets filtering"
++	bool "Bridged IP/ARP packets filtering"
+ 	depends on BRIDGE
+ 	depends on NETFILTER && INET
+ 	depends on NETFILTER_ADVANCED
+-	default m
++	default y
+ 	---help---
+ 	  Enabling this option will let arptables resp. iptables see bridged
+ 	  ARP resp. IP traffic. If you want a bridging firewall, you probably
-- 
2.1.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list