提交 49a18d86 编写于 作者: M Michal Kubeček 提交者: David S. Miller

ipv6: update ip6_rt_last_gc every time GC is run

As pointed out by Eric Dumazet, net->ipv6.ip6_rt_last_gc should
hold the last time garbage collector was run so that we should
update it whenever fib6_run_gc() calls fib6_clean_all(), not only
if we got there from ip6_dst_gc().
Signed-off-by: NMichal Kubecek <mkubecek@suse.cz>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 2ac3ac8f
...@@ -1634,6 +1634,8 @@ static DEFINE_SPINLOCK(fib6_gc_lock); ...@@ -1634,6 +1634,8 @@ 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)
{ {
unsigned long now;
if (force) { if (force) {
spin_lock_bh(&fib6_gc_lock); spin_lock_bh(&fib6_gc_lock);
} else if (!spin_trylock_bh(&fib6_gc_lock)) { } else if (!spin_trylock_bh(&fib6_gc_lock)) {
...@@ -1646,10 +1648,12 @@ void fib6_run_gc(unsigned long expires, struct net *net, bool force) ...@@ -1646,10 +1648,12 @@ 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, 0, NULL); fib6_clean_all(net, fib6_age, 0, NULL);
now = jiffies;
net->ipv6.ip6_rt_last_gc = now;
if (gc_args.more) if (gc_args.more)
mod_timer(&net->ipv6.ip6_fib_timer, mod_timer(&net->ipv6.ip6_fib_timer,
round_jiffies(jiffies round_jiffies(now
+ 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);
......
...@@ -1311,7 +1311,6 @@ static void icmp6_clean_all(int (*func)(struct rt6_info *rt, void *arg), ...@@ -1311,7 +1311,6 @@ static void icmp6_clean_all(int (*func)(struct rt6_info *rt, void *arg),
static int ip6_dst_gc(struct dst_ops *ops) static int ip6_dst_gc(struct dst_ops *ops)
{ {
unsigned long now = jiffies;
struct net *net = container_of(ops, struct net, ipv6.ip6_dst_ops); struct net *net = container_of(ops, struct net, ipv6.ip6_dst_ops);
int rt_min_interval = net->ipv6.sysctl.ip6_rt_gc_min_interval; int rt_min_interval = net->ipv6.sysctl.ip6_rt_gc_min_interval;
int rt_max_size = net->ipv6.sysctl.ip6_rt_max_size; int rt_max_size = net->ipv6.sysctl.ip6_rt_max_size;
...@@ -1321,13 +1320,12 @@ static int ip6_dst_gc(struct dst_ops *ops) ...@@ -1321,13 +1320,12 @@ static int ip6_dst_gc(struct dst_ops *ops)
int entries; int entries;
entries = dst_entries_get_fast(ops); entries = dst_entries_get_fast(ops);
if (time_after(rt_last_gc + rt_min_interval, now) && if (time_after(rt_last_gc + rt_min_interval, jiffies) &&
entries <= rt_max_size) entries <= rt_max_size)
goto out; goto out;
net->ipv6.ip6_rt_gc_expire++; net->ipv6.ip6_rt_gc_expire++;
fib6_run_gc(net->ipv6.ip6_rt_gc_expire, net, entries > rt_max_size); fib6_run_gc(net->ipv6.ip6_rt_gc_expire, net, entries > rt_max_size);
net->ipv6.ip6_rt_last_gc = now;
entries = dst_entries_get_slow(ops); entries = dst_entries_get_slow(ops);
if (entries < ops->gc_thresh) if (entries < ops->gc_thresh)
net->ipv6.ip6_rt_gc_expire = rt_gc_timeout>>1; net->ipv6.ip6_rt_gc_expire = rt_gc_timeout>>1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册