diff options
author | Michal Kubeček <mkubecek@suse.cz> | 2013-08-01 04:04:24 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-08-01 17:16:20 -0400 |
commit | 49a18d86f66d33a20144ecb5a34bba0d1856b260 (patch) | |
tree | 6c6cbdcb8d9417352a85a8c605cb06ac9b4bfc0d /net/ipv6 | |
parent | 2ac3ac8f86f2fe065d746d9a9abaca867adec577 (diff) |
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: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/ip6_fib.c | 6 | ||||
-rw-r--r-- | net/ipv6/route.c | 4 |
2 files changed, 6 insertions, 4 deletions
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index d872553ca933..bff3d821c7eb 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c | |||
@@ -1634,6 +1634,8 @@ static DEFINE_SPINLOCK(fib6_gc_lock); | |||
1634 | 1634 | ||
1635 | void fib6_run_gc(unsigned long expires, struct net *net, bool force) | 1635 | void fib6_run_gc(unsigned long expires, struct net *net, bool force) |
1636 | { | 1636 | { |
1637 | unsigned long now; | ||
1638 | |||
1637 | if (force) { | 1639 | if (force) { |
1638 | spin_lock_bh(&fib6_gc_lock); | 1640 | spin_lock_bh(&fib6_gc_lock); |
1639 | } else if (!spin_trylock_bh(&fib6_gc_lock)) { | 1641 | } 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 | gc_args.more = icmp6_dst_gc(); | 1648 | gc_args.more = icmp6_dst_gc(); |
1647 | 1649 | ||
1648 | fib6_clean_all(net, fib6_age, 0, NULL); | 1650 | fib6_clean_all(net, fib6_age, 0, NULL); |
1651 | now = jiffies; | ||
1652 | net->ipv6.ip6_rt_last_gc = now; | ||
1649 | 1653 | ||
1650 | if (gc_args.more) | 1654 | if (gc_args.more) |
1651 | mod_timer(&net->ipv6.ip6_fib_timer, | 1655 | mod_timer(&net->ipv6.ip6_fib_timer, |
1652 | round_jiffies(jiffies | 1656 | round_jiffies(now |
1653 | + net->ipv6.sysctl.ip6_rt_gc_interval)); | 1657 | + net->ipv6.sysctl.ip6_rt_gc_interval)); |
1654 | else | 1658 | else |
1655 | del_timer(&net->ipv6.ip6_fib_timer); | 1659 | del_timer(&net->ipv6.ip6_fib_timer); |
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 824c424f9648..b70f8979003b 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -1311,7 +1311,6 @@ static void icmp6_clean_all(int (*func)(struct rt6_info *rt, void *arg), | |||
1311 | 1311 | ||
1312 | static int ip6_dst_gc(struct dst_ops *ops) | 1312 | static int ip6_dst_gc(struct dst_ops *ops) |
1313 | { | 1313 | { |
1314 | unsigned long now = jiffies; | ||
1315 | struct net *net = container_of(ops, struct net, ipv6.ip6_dst_ops); | 1314 | struct net *net = container_of(ops, struct net, ipv6.ip6_dst_ops); |
1316 | int rt_min_interval = net->ipv6.sysctl.ip6_rt_gc_min_interval; | 1315 | int rt_min_interval = net->ipv6.sysctl.ip6_rt_gc_min_interval; |
1317 | int rt_max_size = net->ipv6.sysctl.ip6_rt_max_size; | 1316 | 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 | int entries; | 1320 | int entries; |
1322 | 1321 | ||
1323 | entries = dst_entries_get_fast(ops); | 1322 | entries = dst_entries_get_fast(ops); |
1324 | if (time_after(rt_last_gc + rt_min_interval, now) && | 1323 | if (time_after(rt_last_gc + rt_min_interval, jiffies) && |
1325 | entries <= rt_max_size) | 1324 | entries <= rt_max_size) |
1326 | goto out; | 1325 | goto out; |
1327 | 1326 | ||
1328 | net->ipv6.ip6_rt_gc_expire++; | 1327 | net->ipv6.ip6_rt_gc_expire++; |
1329 | fib6_run_gc(net->ipv6.ip6_rt_gc_expire, net, entries > rt_max_size); | 1328 | fib6_run_gc(net->ipv6.ip6_rt_gc_expire, net, entries > rt_max_size); |
1330 | net->ipv6.ip6_rt_last_gc = now; | ||
1331 | entries = dst_entries_get_slow(ops); | 1329 | entries = dst_entries_get_slow(ops); |
1332 | if (entries < ops->gc_thresh) | 1330 | if (entries < ops->gc_thresh) |
1333 | net->ipv6.ip6_rt_gc_expire = rt_gc_timeout>>1; | 1331 | net->ipv6.ip6_rt_gc_expire = rt_gc_timeout>>1; |