netfilter: bridge: refactor frag_max_size
authorBernhard Thaler <bernhard.thaler@wvnet.at>
Sat, 30 May 2015 13:28:28 +0000 (15:28 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 12 Jun 2015 12:08:51 +0000 (14:08 +0200)
Currently frag_max_size is member of br_input_skb_cb and copied back and
forth using IPCB(skb) and BR_INPUT_SKB_CB(skb) each time it is changed or
used.

Attach frag_max_size to nf_bridge_info and set value in pre_routing and
forward functions. Use its value in forward and xmit functions.

Signed-off-by: Bernhard Thaler <bernhard.thaler@wvnet.at>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/linux/skbuff.h
net/bridge/br_netfilter.c
net/bridge/br_private.h

index f70fc0e6bf7bb3836758f375c020d250af18659c..32b105e682b3fef890a0c2318f144203df218db0 100644 (file)
@@ -174,6 +174,7 @@ struct nf_bridge_info {
                BRNF_PROTO_PPPOE
        } orig_proto:8;
        bool                    pkt_otherhost;
+       __u16                   frag_max_size;
        unsigned int            mask;
        struct net_device       *physindev;
        union {
index 9ac0c6417c773623a63d09a1e771f39c8ec34615..1f30b28745de00f480d7a3277902e75cf39abf98 100644 (file)
@@ -440,10 +440,8 @@ static int br_nf_pre_routing_finish(struct sock *sk, struct sk_buff *skb)
        struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb);
        struct rtable *rt;
        int err;
-       int frag_max_size;
 
-       frag_max_size = IPCB(skb)->frag_max_size;
-       BR_INPUT_SKB_CB(skb)->frag_max_size = frag_max_size;
+       nf_bridge->frag_max_size = IPCB(skb)->frag_max_size;
 
        if (nf_bridge->pkt_otherhost) {
                skb->pkt_type = PACKET_OTHERHOST;
@@ -738,11 +736,9 @@ static int br_nf_forward_finish(struct sock *sk, struct sk_buff *skb)
        struct net_device *in;
 
        if (!IS_ARP(skb) && !IS_VLAN_ARP(skb)) {
-               int frag_max_size;
 
                if (skb->protocol == htons(ETH_P_IP)) {
-                       frag_max_size = IPCB(skb)->frag_max_size;
-                       BR_INPUT_SKB_CB(skb)->frag_max_size = frag_max_size;
+                       nf_bridge->frag_max_size = IPCB(skb)->frag_max_size;
                }
 
                in = nf_bridge->physindev;
@@ -806,12 +802,9 @@ static unsigned int br_nf_forward_ip(const struct nf_hook_ops *ops,
        }
 
        if (pf == NFPROTO_IPV4) {
-               int frag_max = BR_INPUT_SKB_CB(skb)->frag_max_size;
-
                if (br_parse_ip_options(skb))
                        return NF_DROP;
-
-               IPCB(skb)->frag_max_size = frag_max;
+               IPCB(skb)->frag_max_size = nf_bridge->frag_max_size;
        }
 
        nf_bridge->physoutdev = skb->dev;
@@ -904,7 +897,7 @@ static int br_nf_ip_fragment(struct sock *sk, struct sk_buff *skb,
 static int br_nf_dev_queue_xmit(struct sock *sk, struct sk_buff *skb)
 {
        int ret;
-       int frag_max_size;
+       struct nf_bridge_info *nf_bridge;
        unsigned int mtu_reserved;
 
        if (skb_is_gso(skb) || skb->protocol != htons(ETH_P_IP)) {
@@ -913,17 +906,18 @@ static int br_nf_dev_queue_xmit(struct sock *sk, struct sk_buff *skb)
        }
 
        mtu_reserved = nf_bridge_mtu_reduction(skb);
+       nf_bridge = nf_bridge_info_get(skb);
        /* This is wrong! We should preserve the original fragment
         * boundaries by preserving frag_list rather than refragmenting.
         */
        if (skb->len + mtu_reserved > skb->dev->mtu) {
                struct brnf_frag_data *data;
 
-               frag_max_size = BR_INPUT_SKB_CB(skb)->frag_max_size;
                if (br_parse_ip_options(skb))
                        /* Drop invalid packet */
                        return NF_DROP;
-               IPCB(skb)->frag_max_size = frag_max_size;
+
+               IPCB(skb)->frag_max_size = nf_bridge->frag_max_size;
 
                nf_bridge_update_protocol(skb);
 
index 1f36fa70639b7ca0657090c86a7f9d4bb67b1090..8cde96e68fd5e281dbe0f40ddcb522f7b135d421 100644 (file)
@@ -304,7 +304,6 @@ struct br_input_skb_cb {
        int mrouters_only;
 #endif
 
-       u16 frag_max_size;
        bool proxyarp_replied;
 
 #ifdef CONFIG_BRIDGE_VLAN_FILTERING