Skip to content

Commit 417f28b

Browse files
Stephen Hemmingerdavem330
authored andcommitted
netns: dont alloc ipv6 fib timer list
FIB timer list is a trivial size structure, avoid indirection and just put it in existing ns. Signed-off-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 888c848 commit 417f28b

File tree

2 files changed

+14
-28
lines changed

2 files changed

+14
-28
lines changed

include/net/netns/ipv6.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct netns_ipv6 {
3939
#endif
4040
struct rt6_info *ip6_null_entry;
4141
struct rt6_statistics *rt6_stats;
42-
struct timer_list *ip6_fib_timer;
42+
struct timer_list ip6_fib_timer;
4343
struct hlist_head *fib_table_hash;
4444
struct fib6_table *fib6_main_tbl;
4545
struct dst_ops *ip6_dst_ops;

net/ipv6/ip6_fib.c

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -661,16 +661,16 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
661661

662662
static __inline__ void fib6_start_gc(struct net *net, struct rt6_info *rt)
663663
{
664-
if (!timer_pending(net->ipv6.ip6_fib_timer) &&
664+
if (!timer_pending(&net->ipv6.ip6_fib_timer) &&
665665
(rt->rt6i_flags & (RTF_EXPIRES|RTF_CACHE)))
666-
mod_timer(net->ipv6.ip6_fib_timer,
666+
mod_timer(&net->ipv6.ip6_fib_timer,
667667
jiffies + net->ipv6.sysctl.ip6_rt_gc_interval);
668668
}
669669

670670
void fib6_force_start_gc(struct net *net)
671671
{
672-
if (!timer_pending(net->ipv6.ip6_fib_timer))
673-
mod_timer(net->ipv6.ip6_fib_timer,
672+
if (!timer_pending(&net->ipv6.ip6_fib_timer))
673+
mod_timer(&net->ipv6.ip6_fib_timer,
674674
jiffies + net->ipv6.sysctl.ip6_rt_gc_interval);
675675
}
676676

@@ -1449,7 +1449,7 @@ void fib6_run_gc(unsigned long expires, struct net *net)
14491449
} else {
14501450
local_bh_disable();
14511451
if (!spin_trylock(&fib6_gc_lock)) {
1452-
mod_timer(net->ipv6.ip6_fib_timer, jiffies + HZ);
1452+
mod_timer(&net->ipv6.ip6_fib_timer, jiffies + HZ);
14531453
local_bh_enable();
14541454
return;
14551455
}
@@ -1462,12 +1462,10 @@ void fib6_run_gc(unsigned long expires, struct net *net)
14621462
fib6_clean_all(net, fib6_age, 0, NULL);
14631463

14641464
if (gc_args.more)
1465-
mod_timer(net->ipv6.ip6_fib_timer, jiffies +
1465+
mod_timer(&net->ipv6.ip6_fib_timer, jiffies +
14661466
net->ipv6.sysctl.ip6_rt_gc_interval);
1467-
else {
1468-
del_timer(net->ipv6.ip6_fib_timer);
1469-
net->ipv6.ip6_fib_timer->expires = 0;
1470-
}
1467+
else
1468+
del_timer(&net->ipv6.ip6_fib_timer);
14711469
spin_unlock_bh(&fib6_gc_lock);
14721470
}
14731471

@@ -1478,16 +1476,7 @@ static void fib6_gc_timer_cb(unsigned long arg)
14781476

14791477
static int fib6_net_init(struct net *net)
14801478
{
1481-
int ret;
1482-
struct timer_list *timer;
1483-
1484-
ret = -ENOMEM;
1485-
timer = kzalloc(sizeof(*timer), GFP_KERNEL);
1486-
if (!timer)
1487-
goto out;
1488-
1489-
setup_timer(timer, fib6_gc_timer_cb, (unsigned long)net);
1490-
net->ipv6.ip6_fib_timer = timer;
1479+
setup_timer(&net->ipv6.ip6_fib_timer, fib6_gc_timer_cb, (unsigned long)net);
14911480

14921481
net->ipv6.rt6_stats = kzalloc(sizeof(*net->ipv6.rt6_stats), GFP_KERNEL);
14931482
if (!net->ipv6.rt6_stats)
@@ -1521,9 +1510,7 @@ static int fib6_net_init(struct net *net)
15211510
#endif
15221511
fib6_tables_init(net);
15231512

1524-
ret = 0;
1525-
out:
1526-
return ret;
1513+
return 0;
15271514

15281515
#ifdef CONFIG_IPV6_MULTIPLE_TABLES
15291516
out_fib6_main_tbl:
@@ -1534,15 +1521,14 @@ static int fib6_net_init(struct net *net)
15341521
out_rt6_stats:
15351522
kfree(net->ipv6.rt6_stats);
15361523
out_timer:
1537-
kfree(timer);
1538-
goto out;
1524+
return -ENOMEM;
15391525
}
15401526

15411527
static void fib6_net_exit(struct net *net)
15421528
{
15431529
rt6_ifdown(net, NULL);
1544-
del_timer_sync(net->ipv6.ip6_fib_timer);
1545-
kfree(net->ipv6.ip6_fib_timer);
1530+
del_timer_sync(&net->ipv6.ip6_fib_timer);
1531+
15461532
#ifdef CONFIG_IPV6_MULTIPLE_TABLES
15471533
kfree(net->ipv6.fib6_local_tbl);
15481534
#endif

0 commit comments

Comments
 (0)