Commit 812918c4 authored by Hannes Frederic Sowa's avatar Hannes Frederic Sowa Committed by David S. Miller

ipv6: make fib6 serial number per namespace

Try to reduce number of possible fn_sernum mutation by constraining them
to their namespace.

Also remove rt_genid which I forgot to remove in 705f1c86 ("ipv6:
remove rt6i_genid").

Cc: YOSHIFUJI Hideaki <hideaki@yoshifuji.org>
Cc: Martin Lau <kafai@fb.com>
Signed-off-by: default avatarHannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c8c4d42a
...@@ -76,7 +76,7 @@ struct netns_ipv6 { ...@@ -76,7 +76,7 @@ struct netns_ipv6 {
#endif #endif
#endif #endif
atomic_t dev_addr_genid; atomic_t dev_addr_genid;
atomic_t rt_genid; atomic_t fib6_sernum;
}; };
#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6) #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
......
...@@ -766,7 +766,7 @@ static int __net_init inet6_net_init(struct net *net) ...@@ -766,7 +766,7 @@ static int __net_init inet6_net_init(struct net *net)
net->ipv6.sysctl.icmpv6_time = 1*HZ; net->ipv6.sysctl.icmpv6_time = 1*HZ;
net->ipv6.sysctl.flowlabel_consistency = 1; net->ipv6.sysctl.flowlabel_consistency = 1;
net->ipv6.sysctl.auto_flowlabels = 0; net->ipv6.sysctl.auto_flowlabels = 0;
atomic_set(&net->ipv6.rt_genid, 0); atomic_set(&net->ipv6.fib6_sernum, 1);
err = ipv6_init_mibs(net); err = ipv6_init_mibs(net);
if (err) if (err)
......
...@@ -74,8 +74,6 @@ static int fib6_walk_continue(struct fib6_walker *w); ...@@ -74,8 +74,6 @@ static int fib6_walk_continue(struct fib6_walker *w);
* result of redirects, path MTU changes, etc. * result of redirects, path MTU changes, etc.
*/ */
static atomic_t rt_sernum = ATOMIC_INIT(1);
static void fib6_gc_timer_cb(unsigned long arg); static void fib6_gc_timer_cb(unsigned long arg);
static LIST_HEAD(fib6_walkers); static LIST_HEAD(fib6_walkers);
...@@ -95,14 +93,15 @@ static void fib6_walker_unlink(struct fib6_walker *w) ...@@ -95,14 +93,15 @@ static void fib6_walker_unlink(struct fib6_walker *w)
write_unlock_bh(&fib6_walker_lock); write_unlock_bh(&fib6_walker_lock);
} }
static int fib6_new_sernum(void) static int fib6_new_sernum(struct net *net)
{ {
int new, old; int new, old;
do { do {
old = atomic_read(&rt_sernum); old = atomic_read(&net->ipv6.fib6_sernum);
new = old < INT_MAX ? old + 1 : 1; new = old < INT_MAX ? old + 1 : 1;
} while (atomic_cmpxchg(&rt_sernum, old, new) != old); } while (atomic_cmpxchg(&net->ipv6.fib6_sernum,
old, new) != old);
return new; return new;
} }
...@@ -841,7 +840,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info, ...@@ -841,7 +840,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info,
int err = -ENOMEM; int err = -ENOMEM;
int allow_create = 1; int allow_create = 1;
int replace_required = 0; int replace_required = 0;
int sernum = fib6_new_sernum(); int sernum = fib6_new_sernum(info->nl_net);
if (info->nlh) { if (info->nlh) {
if (!(info->nlh->nlmsg_flags & NLM_F_CREATE)) if (!(info->nlh->nlmsg_flags & NLM_F_CREATE))
...@@ -1612,7 +1611,7 @@ static int fib6_update_sernum(struct rt6_info *rt, void *arg) ...@@ -1612,7 +1611,7 @@ static int fib6_update_sernum(struct rt6_info *rt, void *arg)
static void fib6_flush_trees(struct net *net) static void fib6_flush_trees(struct net *net)
{ {
int new_sernum = fib6_new_sernum(); int new_sernum = fib6_new_sernum(net);
fib6_clean_all(net, fib6_update_sernum, &new_sernum); fib6_clean_all(net, fib6_update_sernum, &new_sernum);
} }
......
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