Commit b197df4f authored by Martin KaFai Lau's avatar Martin KaFai Lau Committed by David S. Miller

ipv6: Add rt6_get_cookie() function

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: default avatarMartin 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: default avatarDavid S. Miller <davem@davemloft.net>
parent 45e4fd26
...@@ -159,6 +159,11 @@ static inline void rt6_update_expires(struct rt6_info *rt0, int timeout) ...@@ -159,6 +159,11 @@ static inline void rt6_update_expires(struct rt6_info *rt0, int timeout)
rt0->rt6i_flags |= RTF_EXPIRES; rt0->rt6i_flags |= RTF_EXPIRES;
} }
static inline u32 rt6_get_cookie(const struct rt6_info *rt)
{
return rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
}
static inline void ip6_rt_put(struct rt6_info *rt) static inline void ip6_rt_put(struct rt6_info *rt)
{ {
/* dst_release() accepts a NULL parameter. /* dst_release() accepts a NULL parameter.
......
...@@ -145,7 +145,7 @@ static inline void __ip6_dst_store(struct sock *sk, struct dst_entry *dst, ...@@ -145,7 +145,7 @@ static inline void __ip6_dst_store(struct sock *sk, struct dst_entry *dst,
#ifdef CONFIG_IPV6_SUBTREES #ifdef CONFIG_IPV6_SUBTREES
np->saddr_cache = saddr; np->saddr_cache = saddr;
#endif #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, static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst,
......
...@@ -151,7 +151,7 @@ EXPORT_SYMBOL_GPL(ip6_tnl_dst_reset); ...@@ -151,7 +151,7 @@ EXPORT_SYMBOL_GPL(ip6_tnl_dst_reset);
void ip6_tnl_dst_store(struct ip6_tnl *t, struct dst_entry *dst) void ip6_tnl_dst_store(struct ip6_tnl *t, struct dst_entry *dst)
{ {
struct rt6_info *rt = (struct rt6_info *) 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); dst_release(t->dst_cache);
t->dst_cache = dst; t->dst_cache = dst;
} }
......
...@@ -99,8 +99,7 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb) ...@@ -99,8 +99,7 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
dst_hold(dst); dst_hold(dst);
sk->sk_rx_dst = dst; sk->sk_rx_dst = dst;
inet_sk(sk)->rx_dst_ifindex = skb->skb_iif; inet_sk(sk)->rx_dst_ifindex = skb->skb_iif;
if (rt->rt6i_node) inet6_sk(sk)->rx_dst_cookie = rt6_get_cookie(rt);
inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
} }
} }
......
...@@ -76,8 +76,7 @@ static int xfrm6_init_path(struct xfrm_dst *path, struct dst_entry *dst, ...@@ -76,8 +76,7 @@ static int xfrm6_init_path(struct xfrm_dst *path, struct dst_entry *dst,
{ {
if (dst->ops->family == AF_INET6) { if (dst->ops->family == AF_INET6) {
struct rt6_info *rt = (struct rt6_info *)dst; struct rt6_info *rt = (struct rt6_info *)dst;
if (rt->rt6i_node) path->path_cookie = rt6_get_cookie(rt);
path->path_cookie = rt->rt6i_node->fn_sernum;
} }
path->u.rt6.rt6i_nfheader_len = nfheader_len; path->u.rt6.rt6i_nfheader_len = nfheader_len;
...@@ -105,8 +104,7 @@ static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev, ...@@ -105,8 +104,7 @@ static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
RTF_LOCAL); RTF_LOCAL);
xdst->u.rt6.rt6i_metric = rt->rt6i_metric; xdst->u.rt6.rt6i_metric = rt->rt6i_metric;
xdst->u.rt6.rt6i_node = rt->rt6i_node; xdst->u.rt6.rt6i_node = rt->rt6i_node;
if (rt->rt6i_node) xdst->route_cookie = rt6_get_cookie(rt);
xdst->route_cookie = rt->rt6i_node->fn_sernum;
xdst->u.rt6.rt6i_gateway = rt->rt6i_gateway; xdst->u.rt6.rt6i_gateway = rt->rt6i_gateway;
xdst->u.rt6.rt6i_dst = rt->rt6i_dst; xdst->u.rt6.rt6i_dst = rt->rt6i_dst;
xdst->u.rt6.rt6i_src = rt->rt6i_src; xdst->u.rt6.rt6i_src = rt->rt6i_src;
......
...@@ -435,7 +435,7 @@ __ip_vs_get_out_rt_v6(int skb_af, struct sk_buff *skb, struct ip_vs_dest *dest, ...@@ -435,7 +435,7 @@ __ip_vs_get_out_rt_v6(int skb_af, struct sk_buff *skb, struct ip_vs_dest *dest,
goto err_unreach; goto err_unreach;
} }
rt = (struct rt6_info *) dst; 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, dest_dst, &rt->dst, cookie); __ip_vs_dst_set(dest, dest_dst, &rt->dst, cookie);
spin_unlock_bh(&dest->dst_lock); spin_unlock_bh(&dest->dst_lock);
IP_VS_DBG(10, "new dst %pI6, src %pI6, refcnt=%d\n", IP_VS_DBG(10, "new dst %pI6, src %pI6, refcnt=%d\n",
......
...@@ -331,7 +331,7 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr, ...@@ -331,7 +331,7 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
rt = (struct rt6_info *)dst; rt = (struct rt6_info *)dst;
t->dst = dst; t->dst = dst;
t->dst_cookie = rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0; t->dst_cookie = rt6_get_cookie(rt);
pr_debug("rt6_dst:%pI6/%d rt6_src:%pI6\n", pr_debug("rt6_dst:%pI6/%d rt6_src:%pI6\n",
&rt->rt6i_dst.addr, rt->rt6i_dst.plen, &rt->rt6i_dst.addr, rt->rt6i_dst.plen,
&fl6->saddr); &fl6->saddr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment