Commit 3dc94f93 authored by Michal Kubeček's avatar Michal Kubeček Committed by David S. Miller

ipv6: per netns FIB garbage collection

One of our customers observed issues with FIB6 garbage collectors
running in different network namespaces blocking each other, resulting
in soft lockups (fib6_run_gc() initiated from timer runs always in
forced mode).

Now that FIB6 walkers are separated per namespace, there is no more need
for instances of fib6_run_gc() in different namespaces blocking each
other. There is still a call to icmp6_dst_gc() which operates on shared
data but this function is protected by its own shared lock.
Signed-off-by: default avatarMichal Kubecek <mkubecek@suse.cz>
Reviewed-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9a03cd8f
...@@ -61,6 +61,7 @@ struct netns_ipv6 { ...@@ -61,6 +61,7 @@ struct netns_ipv6 {
struct list_head fib6_walkers; struct list_head fib6_walkers;
struct dst_ops ip6_dst_ops; struct dst_ops ip6_dst_ops;
rwlock_t fib6_walker_lock; rwlock_t fib6_walker_lock;
spinlock_t fib6_gc_lock;
unsigned int ip6_rt_gc_expire; unsigned int ip6_rt_gc_expire;
unsigned long ip6_rt_last_gc; unsigned long ip6_rt_last_gc;
#ifdef CONFIG_IPV6_MULTIPLE_TABLES #ifdef CONFIG_IPV6_MULTIPLE_TABLES
......
...@@ -1776,16 +1776,14 @@ static int fib6_age(struct rt6_info *rt, void *arg) ...@@ -1776,16 +1776,14 @@ static int fib6_age(struct rt6_info *rt, void *arg)
return 0; return 0;
} }
static DEFINE_SPINLOCK(fib6_gc_lock);
void fib6_run_gc(unsigned long expires, struct net *net, bool force) void fib6_run_gc(unsigned long expires, struct net *net, bool force)
{ {
struct fib6_gc_args gc_args; struct fib6_gc_args gc_args;
unsigned long now; unsigned long now;
if (force) { if (force) {
spin_lock_bh(&fib6_gc_lock); spin_lock_bh(&net->ipv6.fib6_gc_lock);
} else if (!spin_trylock_bh(&fib6_gc_lock)) { } else if (!spin_trylock_bh(&net->ipv6.fib6_gc_lock)) {
mod_timer(&net->ipv6.ip6_fib_timer, jiffies + HZ); mod_timer(&net->ipv6.ip6_fib_timer, jiffies + HZ);
return; return;
} }
...@@ -1804,7 +1802,7 @@ void fib6_run_gc(unsigned long expires, struct net *net, bool force) ...@@ -1804,7 +1802,7 @@ void fib6_run_gc(unsigned long expires, struct net *net, bool force)
+ net->ipv6.sysctl.ip6_rt_gc_interval)); + net->ipv6.sysctl.ip6_rt_gc_interval));
else else
del_timer(&net->ipv6.ip6_fib_timer); del_timer(&net->ipv6.ip6_fib_timer);
spin_unlock_bh(&fib6_gc_lock); spin_unlock_bh(&net->ipv6.fib6_gc_lock);
} }
static void fib6_gc_timer_cb(unsigned long arg) static void fib6_gc_timer_cb(unsigned long arg)
...@@ -1816,6 +1814,7 @@ static int __net_init fib6_net_init(struct net *net) ...@@ -1816,6 +1814,7 @@ static int __net_init fib6_net_init(struct net *net)
{ {
size_t size = sizeof(struct hlist_head) * FIB6_TABLE_HASHSZ; size_t size = sizeof(struct hlist_head) * FIB6_TABLE_HASHSZ;
spin_lock_init(&net->ipv6.fib6_gc_lock);
rwlock_init(&net->ipv6.fib6_walker_lock); rwlock_init(&net->ipv6.fib6_walker_lock);
INIT_LIST_HEAD(&net->ipv6.fib6_walkers); INIT_LIST_HEAD(&net->ipv6.fib6_walkers);
setup_timer(&net->ipv6.ip6_fib_timer, fib6_gc_timer_cb, (unsigned long)net); setup_timer(&net->ipv6.ip6_fib_timer, fib6_gc_timer_cb, (unsigned long)net);
......
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