diff options
author | Daniel Lezcano <dlezcano@fr.ibm.com> | 2008-03-03 23:29:33 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-03-03 23:29:33 -0800 |
commit | 450d19f8ab35fad4ef2b129cb383a5b8d1326611 (patch) | |
tree | 23810e8970b9ad009ef9b52cc2082808ecb57951 /net | |
parent | 5b7c931dff03621ae7ac524c4fa280d4e5f187a4 (diff) | |
download | talos-obmc-linux-450d19f8ab35fad4ef2b129cb383a5b8d1326611.tar.gz talos-obmc-linux-450d19f8ab35fad4ef2b129cb383a5b8d1326611.zip |
[NETNS][IPV6] ip6_fib - dynamically allocate gc-timer
The ip6_fib_timer gc timer is dynamically allocated and initialized in
the ip6 fib init function. There are no more references to a static
global variable. That will allow to make multiple instance of the
garbage collecting timer and make them per namespace.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv6/ip6_fib.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 9b1c232a29ee..77ad1002c904 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c @@ -95,8 +95,7 @@ static __u32 rt_sernum; static void fib6_gc_timer_cb(unsigned long arg); -static DEFINE_TIMER(ip6_fib_timer, fib6_gc_timer_cb, 0, - (unsigned long)&init_net); +static struct timer_list *ip6_fib_timer; static struct fib6_walker_t fib6_walker_list = { .prev = &fib6_walker_list, @@ -666,16 +665,16 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt, static __inline__ void fib6_start_gc(struct rt6_info *rt) { - if (ip6_fib_timer.expires == 0 && + if (ip6_fib_timer->expires == 0 && (rt->rt6i_flags & (RTF_EXPIRES|RTF_CACHE))) - mod_timer(&ip6_fib_timer, jiffies + + mod_timer(ip6_fib_timer, jiffies + init_net.ipv6.sysctl.ip6_rt_gc_interval); } void fib6_force_start_gc(void) { - if (ip6_fib_timer.expires == 0) - mod_timer(&ip6_fib_timer, jiffies + + if (ip6_fib_timer->expires == 0) + mod_timer(ip6_fib_timer, jiffies + init_net.ipv6.sysctl.ip6_rt_gc_interval); } @@ -1444,7 +1443,7 @@ void fib6_run_gc(unsigned long expires, struct net *net) } else { local_bh_disable(); if (!spin_trylock(&fib6_gc_lock)) { - mod_timer(&ip6_fib_timer, jiffies + HZ); + mod_timer(ip6_fib_timer, jiffies + HZ); local_bh_enable(); return; } @@ -1457,11 +1456,11 @@ void fib6_run_gc(unsigned long expires, struct net *net) fib6_clean_all(net, fib6_age, 0, NULL); if (gc_args.more) - mod_timer(&ip6_fib_timer, jiffies + + mod_timer(ip6_fib_timer, jiffies + net->ipv6.sysctl.ip6_rt_gc_interval); else { - del_timer(&ip6_fib_timer); - ip6_fib_timer.expires = 0; + del_timer(ip6_fib_timer); + ip6_fib_timer->expires = 0; } spin_unlock_bh(&fib6_gc_lock); } @@ -1541,9 +1540,16 @@ int __init fib6_init(void) if (!fib6_node_kmem) goto out; + ret = -ENOMEM; + ip6_fib_timer = kzalloc(sizeof(*ip6_fib_timer), GFP_KERNEL); + if (!ip6_fib_timer) + goto out_kmem_cache_create; + + setup_timer(ip6_fib_timer, fib6_gc_timer_cb, (unsigned long)&init_net); + ret = register_pernet_subsys(&fib6_net_ops); if (ret) - goto out_kmem_cache_create; + goto out_timer; ret = __rtnl_register(PF_INET6, RTM_GETROUTE, NULL, inet6_dump_fib); if (ret) @@ -1553,6 +1559,8 @@ out: out_unregister_subsys: unregister_pernet_subsys(&fib6_net_ops); +out_timer: + kfree(ip6_fib_timer); out_kmem_cache_create: kmem_cache_destroy(fib6_node_kmem); goto out; @@ -1560,7 +1568,8 @@ out_kmem_cache_create: void fib6_gc_cleanup(void) { - del_timer(&ip6_fib_timer); + del_timer(ip6_fib_timer); + kfree(ip6_fib_timer); unregister_pernet_subsys(&fib6_net_ops); kmem_cache_destroy(fib6_node_kmem); } |