ipv4: Only compute net once in ip_do_fragment
[cascardo/linux.git] / net / ipv4 / ip_output.c
index 0138fad..85b72d4 100644 (file)
@@ -102,7 +102,7 @@ static int __ip_local_out_sk(struct sock *sk, struct sk_buff *skb)
        iph->tot_len = htons(skb->len);
        ip_send_check(iph);
        return nf_hook(NFPROTO_IPV4, NF_INET_LOCAL_OUT, sk, skb, NULL,
-                      skb_dst(skb)->dev, dst_output_sk);
+                      skb_dst(skb)->dev, dst_output);
 }
 
 int __ip_local_out(struct sk_buff *skb)
@@ -116,7 +116,7 @@ int ip_local_out_sk(struct sock *sk, struct sk_buff *skb)
 
        err = __ip_local_out(skb);
        if (likely(err == 1))
-               err = dst_output_sk(sk, skb);
+               err = dst_output(sk, skb);
 
        return err;
 }
@@ -271,7 +271,7 @@ static int ip_finish_output(struct sock *sk, struct sk_buff *skb)
        /* Policy lookup after SNAT yielded a new policy */
        if (skb_dst(skb)->xfrm) {
                IPCB(skb)->flags |= IPSKB_REROUTED;
-               return dst_output_sk(sk, skb);
+               return dst_output(sk, skb);
        }
 #endif
        mtu = ip_skb_dst_mtu(skb);
@@ -288,11 +288,12 @@ int ip_mc_output(struct sock *sk, struct sk_buff *skb)
 {
        struct rtable *rt = skb_rtable(skb);
        struct net_device *dev = rt->dst.dev;
+       struct net *net = dev_net(dev);
 
        /*
         *      If the indicated interface is up and running, send the packet.
         */
-       IP_UPD_PO_STATS(dev_net(dev), IPSTATS_MIB_OUT, skb->len);
+       IP_UPD_PO_STATS(net, IPSTATS_MIB_OUT, skb->len);
 
        skb->dev = dev;
        skb->protocol = htons(ETH_P_IP);
@@ -347,8 +348,9 @@ int ip_mc_output(struct sock *sk, struct sk_buff *skb)
 int ip_output(struct sock *sk, struct sk_buff *skb)
 {
        struct net_device *dev = skb_dst(skb)->dev;
+       struct net *net = dev_net(dev);
 
-       IP_UPD_PO_STATS(dev_net(dev), IPSTATS_MIB_OUT, skb->len);
+       IP_UPD_PO_STATS(net, IPSTATS_MIB_OUT, skb->len);
 
        skb->dev = dev;
        skb->protocol = htons(ETH_P_IP);
@@ -529,9 +531,11 @@ int ip_do_fragment(struct sock *sk, struct sk_buff *skb,
        int offset;
        __be16 not_last_frag;
        struct rtable *rt = skb_rtable(skb);
+       struct net *net;
        int err = 0;
 
        dev = rt->dst.dev;
+       net = dev_net(dev);
 
        /*
         *      Point into the IP datagram header.
@@ -624,7 +628,7 @@ int ip_do_fragment(struct sock *sk, struct sk_buff *skb,
                        err = output(sk, skb);
 
                        if (!err)
-                               IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGCREATES);
+                               IP_INC_STATS(net, IPSTATS_MIB_FRAGCREATES);
                        if (err || !frag)
                                break;
 
@@ -634,7 +638,7 @@ int ip_do_fragment(struct sock *sk, struct sk_buff *skb,
                }
 
                if (err == 0) {
-                       IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGOKS);
+                       IP_INC_STATS(net, IPSTATS_MIB_FRAGOKS);
                        return 0;
                }
 
@@ -643,7 +647,7 @@ int ip_do_fragment(struct sock *sk, struct sk_buff *skb,
                        kfree_skb(frag);
                        frag = skb;
                }
-               IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS);
+               IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS);
                return err;
 
 slow_path_clean:
@@ -765,15 +769,15 @@ slow_path:
                if (err)
                        goto fail;
 
-               IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGCREATES);
+               IP_INC_STATS(net, IPSTATS_MIB_FRAGCREATES);
        }
        consume_skb(skb);
-       IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGOKS);
+       IP_INC_STATS(net, IPSTATS_MIB_FRAGOKS);
        return err;
 
 fail:
        kfree_skb(skb);
-       IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS);
+       IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS);
        return err;
 }
 EXPORT_SYMBOL(ip_do_fragment);