]> git.itanic.dy.fi Git - linux-stable/commitdiff
ipv6: Add rt6_get_cookie() function
authorMartin KaFai Lau <kafai@fb.com>
Sat, 23 May 2015 03:56:01 +0000 (20:56 -0700)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 11 Nov 2017 13:34:32 +0000 (13:34 +0000)
commit b197df4f0f3782782e9ea8996e91b65ae33e8dd9 upstream.

Instead of doing the rt6->rt6i_node check whenever we need
to get the route's cookie.  Refactor it into rt6_get_cookie().
It is a prep work to handle FLOWI_FLAG_KNOWN_NH and also
percpu rt6_info later.

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
Cc: Steffen Klassert <steffen.klassert@secunet.com>
Cc: Julian Anastasov <ja@ssi.bg>
Signed-off-by: David S. Miller <davem@davemloft.net>
[bwh: Backported to 3.2:
 - Drop changes in inet6_sk_rx_dst_set(), sctp_v6_get_dst()
 - Adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
include/net/ip6_fib.h
include/net/ip6_route.h
net/ipv6/ip6_tunnel.c
net/ipv6/xfrm6_policy.c
net/netfilter/ipvs/ip_vs_xmit.c

index 39073588562983e77a247e953466a479ab3bdd5d..ac5cb6a45cefc7cd0343f9c8c0a84a52efd0dfd7 100644 (file)
@@ -126,6 +126,11 @@ static inline struct inet6_dev *ip6_dst_idev(struct dst_entry *dst)
        return ((struct rt6_info *)dst)->rt6i_idev;
 }
 
+static inline u32 rt6_get_cookie(const struct rt6_info *rt)
+{
+       return rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
+}
+
 struct fib6_walker_t {
        struct list_head lh;
        struct fib6_node *root, *node;
index 4913dacd13331132b6e596c43dbc5b6f1a0e2e32..67bfec19b99ac0f0baf7274f7e13a2311b7a59ff 100644 (file)
@@ -167,7 +167,7 @@ static inline void __ip6_dst_store(struct sock *sk, struct dst_entry *dst,
 #ifdef CONFIG_IPV6_SUBTREES
        np->saddr_cache = saddr;
 #endif
-       np->dst_cookie = rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
+       np->dst_cookie = rt6_get_cookie(rt);
 }
 
 static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst,
index 2b4b4e379ac8046d7a69e3fec5931998397fa474..55f5a1a5112d228ffe2a61e95491c50eef697c1a 100644 (file)
@@ -143,7 +143,7 @@ static inline void ip6_tnl_dst_reset(struct ip6_tnl *t)
 static inline void ip6_tnl_dst_store(struct ip6_tnl *t, struct dst_entry *dst)
 {
        struct rt6_info *rt = (struct rt6_info *) dst;
-       t->dst_cookie = rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
+       t->dst_cookie = rt6_get_cookie(rt);
        dst_release(t->dst_cache);
        t->dst_cache = dst;
 }
index db78e7d874d7d92113b177130c04ca00da64c450..353ce0071d25f7fc1ceba3c800095df87cbaf4cb 100644 (file)
@@ -78,8 +78,7 @@ static int xfrm6_init_path(struct xfrm_dst *path, struct dst_entry *dst,
 {
        if (dst->ops->family == AF_INET6) {
                struct rt6_info *rt = (struct rt6_info*)dst;
-               if (rt->rt6i_node)
-                       path->path_cookie = rt->rt6i_node->fn_sernum;
+               path->path_cookie = rt6_get_cookie(rt);
        }
 
        path->u.rt6.rt6i_nfheader_len = nfheader_len;
@@ -111,8 +110,7 @@ static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
                                                   RTF_LOCAL);
        xdst->u.rt6.rt6i_metric = rt->rt6i_metric;
        xdst->u.rt6.rt6i_node = rt->rt6i_node;
-       if (rt->rt6i_node)
-               xdst->route_cookie = rt->rt6i_node->fn_sernum;
+       xdst->route_cookie = rt6_get_cookie(rt);
        xdst->u.rt6.rt6i_gateway = rt->rt6i_gateway;
        xdst->u.rt6.rt6i_dst = rt->rt6i_dst;
        xdst->u.rt6.rt6i_src = rt->rt6i_src;
index cc8f8b43ba0e0c8b9ce7945e20194d9533894625..a6cbb7aacb25385be6b639fa7413aa9367126d7e 100644 (file)
@@ -272,7 +272,7 @@ __ip_vs_get_out_rt_v6(struct sk_buff *skb, struct ip_vs_dest *dest,
                                return NULL;
                        }
                        rt = (struct rt6_info *) dst;
-                       cookie = rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
+                       cookie = rt6_get_cookie(rt);
                        __ip_vs_dst_set(dest, 0, dst_clone(&rt->dst), cookie);
                        IP_VS_DBG(10, "new dst %pI6, src %pI6, refcnt=%d\n",
                                  &dest->addr.in6, &dest->dst_saddr.in6,