mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-06 22:42:10 +00:00
[NETNS][IPV6] route6 - make garbage collection work with multiple network namespaces
This patch makes the necessary changes to make IPv6 dst_entry garbage collection work with multiple network namespaces. In ip6_dst_gc(), static local variables are now declared per-namespace. Signed-off-by: Benjamin Thery <benjamin.thery@bull.net> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
f2fc6a5458
commit
6891a346c3
2 changed files with 14 additions and 11 deletions
|
@ -42,6 +42,8 @@ struct netns_ipv6 {
|
||||||
struct hlist_head *fib_table_hash;
|
struct hlist_head *fib_table_hash;
|
||||||
struct fib6_table *fib6_main_tbl;
|
struct fib6_table *fib6_main_tbl;
|
||||||
struct dst_ops *ip6_dst_ops;
|
struct dst_ops *ip6_dst_ops;
|
||||||
|
unsigned int ip6_rt_gc_expire;
|
||||||
|
unsigned long ip6_rt_last_gc;
|
||||||
#ifdef CONFIG_IPV6_MULTIPLE_TABLES
|
#ifdef CONFIG_IPV6_MULTIPLE_TABLES
|
||||||
struct rt6_info *ip6_prohibit_entry;
|
struct rt6_info *ip6_prohibit_entry;
|
||||||
struct rt6_info *ip6_blk_hole_entry;
|
struct rt6_info *ip6_blk_hole_entry;
|
||||||
|
|
|
@ -992,23 +992,22 @@ int icmp6_dst_gc(int *more)
|
||||||
|
|
||||||
static int ip6_dst_gc(struct dst_ops *ops)
|
static int ip6_dst_gc(struct dst_ops *ops)
|
||||||
{
|
{
|
||||||
static unsigned expire = 30*HZ;
|
struct net *net = ops->dst_net;
|
||||||
static unsigned long last_gc;
|
|
||||||
unsigned long now = jiffies;
|
unsigned long now = jiffies;
|
||||||
|
|
||||||
if (time_after(last_gc + init_net.ipv6.sysctl.ip6_rt_gc_min_interval, now) &&
|
if (time_after(net->ipv6.ip6_rt_last_gc + net->ipv6.sysctl.ip6_rt_gc_min_interval, now) &&
|
||||||
atomic_read(&init_net.ipv6.ip6_dst_ops->entries) <= init_net.ipv6.sysctl.ip6_rt_max_size)
|
atomic_read(&net->ipv6.ip6_dst_ops->entries) <= net->ipv6.sysctl.ip6_rt_max_size)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
expire++;
|
net->ipv6.ip6_rt_gc_expire++;
|
||||||
fib6_run_gc(expire, &init_net);
|
fib6_run_gc(net->ipv6.ip6_rt_gc_expire, net);
|
||||||
last_gc = now;
|
net->ipv6.ip6_rt_last_gc = now;
|
||||||
if (atomic_read(&init_net.ipv6.ip6_dst_ops->entries) < init_net.ipv6.ip6_dst_ops->gc_thresh)
|
if (atomic_read(&net->ipv6.ip6_dst_ops->entries) < net->ipv6.ip6_dst_ops->gc_thresh)
|
||||||
expire = init_net.ipv6.sysctl.ip6_rt_gc_timeout>>1;
|
net->ipv6.ip6_rt_gc_expire = net->ipv6.sysctl.ip6_rt_gc_timeout>>1;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
expire -= expire>>init_net.ipv6.sysctl.ip6_rt_gc_elasticity;
|
net->ipv6.ip6_rt_gc_expire -= net->ipv6.ip6_rt_gc_expire>>net->ipv6.sysctl.ip6_rt_gc_elasticity;
|
||||||
return (atomic_read(&init_net.ipv6.ip6_dst_ops->entries) > init_net.ipv6.sysctl.ip6_rt_max_size);
|
return (atomic_read(&net->ipv6.ip6_dst_ops->entries) > net->ipv6.sysctl.ip6_rt_max_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clean host part of a prefix. Not necessary in radix tree,
|
/* Clean host part of a prefix. Not necessary in radix tree,
|
||||||
|
@ -2615,6 +2614,8 @@ static int ip6_route_net_init(struct net *net)
|
||||||
proc_net_fops_create(net, "ipv6_route", 0, &ipv6_route_proc_fops);
|
proc_net_fops_create(net, "ipv6_route", 0, &ipv6_route_proc_fops);
|
||||||
proc_net_fops_create(net, "rt6_stats", S_IRUGO, &rt6_stats_seq_fops);
|
proc_net_fops_create(net, "rt6_stats", S_IRUGO, &rt6_stats_seq_fops);
|
||||||
#endif
|
#endif
|
||||||
|
net->ipv6.ip6_rt_gc_expire = 30*HZ;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
out:
|
out:
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue