aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorHannes Frederic Sowa <hannes@stressinduktion.org>2014-10-06 13:58:37 -0400
committerDavid S. Miller <davem@davemloft.net>2014-10-07 00:02:30 -0400
commit812918c464eca0e8c145f975932ca5020e9c05cb (patch)
treef93555164f70bf5f7f14eed06b2571bfb1fc2c2d /net/ipv6
parentc8c4d42a6b46ea9f81816c47ac8d6ae25cf533fc (diff)
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 705f1c869d577c ("ipv6: remove rt6i_genid"). Cc: YOSHIFUJI Hideaki <hideaki@yoshifuji.org> Cc: Martin Lau <kafai@fb.com> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/af_inet6.c2
-rw-r--r--net/ipv6/ip6_fib.c13
2 files changed, 7 insertions, 8 deletions
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 34f726f59814..e8c4400f23e9 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -766,7 +766,7 @@ static int __net_init inet6_net_init(struct net *net)
766 net->ipv6.sysctl.icmpv6_time = 1*HZ; 766 net->ipv6.sysctl.icmpv6_time = 1*HZ;
767 net->ipv6.sysctl.flowlabel_consistency = 1; 767 net->ipv6.sysctl.flowlabel_consistency = 1;
768 net->ipv6.sysctl.auto_flowlabels = 0; 768 net->ipv6.sysctl.auto_flowlabels = 0;
769 atomic_set(&net->ipv6.rt_genid, 0); 769 atomic_set(&net->ipv6.fib6_sernum, 1);
770 770
771 err = ipv6_init_mibs(net); 771 err = ipv6_init_mibs(net);
772 if (err) 772 if (err)
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index be9cb09b05f7..6f9beb1f2861 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -74,8 +74,6 @@ static int fib6_walk_continue(struct fib6_walker *w);
74 * result of redirects, path MTU changes, etc. 74 * result of redirects, path MTU changes, etc.
75 */ 75 */
76 76
77static atomic_t rt_sernum = ATOMIC_INIT(1);
78
79static void fib6_gc_timer_cb(unsigned long arg); 77static void fib6_gc_timer_cb(unsigned long arg);
80 78
81static LIST_HEAD(fib6_walkers); 79static LIST_HEAD(fib6_walkers);
@@ -95,14 +93,15 @@ static void fib6_walker_unlink(struct fib6_walker *w)
95 write_unlock_bh(&fib6_walker_lock); 93 write_unlock_bh(&fib6_walker_lock);
96} 94}
97 95
98static int fib6_new_sernum(void) 96static int fib6_new_sernum(struct net *net)
99{ 97{
100 int new, old; 98 int new, old;
101 99
102 do { 100 do {
103 old = atomic_read(&rt_sernum); 101 old = atomic_read(&net->ipv6.fib6_sernum);
104 new = old < INT_MAX ? old + 1 : 1; 102 new = old < INT_MAX ? old + 1 : 1;
105 } while (atomic_cmpxchg(&rt_sernum, old, new) != old); 103 } while (atomic_cmpxchg(&net->ipv6.fib6_sernum,
104 old, new) != old);
106 return new; 105 return new;
107} 106}
108 107
@@ -841,7 +840,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info,
841 int err = -ENOMEM; 840 int err = -ENOMEM;
842 int allow_create = 1; 841 int allow_create = 1;
843 int replace_required = 0; 842 int replace_required = 0;
844 int sernum = fib6_new_sernum(); 843 int sernum = fib6_new_sernum(info->nl_net);
845 844
846 if (info->nlh) { 845 if (info->nlh) {
847 if (!(info->nlh->nlmsg_flags & NLM_F_CREATE)) 846 if (!(info->nlh->nlmsg_flags & NLM_F_CREATE))
@@ -1612,7 +1611,7 @@ static int fib6_update_sernum(struct rt6_info *rt, void *arg)
1612 1611
1613static void fib6_flush_trees(struct net *net) 1612static void fib6_flush_trees(struct net *net)
1614{ 1613{
1615 int new_sernum = fib6_new_sernum(); 1614 int new_sernum = fib6_new_sernum(net);
1616 1615
1617 fib6_clean_all(net, fib6_update_sernum, &new_sernum); 1616 fib6_clean_all(net, fib6_update_sernum, &new_sernum);
1618} 1617}