netfilter: explicit module dependency between br_netfilter and physdev
Subsystems (3)
Pablo Neira Ayuso
maintainerPATCH v2 1/1 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.
---
Changes in v2: Remove module refcount, we don't need this. Suggested by Florian and Patrick.
include/net/netfilter/br_netfilter.h | 6 ++++++ net/bridge/br_netfilter.c | 5 +++++ net/netfilter/xt_physdev.c | 3 +++ 3 files changed, 14 insertions(+) create mode 100644 include/net/netfilter/br_netfilter.h
include/net/netfilter/br_netfilter.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef _BR_NETFILTER_H_ +#define _BR_NETFILTER_H_ + +void br_netfilter_enable (void ); + +#endif /* _BR_NETFILTER_H_ */
net/bridge/br_netfilter.c +5 -0
@@ -856,6 +856,11 @@ static unsigned int ip_sabotage_in(const struct nf_hook_ops *ops,return NF_ACCEPT ; } +void br_netfilter_enable (void ) +{ +} +EXPORT_SYMBOL_GPL (br_netfilter_enable); +/* For br_nf_post_routing, we need (prio = NF_BR_PRI_LAST), because * br_dev_queue_push_xmit is called afterwards */ static struct nf_hook_ops br_nf_ops[]__read_mostly = {
net/netfilter/xt_physdev.c +3 -0
@@ -13,6 +13,7 @@#include <linux/netfilter_bridge.h> #include <linux/netfilter/xt_physdev.h> #include <linux/netfilter/x_tables.h> +#include <net/netfilter/br_netfilter.h> MODULE_LICENSE ("GPL" );MODULE_AUTHOR ("Bart De Schuymer <[email protected]>" );
@@ -87,6 +88,8 @@ static int physdev_mt_check(const struct xt_mtchk_param *par) {const struct xt_physdev_info *info = par->matchinfo; +br_netfilter_enable (); +if (!(info->bitmask &XT_PHYSDEV_OP_MASK ) || info->bitmask & ~XT_PHYSDEV_OP_MASK )return -EINVAL ;
Signature · 1 line
1.7.10.4
Florian Westphal
maintainerQuoted 10 lines · Pablo Neira Ayuso
You can use physdev to match the physical interface enslaved to the bridge device. This information is stored in
skb->nf_bridgeand it is set up bybr_netfilter. So, this is only available when iptables is used from the bridge netfilter path.Since 34666d4 ("netfilter: bridge: move
br_netfilterout of the core"), thebr_netfiltercode is modular. To reduce the impact of this change, we can autoload thebr_netfilterif the physdev match is used since we assume that the users needbr_netfilterin place.
Quoted 4 lines
Signed-off-by Pablo Neira Ayuso <[email protected]>---
Changes in v2: Remove module refcount, we don't need this. Suggested by Florian and Patrick.
Looks good, thanks Pablo!