ipv6: Add rt6_get_cookie() function
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. Change-Id: I15221a1abc4ab608498275603f98bee922e3ce95 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>
This commit is contained in:
parent
7bcc3459b4
commit
6317ba9a29
|
@ -196,6 +196,11 @@ static inline void rt6_set_from(struct rt6_info *rt, struct rt6_info *from)
|
|||
rt->dst.from = new;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
/* dst_release() accepts a NULL parameter.
|
||||
|
|
|
@ -171,7 +171,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,
|
||||
|
|
|
@ -159,7 +159,7 @@ EXPORT_SYMBOL_GPL(ip6_tnl_dst_reset);
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -85,8 +85,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;
|
||||
|
@ -116,8 +115,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;
|
||||
|
|
|
@ -373,7 +373,7 @@ __ip_vs_get_out_rt_v6(struct sk_buff *skb, struct ip_vs_dest *dest,
|
|||
goto err_unreach;
|
||||
}
|
||||
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);
|
||||
spin_unlock_bh(&dest->dst_lock);
|
||||
IP_VS_DBG(10, "new dst %pI6, src %pI6, refcnt=%d\n",
|
||||
|
|
Loading…
Reference in New Issue