Commit 3570df91 authored by Michal Kubeček's avatar Michal Kubeček Committed by David S. Miller

ipv6: replace global gc_args with local variable

Global variable gc_args is only used in fib6_run_gc() and functions
called from it. As fib6_run_gc() makes sure there is at most one
instance of fib6_clean_all() running at any moment, we can replace
gc_args with a local variable which will be needed once multiple
instances (per netns) of garbage collector are allowed.
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 02daec7c
...@@ -1725,14 +1725,15 @@ static void fib6_flush_trees(struct net *net) ...@@ -1725,14 +1725,15 @@ static void fib6_flush_trees(struct net *net)
* Garbage collection * Garbage collection
*/ */
static struct fib6_gc_args struct fib6_gc_args
{ {
int timeout; int timeout;
int more; int more;
} gc_args; };
static int fib6_age(struct rt6_info *rt, void *arg) static int fib6_age(struct rt6_info *rt, void *arg)
{ {
struct fib6_gc_args *gc_args = arg;
unsigned long now = jiffies; unsigned long now = jiffies;
/* /*
...@@ -1748,10 +1749,10 @@ static int fib6_age(struct rt6_info *rt, void *arg) ...@@ -1748,10 +1749,10 @@ static int fib6_age(struct rt6_info *rt, void *arg)
RT6_TRACE("expiring %p\n", rt); RT6_TRACE("expiring %p\n", rt);
return -1; return -1;
} }
gc_args.more++; gc_args->more++;
} else if (rt->rt6i_flags & RTF_CACHE) { } else if (rt->rt6i_flags & RTF_CACHE) {
if (atomic_read(&rt->dst.__refcnt) == 0 && if (atomic_read(&rt->dst.__refcnt) == 0 &&
time_after_eq(now, rt->dst.lastuse + gc_args.timeout)) { time_after_eq(now, rt->dst.lastuse + gc_args->timeout)) {
RT6_TRACE("aging clone %p\n", rt); RT6_TRACE("aging clone %p\n", rt);
return -1; return -1;
} else if (rt->rt6i_flags & RTF_GATEWAY) { } else if (rt->rt6i_flags & RTF_GATEWAY) {
...@@ -1769,7 +1770,7 @@ static int fib6_age(struct rt6_info *rt, void *arg) ...@@ -1769,7 +1770,7 @@ static int fib6_age(struct rt6_info *rt, void *arg)
return -1; return -1;
} }
} }
gc_args.more++; gc_args->more++;
} }
return 0; return 0;
...@@ -1779,6 +1780,7 @@ static DEFINE_SPINLOCK(fib6_gc_lock); ...@@ -1779,6 +1780,7 @@ 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;
unsigned long now; unsigned long now;
if (force) { if (force) {
...@@ -1792,7 +1794,7 @@ void fib6_run_gc(unsigned long expires, struct net *net, bool force) ...@@ -1792,7 +1794,7 @@ void fib6_run_gc(unsigned long expires, struct net *net, bool force)
gc_args.more = icmp6_dst_gc(); gc_args.more = icmp6_dst_gc();
fib6_clean_all(net, fib6_age, NULL); fib6_clean_all(net, fib6_age, &gc_args);
now = jiffies; now = jiffies;
net->ipv6.ip6_rt_last_gc = now; net->ipv6.ip6_rt_last_gc = now;
......
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