aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2014-09-18 05:29:03 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2014-09-26 12:42:31 -0400
commit34666d467cbf1e2e3c7bb15a63eccfb582cdd71f (patch)
treef4b44a26f14d9c06dbb2d5df9284f0a00ee974bc /include/linux
parent7276ca3fa23864133f5ee7431c51546d9b7f695f (diff)
netfilter: bridge: move br_netfilter out of the core
Jesper reported that br_netfilter always registers the hooks since this is part of the bridge core. This harms performance for people that don't need this. This patch modularizes br_netfilter so it can be rmmod'ed, thus, the hooks can be unregistered. I think the bridge netfilter should have been a separated module since the beginning, Patrick agreed on that. Note that this is breaking compatibility for users that expect that bridge netfilter is going to be available after explicitly 'modprobe bridge' or via automatic load through brctl. However, the damage can be easily undone by modprobing br_netfilter. The bridge core also spots a message to provide a clue to people that didn't notice that this has been deprecated. On top of that, the plan is that nftables will not rely on this software layer, but integrate the connection tracking into the bridge layer to enable stateful filtering and NAT, which is was bridge netfilter users seem to require. This patch still keeps the fake_dst_ops in the bridge core, since this is required by when the bridge port is initialized. So we can safely modprobe/rmmod br_netfilter anytime. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Acked-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/netfilter_bridge.h2
-rw-r--r--include/linux/skbuff.h12
2 files changed, 7 insertions, 7 deletions
diff --git a/include/linux/netfilter_bridge.h b/include/linux/netfilter_bridge.h
index fe996d59de64..c755e4971fa3 100644
--- a/include/linux/netfilter_bridge.h
+++ b/include/linux/netfilter_bridge.h
@@ -15,7 +15,7 @@ enum nf_br_hook_priorities {
15 NF_BR_PRI_LAST = INT_MAX, 15 NF_BR_PRI_LAST = INT_MAX,
16}; 16};
17 17
18#ifdef CONFIG_BRIDGE_NETFILTER 18#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
19 19
20#define BRNF_PKT_TYPE 0x01 20#define BRNF_PKT_TYPE 0x01
21#define BRNF_BRIDGED_DNAT 0x02 21#define BRNF_BRIDGED_DNAT 0x02
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 07c9fdd0c126..c4ff43f84573 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -156,7 +156,7 @@ struct nf_conntrack {
156}; 156};
157#endif 157#endif
158 158
159#ifdef CONFIG_BRIDGE_NETFILTER 159#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
160struct nf_bridge_info { 160struct nf_bridge_info {
161 atomic_t use; 161 atomic_t use;
162 unsigned int mask; 162 unsigned int mask;
@@ -560,7 +560,7 @@ struct sk_buff {
560#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 560#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
561 struct nf_conntrack *nfct; 561 struct nf_conntrack *nfct;
562#endif 562#endif
563#ifdef CONFIG_BRIDGE_NETFILTER 563#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
564 struct nf_bridge_info *nf_bridge; 564 struct nf_bridge_info *nf_bridge;
565#endif 565#endif
566 566
@@ -2977,7 +2977,7 @@ static inline void nf_conntrack_get(struct nf_conntrack *nfct)
2977 atomic_inc(&nfct->use); 2977 atomic_inc(&nfct->use);
2978} 2978}
2979#endif 2979#endif
2980#ifdef CONFIG_BRIDGE_NETFILTER 2980#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
2981static inline void nf_bridge_put(struct nf_bridge_info *nf_bridge) 2981static inline void nf_bridge_put(struct nf_bridge_info *nf_bridge)
2982{ 2982{
2983 if (nf_bridge && atomic_dec_and_test(&nf_bridge->use)) 2983 if (nf_bridge && atomic_dec_and_test(&nf_bridge->use))
@@ -2995,7 +2995,7 @@ static inline void nf_reset(struct sk_buff *skb)
2995 nf_conntrack_put(skb->nfct); 2995 nf_conntrack_put(skb->nfct);
2996 skb->nfct = NULL; 2996 skb->nfct = NULL;
2997#endif 2997#endif
2998#ifdef CONFIG_BRIDGE_NETFILTER 2998#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
2999 nf_bridge_put(skb->nf_bridge); 2999 nf_bridge_put(skb->nf_bridge);
3000 skb->nf_bridge = NULL; 3000 skb->nf_bridge = NULL;
3001#endif 3001#endif
@@ -3016,7 +3016,7 @@ static inline void __nf_copy(struct sk_buff *dst, const struct sk_buff *src)
3016 nf_conntrack_get(src->nfct); 3016 nf_conntrack_get(src->nfct);
3017 dst->nfctinfo = src->nfctinfo; 3017 dst->nfctinfo = src->nfctinfo;
3018#endif 3018#endif
3019#ifdef CONFIG_BRIDGE_NETFILTER 3019#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
3020 dst->nf_bridge = src->nf_bridge; 3020 dst->nf_bridge = src->nf_bridge;
3021 nf_bridge_get(src->nf_bridge); 3021 nf_bridge_get(src->nf_bridge);
3022#endif 3022#endif
@@ -3030,7 +3030,7 @@ static inline void nf_copy(struct sk_buff *dst, const struct sk_buff *src)
3030#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 3030#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
3031 nf_conntrack_put(dst->nfct); 3031 nf_conntrack_put(dst->nfct);
3032#endif 3032#endif
3033#ifdef CONFIG_BRIDGE_NETFILTER 3033#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
3034 nf_bridge_put(dst->nf_bridge); 3034 nf_bridge_put(dst->nf_bridge);
3035#endif 3035#endif
3036 __nf_copy(dst, src); 3036 __nf_copy(dst, src);