OSDN Git Service

ipv6: make ip6_dst_mtu_forward inline
[uclinux-h8/linux.git] / net / ipv6 / ip6_output.c
index b8ee50e..cec49e1 100644 (file)
@@ -375,30 +375,13 @@ static int ip6_forward_proxy_check(struct sk_buff *skb)
 static inline int ip6_forward_finish(struct net *net, struct sock *sk,
                                     struct sk_buff *skb)
 {
-       return dst_output(net, sk, skb);
-}
-
-unsigned int ip6_dst_mtu_forward(const struct dst_entry *dst)
-{
-       unsigned int mtu;
-       struct inet6_dev *idev;
-
-       if (dst_metric_locked(dst, RTAX_MTU)) {
-               mtu = dst_metric_raw(dst, RTAX_MTU);
-               if (mtu)
-                       return mtu;
-       }
+       struct dst_entry *dst = skb_dst(skb);
 
-       mtu = IPV6_MIN_MTU;
-       rcu_read_lock();
-       idev = __in6_dev_get(dst->dev);
-       if (idev)
-               mtu = idev->cnf.mtu6;
-       rcu_read_unlock();
+       __IP6_INC_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTFORWDATAGRAMS);
+       __IP6_ADD_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTOCTETS, skb->len);
 
-       return mtu;
+       return dst_output(net, sk, skb);
 }
-EXPORT_SYMBOL_GPL(ip6_dst_mtu_forward);
 
 static bool ip6_pkt_too_big(const struct sk_buff *skb, unsigned int mtu)
 {
@@ -420,6 +403,7 @@ static bool ip6_pkt_too_big(const struct sk_buff *skb, unsigned int mtu)
 
 int ip6_forward(struct sk_buff *skb)
 {
+       struct inet6_dev *idev = __in6_dev_get_safely(skb->dev);
        struct dst_entry *dst = skb_dst(skb);
        struct ipv6hdr *hdr = ipv6_hdr(skb);
        struct inet6_skb_parm *opt = IP6CB(skb);
@@ -439,8 +423,7 @@ int ip6_forward(struct sk_buff *skb)
                goto drop;
 
        if (!xfrm6_policy_check(NULL, XFRM_POLICY_FWD, skb)) {
-               __IP6_INC_STATS(net, ip6_dst_idev(dst),
-                               IPSTATS_MIB_INDISCARDS);
+               __IP6_INC_STATS(net, idev, IPSTATS_MIB_INDISCARDS);
                goto drop;
        }
 
@@ -471,8 +454,7 @@ int ip6_forward(struct sk_buff *skb)
                /* Force OUTPUT device used as source address */
                skb->dev = dst->dev;
                icmpv6_send(skb, ICMPV6_TIME_EXCEED, ICMPV6_EXC_HOPLIMIT, 0);
-               __IP6_INC_STATS(net, ip6_dst_idev(dst),
-                               IPSTATS_MIB_INHDRERRORS);
+               __IP6_INC_STATS(net, idev, IPSTATS_MIB_INHDRERRORS);
 
                kfree_skb(skb);
                return -ETIMEDOUT;
@@ -485,15 +467,13 @@ int ip6_forward(struct sk_buff *skb)
                if (proxied > 0)
                        return ip6_input(skb);
                else if (proxied < 0) {
-                       __IP6_INC_STATS(net, ip6_dst_idev(dst),
-                                       IPSTATS_MIB_INDISCARDS);
+                       __IP6_INC_STATS(net, idev, IPSTATS_MIB_INDISCARDS);
                        goto drop;
                }
        }
 
        if (!xfrm6_route_forward(skb)) {
-               __IP6_INC_STATS(net, ip6_dst_idev(dst),
-                               IPSTATS_MIB_INDISCARDS);
+               __IP6_INC_STATS(net, idev, IPSTATS_MIB_INDISCARDS);
                goto drop;
        }
        dst = skb_dst(skb);
@@ -549,8 +529,7 @@ int ip6_forward(struct sk_buff *skb)
                /* Again, force OUTPUT device used as source address */
                skb->dev = dst->dev;
                icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
-               __IP6_INC_STATS(net, ip6_dst_idev(dst),
-                               IPSTATS_MIB_INTOOBIGERRORS);
+               __IP6_INC_STATS(net, idev, IPSTATS_MIB_INTOOBIGERRORS);
                __IP6_INC_STATS(net, ip6_dst_idev(dst),
                                IPSTATS_MIB_FRAGFAILS);
                kfree_skb(skb);
@@ -569,14 +548,12 @@ int ip6_forward(struct sk_buff *skb)
 
        hdr->hop_limit--;
 
-       __IP6_INC_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTFORWDATAGRAMS);
-       __IP6_ADD_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTOCTETS, skb->len);
        return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD,
                       net, NULL, skb, skb->dev, dst->dev,
                       ip6_forward_finish);
 
 error:
-       __IP6_INC_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_INADDRERRORS);
+       __IP6_INC_STATS(net, idev, IPSTATS_MIB_INADDRERRORS);
 drop:
        kfree_skb(skb);
        return -EINVAL;
@@ -969,7 +946,8 @@ static int ip6_dst_lookup_tail(struct net *net, const struct sock *sk,
                if (!had_dst)
                        *dst = ip6_route_output(net, sk, fl6);
                rt = (*dst)->error ? NULL : (struct rt6_info *)*dst;
-               err = ip6_route_get_saddr(net, rt, &fl6->daddr,
+               err = ip6_route_get_saddr(net, rt ? rt->from : NULL,
+                                         &fl6->daddr,
                                          sk ? inet6_sk(sk)->srcprefs : 0,
                                          &fl6->saddr);
                if (err)