aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDaniel Lezcano <dlezcano@fr.ibm.com>2008-03-04 02:29:33 -0500
committerDavid S. Miller <davem@davemloft.net>2008-03-04 02:29:33 -0500
commit450d19f8ab35fad4ef2b129cb383a5b8d1326611 (patch)
tree23810e8970b9ad009ef9b52cc2082808ecb57951 /net
parent5b7c931dff03621ae7ac524c4fa280d4e5f187a4 (diff)
[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.c33
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;
95 95
96static void fib6_gc_timer_cb(unsigned long arg); 96static void fib6_gc_timer_cb(unsigned long arg);
97 97
98static DEFINE_TIMER(ip6_fib_timer, fib6_gc_timer_cb, 0, 98static struct timer_list *ip6_fib_timer;
99 (unsigned long)&init_net);
100 99
101static struct fib6_walker_t fib6_walker_list = { 100static struct fib6_walker_t fib6_walker_list = {
102 .prev = &fib6_walker_list, 101 .prev = &fib6_walker_list,
@@ -666,16 +665,16 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
666 665
667static __inline__ void fib6_start_gc(struct rt6_info *rt) 666static __inline__ void fib6_start_gc(struct rt6_info *rt)
668{ 667{
669 if (ip6_fib_timer.expires == 0 && 668 if (ip6_fib_timer->expires == 0 &&
670 (rt->rt6i_flags & (RTF_EXPIRES|RTF_CACHE))) 669 (rt->rt6i_flags & (RTF_EXPIRES|RTF_CACHE)))
671 mod_timer(&ip6_fib_timer, jiffies + 670 mod_timer(ip6_fib_timer, jiffies +
672 init_net.ipv6.sysctl.ip6_rt_gc_interval); 671 init_net.ipv6.sysctl.ip6_rt_gc_interval);
673} 672}
674 673
675void fib6_force_start_gc(void) 674void fib6_force_start_gc(void)
676{ 675{
677 if (ip6_fib_timer.expires == 0) 676 if (ip6_fib_timer->expires == 0)
678 mod_timer(&ip6_fib_timer, jiffies + 677 mod_timer(ip6_fib_timer, jiffies +
679 init_net.ipv6.sysctl.ip6_rt_gc_interval); 678 init_net.ipv6.sysctl.ip6_rt_gc_interval);
680} 679}
681 680
@@ -1444,7 +1443,7 @@ void fib6_run_gc(unsigned long expires, struct net *net)
1444 } else { 1443 } else {
1445 local_bh_disable(); 1444 local_bh_disable();
1446 if (!spin_trylock(&fib6_gc_lock)) { 1445 if (!spin_trylock(&fib6_gc_lock)) {
1447 mod_timer(&ip6_fib_timer, jiffies + HZ); 1446 mod_timer(ip6_fib_timer, jiffies + HZ);
1448 local_bh_enable(); 1447 local_bh_enable();
1449 return; 1448 return;
1450 } 1449 }
@@ -1457,11 +1456,11 @@ void fib6_run_gc(unsigned long expires, struct net *net)
1457 fib6_clean_all(net, fib6_age, 0, NULL); 1456 fib6_clean_all(net, fib6_age, 0, NULL);
1458 1457
1459 if (gc_args.more) 1458 if (gc_args.more)
1460 mod_timer(&ip6_fib_timer, jiffies + 1459 mod_timer(ip6_fib_timer, jiffies +
1461 net->ipv6.sysctl.ip6_rt_gc_interval); 1460 net->ipv6.sysctl.ip6_rt_gc_interval);
1462 else { 1461 else {
1463 del_timer(&ip6_fib_timer); 1462 del_timer(ip6_fib_timer);
1464 ip6_fib_timer.expires = 0; 1463 ip6_fib_timer->expires = 0;
1465 } 1464 }
1466 spin_unlock_bh(&fib6_gc_lock); 1465 spin_unlock_bh(&fib6_gc_lock);
1467} 1466}
@@ -1541,9 +1540,16 @@ int __init fib6_init(void)
1541 if (!fib6_node_kmem) 1540 if (!fib6_node_kmem)
1542 goto out; 1541 goto out;
1543 1542
1543 ret = -ENOMEM;
1544 ip6_fib_timer = kzalloc(sizeof(*ip6_fib_timer), GFP_KERNEL);
1545 if (!ip6_fib_timer)
1546 goto out_kmem_cache_create;
1547
1548 setup_timer(ip6_fib_timer, fib6_gc_timer_cb, (unsigned long)&init_net);
1549
1544 ret = register_pernet_subsys(&fib6_net_ops); 1550 ret = register_pernet_subsys(&fib6_net_ops);
1545 if (ret) 1551 if (ret)
1546 goto out_kmem_cache_create; 1552 goto out_timer;
1547 1553
1548 ret = __rtnl_register(PF_INET6, RTM_GETROUTE, NULL, inet6_dump_fib); 1554 ret = __rtnl_register(PF_INET6, RTM_GETROUTE, NULL, inet6_dump_fib);
1549 if (ret) 1555 if (ret)
@@ -1553,6 +1559,8 @@ out:
1553 1559
1554out_unregister_subsys: 1560out_unregister_subsys:
1555 unregister_pernet_subsys(&fib6_net_ops); 1561 unregister_pernet_subsys(&fib6_net_ops);
1562out_timer:
1563 kfree(ip6_fib_timer);
1556out_kmem_cache_create: 1564out_kmem_cache_create:
1557 kmem_cache_destroy(fib6_node_kmem); 1565 kmem_cache_destroy(fib6_node_kmem);
1558 goto out; 1566 goto out;
@@ -1560,7 +1568,8 @@ out_kmem_cache_create:
1560 1568
1561void fib6_gc_cleanup(void) 1569void fib6_gc_cleanup(void)
1562{ 1570{
1563 del_timer(&ip6_fib_timer); 1571 del_timer(ip6_fib_timer);
1572 kfree(ip6_fib_timer);
1564 unregister_pernet_subsys(&fib6_net_ops); 1573 unregister_pernet_subsys(&fib6_net_ops);
1565 kmem_cache_destroy(fib6_node_kmem); 1574 kmem_cache_destroy(fib6_node_kmem);
1566} 1575}