Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: explicit module dependency between br_netfilter and physdev

You can use physdev to match the physical interface enslaved to the
bridge device. This information is stored in skb->nf_bridge and it is
set up by br_netfilter. So, this is only available when iptables is
used from the bridge netfilter path.

Since 34666d4 ("netfilter: bridge: move br_netfilter out of the core"),
the br_netfilter code is modular. To reduce the impact of this change,
we can autoload the br_netfilter if the physdev match is used since
we assume that the users need br_netfilter in place.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

+14
+6
include/net/netfilter/br_netfilter.h
··· 1 + #ifndef _BR_NETFILTER_H_ 2 + #define _BR_NETFILTER_H_ 3 + 4 + void br_netfilter_enable(void); 5 + 6 + #endif /* _BR_NETFILTER_H_ */
+5
net/bridge/br_netfilter.c
··· 856 856 return NF_ACCEPT; 857 857 } 858 858 859 + void br_netfilter_enable(void) 860 + { 861 + } 862 + EXPORT_SYMBOL_GPL(br_netfilter_enable); 863 + 859 864 /* For br_nf_post_routing, we need (prio = NF_BR_PRI_LAST), because 860 865 * br_dev_queue_push_xmit is called afterwards */ 861 866 static struct nf_hook_ops br_nf_ops[] __read_mostly = {
+3
net/netfilter/xt_physdev.c
··· 13 13 #include <linux/netfilter_bridge.h> 14 14 #include <linux/netfilter/xt_physdev.h> 15 15 #include <linux/netfilter/x_tables.h> 16 + #include <net/netfilter/br_netfilter.h> 16 17 17 18 MODULE_LICENSE("GPL"); 18 19 MODULE_AUTHOR("Bart De Schuymer <bdschuym@pandora.be>"); ··· 87 86 static int physdev_mt_check(const struct xt_mtchk_param *par) 88 87 { 89 88 const struct xt_physdev_info *info = par->matchinfo; 89 + 90 + br_netfilter_enable(); 90 91 91 92 if (!(info->bitmask & XT_PHYSDEV_OP_MASK) || 92 93 info->bitmask & ~XT_PHYSDEV_OP_MASK)