Commit 705f1c86 authored by Hannes Frederic Sowa's avatar Hannes Frederic Sowa Committed by David S. Miller
Browse files

ipv6: remove rt6i_genid

Eric Dumazet noticed that all no-nonexthop or no-gateway routes which
are already marked DST_HOST (e.g. input routes routes) will always be
invalidated during sk_dst_check. Thus per-socket dst caching absolutely
had no effect and early demuxing had no effect.

Thus this patch removes rt6i_genid: fn_sernum already gets modified during
add operations, so we only must ensure we mutate fn_sernum during ipv6
address remove operations. This is a fairly cost extensive operations,
but address removal should not happen that often. Also our mtu update
functions do the same and we heard no complains so far. xfrm policy
changes also cause a call into fib6_flush_trees. Also plug a hole in
rt6_info (no cacheline changes).

I verified via tracing that this change has effect.

Cc: Eric Dumazet <>
Cc: YOSHIFUJI Hideaki <>
Cc: Vlad Yasevich <>
Cc: Nicolas Dichtel <>
Cc: Martin Lau <>
Signed-off-by: default avatarHannes Frederic Sowa <>
Signed-off-by: default avatarDavid S. Miller <>
parent dedb845d
......@@ -114,16 +114,13 @@ struct rt6_info {
u32 rt6i_flags;
struct rt6key rt6i_src;
struct rt6key rt6i_prefsrc;
u32 rt6i_metric;
struct inet6_dev *rt6i_idev;
unsigned long _rt6i_peer;
u32 rt6i_genid;
u32 rt6i_metric;
/* more non-fragment space at head required */
unsigned short rt6i_nfheader_len;
u8 rt6i_protocol;
......@@ -352,26 +352,12 @@ static inline void rt_genid_bump_ipv4(struct net *net)
static inline int rt_genid_ipv6(struct net *net)
return atomic_read(&net->ipv6.rt_genid);
static inline void rt_genid_bump_ipv6(struct net *net)
static inline int rt_genid_ipv6(struct net *net)
return 0;
extern void (*__fib6_flush_trees)(struct net *net);
static inline void rt_genid_bump_ipv6(struct net *net)
if (__fib6_flush_trees)
static inline struct netns_ieee802154_lowpan *
......@@ -4780,10 +4780,11 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
if (ip6_del_rt(ifp->rt))
static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
......@@ -8,6 +8,13 @@
#include <net/addrconf.h>
#include <net/ip.h>
/* if ipv6 module registers this function is used by xfrm to force all
* sockets to relookup their nodes - this is fairly expensive, be
* careful
void (*__fib6_flush_trees)(struct net *);
#define IPV6_ADDR_SCOPE_TYPE(scope) ((scope) << 16)
static inline unsigned int ipv6_addr_scope2type(unsigned int scope)
......@@ -1605,6 +1605,24 @@ static void fib6_prune_clones(struct net *net, struct fib6_node *fn)
fib6_clean_tree(net, fn, fib6_prune_clone, 1, NULL);
static int fib6_update_sernum(struct rt6_info *rt, void *arg)
__u32 sernum = *(__u32 *)arg;
if (rt->rt6i_node &&
rt->rt6i_node->fn_sernum != sernum)
rt->rt6i_node->fn_sernum = sernum;
return 0;
static void fib6_flush_trees(struct net *net)
__u32 new_sernum = fib6_new_sernum();
fib6_clean_all(net, fib6_update_sernum, &new_sernum);
* Garbage collection
......@@ -1788,6 +1806,8 @@ int __init fib6_init(void)
if (ret)
goto out_unregister_subsys;
__fib6_flush_trees = fib6_flush_trees;
return ret;
......@@ -314,7 +314,6 @@ static inline struct rt6_info *ip6_dst_alloc(struct net *net,
memset(dst + 1, 0, sizeof(*rt) - sizeof(*dst));
rt6_init_peer(rt, table ? &table->tb6_peers : net->ipv6.peers);
rt->rt6i_genid = rt_genid_ipv6(net);
return rt;
......@@ -1098,9 +1097,6 @@ static struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie)
* DST_OBSOLETE_FORCE_CHK which forces validation calls down
* into this function always.
if (rt->rt6i_genid != rt_genid_ipv6(dev_net(rt->
return NULL;
if (!rt->rt6i_node || (rt->rt6i_node->fn_sernum != cookie))
return NULL;
Supports Markdown
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