aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2015-04-02 08:31:44 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2015-04-08 10:49:11 -0400
commit3eaf402502e49ad9c58c73e8599c7c4f345d62da (patch)
treedf5d4e77678c1793f11fdf828c0a98645314674c
parent383307838d41935841ba6b2e939b968326e2dea1 (diff)
netfilter: bridge: start splitting mask into public/private chunks
->mask is a bit info field that mixes various use cases. In particular, we have flags that are mutually exlusive, and flags that are only used within br_netfilter while others need to be exposed to other parts of the kernel. Remove BRNF_8021Q/PPPoE flags. They're mutually exclusive and only needed within br_netfilter context. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--include/linux/netfilter_bridge.h4
-rw-r--r--include/linux/skbuff.h5
-rw-r--r--net/bridge/br_netfilter.c15
3 files changed, 17 insertions, 7 deletions
diff --git a/include/linux/netfilter_bridge.h b/include/linux/netfilter_bridge.h
index e1d96bc2767c..d47a32dffa15 100644
--- a/include/linux/netfilter_bridge.h
+++ b/include/linux/netfilter_bridge.h
@@ -20,12 +20,10 @@ enum nf_br_hook_priorities {
20#define BRNF_PKT_TYPE 0x01 20#define BRNF_PKT_TYPE 0x01
21#define BRNF_BRIDGED_DNAT 0x02 21#define BRNF_BRIDGED_DNAT 0x02
22#define BRNF_NF_BRIDGE_PREROUTING 0x08 22#define BRNF_NF_BRIDGE_PREROUTING 0x08
23#define BRNF_8021Q 0x10
24#define BRNF_PPPoE 0x20
25 23
26static inline unsigned int nf_bridge_mtu_reduction(const struct sk_buff *skb) 24static inline unsigned int nf_bridge_mtu_reduction(const struct sk_buff *skb)
27{ 25{
28 if (unlikely(skb->nf_bridge->mask & BRNF_PPPoE)) 26 if (skb->nf_bridge->orig_proto == BRNF_PROTO_PPPOE)
29 return PPPOE_SES_HLEN; 27 return PPPOE_SES_HLEN;
30 return 0; 28 return 0;
31} 29}
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index f66a089afc41..6f75fb5c6ed7 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -166,6 +166,11 @@ struct nf_conntrack {
166#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER) 166#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
167struct nf_bridge_info { 167struct nf_bridge_info {
168 atomic_t use; 168 atomic_t use;
169 enum {
170 BRNF_PROTO_UNCHANGED,
171 BRNF_PROTO_8021Q,
172 BRNF_PROTO_PPPOE
173 } orig_proto;
169 unsigned int mask; 174 unsigned int mask;
170 struct net_device *physindev; 175 struct net_device *physindev;
171 struct net_device *physoutdev; 176 struct net_device *physoutdev;
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index 301f12b0a7cd..ab1e988ca4b8 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -262,10 +262,16 @@ drop:
262 262
263static void nf_bridge_update_protocol(struct sk_buff *skb) 263static void nf_bridge_update_protocol(struct sk_buff *skb)
264{ 264{
265 if (skb->nf_bridge->mask & BRNF_8021Q) 265 switch (skb->nf_bridge->orig_proto) {
266 case BRNF_PROTO_8021Q:
266 skb->protocol = htons(ETH_P_8021Q); 267 skb->protocol = htons(ETH_P_8021Q);
267 else if (skb->nf_bridge->mask & BRNF_PPPoE) 268 break;
269 case BRNF_PROTO_PPPOE:
268 skb->protocol = htons(ETH_P_PPP_SES); 270 skb->protocol = htons(ETH_P_PPP_SES);
271 break;
272 case BRNF_PROTO_UNCHANGED:
273 break;
274 }
269} 275}
270 276
271/* PF_BRIDGE/PRE_ROUTING *********************************************/ 277/* PF_BRIDGE/PRE_ROUTING *********************************************/
@@ -503,10 +509,11 @@ static struct net_device *setup_pre_routing(struct sk_buff *skb)
503 nf_bridge->mask |= BRNF_NF_BRIDGE_PREROUTING; 509 nf_bridge->mask |= BRNF_NF_BRIDGE_PREROUTING;
504 nf_bridge->physindev = skb->dev; 510 nf_bridge->physindev = skb->dev;
505 skb->dev = brnf_get_logical_dev(skb, skb->dev); 511 skb->dev = brnf_get_logical_dev(skb, skb->dev);
512
506 if (skb->protocol == htons(ETH_P_8021Q)) 513 if (skb->protocol == htons(ETH_P_8021Q))
507 nf_bridge->mask |= BRNF_8021Q; 514 nf_bridge->orig_proto = BRNF_PROTO_8021Q;
508 else if (skb->protocol == htons(ETH_P_PPP_SES)) 515 else if (skb->protocol == htons(ETH_P_PPP_SES))
509 nf_bridge->mask |= BRNF_PPPoE; 516 nf_bridge->orig_proto = BRNF_PROTO_PPPOE;
510 517
511 /* Must drop socket now because of tproxy. */ 518 /* Must drop socket now because of tproxy. */
512 skb_orphan(skb); 519 skb_orphan(skb);