diff options
author | Daniel Lezcano <dlezcano@fr.ibm.com> | 2008-03-04 02:28:58 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-03-04 02:28:58 -0500 |
commit | 5b7c931dff03621ae7ac524c4fa280d4e5f187a4 (patch) | |
tree | 9b3eda8e34816c0ac45cff8ce73d19f6bd11b4dd /net/ipv6/ip6_fib.c | |
parent | f3db48517f59133610f558f29de8834d7b007691 (diff) |
[NETNS][IPV6] ip6_fib - add net to gc timer parameter
The fib tables are now relative to the network namespace. When the
garbage collector timer expires, we must have a network namespace
parameter in order to retrieve the tables. For now this is the
init_net, but we should be able to have a timer per namespace and use
the timer callback parameter to pass the network namespace from the
expired timer.
The timer callback, fib6_run_gc, is actually used to be called
synchronously by some functions and asynchronously when the timer
expires.
When the timer expires, the delay specified for fib6_run_gc parameter
is always zero. So, I changed fib6_run_gc to not be a timer callback
but a function called by the timer callback and I added a timer
callback where its work is just to retrieve from the data arg of the
timer the network namespace and call fib6_run_gc with zero expiring
time and the network namespace parameters. That makes the code cleaner
for the fib6_run_gc callers.
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/ipv6/ip6_fib.c')
-rw-r--r-- | net/ipv6/ip6_fib.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 0f9dc81f0e61..9b1c232a29ee 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c | |||
@@ -93,7 +93,10 @@ static int fib6_walk_continue(struct fib6_walker_t *w); | |||
93 | 93 | ||
94 | static __u32 rt_sernum; | 94 | static __u32 rt_sernum; |
95 | 95 | ||
96 | static DEFINE_TIMER(ip6_fib_timer, fib6_run_gc, 0, 0); | 96 | static void fib6_gc_timer_cb(unsigned long arg); |
97 | |||
98 | static DEFINE_TIMER(ip6_fib_timer, fib6_gc_timer_cb, 0, | ||
99 | (unsigned long)&init_net); | ||
97 | 100 | ||
98 | static struct fib6_walker_t fib6_walker_list = { | 101 | static struct fib6_walker_t fib6_walker_list = { |
99 | .prev = &fib6_walker_list, | 102 | .prev = &fib6_walker_list, |
@@ -1432,12 +1435,12 @@ static int fib6_age(struct rt6_info *rt, void *arg) | |||
1432 | 1435 | ||
1433 | static DEFINE_SPINLOCK(fib6_gc_lock); | 1436 | static DEFINE_SPINLOCK(fib6_gc_lock); |
1434 | 1437 | ||
1435 | void fib6_run_gc(unsigned long dummy) | 1438 | void fib6_run_gc(unsigned long expires, struct net *net) |
1436 | { | 1439 | { |
1437 | if (dummy != ~0UL) { | 1440 | if (expires != ~0UL) { |
1438 | spin_lock_bh(&fib6_gc_lock); | 1441 | spin_lock_bh(&fib6_gc_lock); |
1439 | gc_args.timeout = dummy ? (int)dummy : | 1442 | gc_args.timeout = expires ? (int)expires : |
1440 | init_net.ipv6.sysctl.ip6_rt_gc_interval; | 1443 | net->ipv6.sysctl.ip6_rt_gc_interval; |
1441 | } else { | 1444 | } else { |
1442 | local_bh_disable(); | 1445 | local_bh_disable(); |
1443 | if (!spin_trylock(&fib6_gc_lock)) { | 1446 | if (!spin_trylock(&fib6_gc_lock)) { |
@@ -1445,17 +1448,17 @@ void fib6_run_gc(unsigned long dummy) | |||
1445 | local_bh_enable(); | 1448 | local_bh_enable(); |
1446 | return; | 1449 | return; |
1447 | } | 1450 | } |
1448 | gc_args.timeout = init_net.ipv6.sysctl.ip6_rt_gc_interval; | 1451 | gc_args.timeout = net->ipv6.sysctl.ip6_rt_gc_interval; |
1449 | } | 1452 | } |
1450 | gc_args.more = 0; | 1453 | gc_args.more = 0; |
1451 | 1454 | ||
1452 | icmp6_dst_gc(&gc_args.more); | 1455 | icmp6_dst_gc(&gc_args.more); |
1453 | 1456 | ||
1454 | fib6_clean_all(&init_net, fib6_age, 0, NULL); | 1457 | fib6_clean_all(net, fib6_age, 0, NULL); |
1455 | 1458 | ||
1456 | if (gc_args.more) | 1459 | if (gc_args.more) |
1457 | mod_timer(&ip6_fib_timer, jiffies + | 1460 | mod_timer(&ip6_fib_timer, jiffies + |
1458 | init_net.ipv6.sysctl.ip6_rt_gc_interval); | 1461 | net->ipv6.sysctl.ip6_rt_gc_interval); |
1459 | else { | 1462 | else { |
1460 | del_timer(&ip6_fib_timer); | 1463 | del_timer(&ip6_fib_timer); |
1461 | ip6_fib_timer.expires = 0; | 1464 | ip6_fib_timer.expires = 0; |
@@ -1463,6 +1466,11 @@ void fib6_run_gc(unsigned long dummy) | |||
1463 | spin_unlock_bh(&fib6_gc_lock); | 1466 | spin_unlock_bh(&fib6_gc_lock); |
1464 | } | 1467 | } |
1465 | 1468 | ||
1469 | static void fib6_gc_timer_cb(unsigned long arg) | ||
1470 | { | ||
1471 | fib6_run_gc(0, (struct net *)arg); | ||
1472 | } | ||
1473 | |||
1466 | static int fib6_net_init(struct net *net) | 1474 | static int fib6_net_init(struct net *net) |
1467 | { | 1475 | { |
1468 | int ret; | 1476 | int ret; |