netns: dont alloc ipv6 fib timer list
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/5 netns: dont alloc ipv6 fib timer list
FIB timer list is a trivial size structure, avoid indirection and just put it in existing ns.
---
patch against current net-2.6 tree
net/ipv6/ip6_fib.c +13 -27
@@ -661,16 +661,16 @@ static int fib6_add_rt2node(struct fib6_static __inline__void fib6_start_gc (struct net *net,struct rt6_info *rt) { -if (!timer_pending (net->ipv6.ip6_fib_timer) && +if (!timer_pending (&net->ipv6.ip6_fib_timer) && (rt->rt6i_flags & (RTF_EXPIRES |RTF_CACHE ))) -mod_timer (net->ipv6.ip6_fib_timer, +mod_timer (&net->ipv6.ip6_fib_timer, jiffies + net->ipv6.sysctl.ip6_rt_gc_interval); }void fib6_force_start_gc (struct net *net) { -if (!timer_pending (net->ipv6.ip6_fib_timer)) -mod_timer (net->ipv6.ip6_fib_timer, +if (!timer_pending (&net->ipv6.ip6_fib_timer)) +mod_timer (&net->ipv6.ip6_fib_timer, jiffies + net->ipv6.sysctl.ip6_rt_gc_interval); }
@@ -1449,7 +1449,7 @@ void fib6_run_gc(unsigned long expires, }else {local_bh_disable ();if (!spin_trylock (&fib6_gc_lock)) { -mod_timer (net->ipv6.ip6_fib_timer, jiffies +HZ ); +mod_timer (&net->ipv6.ip6_fib_timer, jiffies +HZ );local_bh_enable ();return ; }
@@ -1462,12 +1462,10 @@ void fib6_run_gc(unsigned long expires,fib6_clean_all (net, fib6_age,0 ,NULL );if (gc_args.more) -mod_timer (net->ipv6.ip6_fib_timer, jiffies + +mod_timer (&net->ipv6.ip6_fib_timer, jiffies + net->ipv6.sysctl.ip6_rt_gc_interval); -else { -del_timer (net->ipv6.ip6_fib_timer); - net->ipv6.ip6_fib_timer->expires =0 ; - } +else +del_timer (&net->ipv6.ip6_fib_timer);spin_unlock_bh (&fib6_gc_lock); }
@@ -1478,16 +1476,7 @@ static void fib6_gc_timer_cb(unsigned lostatic int fib6_net_init (struct net *net) { -int ret; -struct timer_list *timer; - - ret = -ENOMEM ; - timer =kzalloc (sizeof (*timer),GFP_KERNEL ); -if (!timer) - goto out; - -setup_timer (timer, fib6_gc_timer_cb, (unsigned long )net); - net->ipv6.ip6_fib_timer = timer; +setup_timer (&net->ipv6.ip6_fib_timer, fib6_gc_timer_cb, (unsigned long )net); net->ipv6.rt6_stats =kzalloc (sizeof (*net->ipv6.rt6_stats),GFP_KERNEL );if (!net->ipv6.rt6_stats)
@@ -1521,9 +1510,7 @@ static int fib6_net_init(struct net *net#endif fib6_tables_init (net); - ret =0 ; -out: -return ret; +return 0 ;#ifdef CONFIG_IPV6_MULTIPLE_TABLES out_fib6_main_tbl:
@@ -1534,15 +1521,14 @@ out_fib_table_hash: out_rt6_stats:kfree (net->ipv6.rt6_stats); out_timer: -kfree (timer); - goto out; +return -ENOMEM ; }static void fib6_net_exit (struct net *net) {rt6_ifdown (net,NULL ); -del_timer_sync (net->ipv6.ip6_fib_timer); -kfree (net->ipv6.ip6_fib_timer); +del_timer_sync (&net->ipv6.ip6_fib_timer); +#ifdef CONFIG_IPV6_MULTIPLE_TABLES kfree (net->ipv6.fib6_local_tbl);#endif
include/net/netns/ipv6.h +1 -1
@@ -39,7 +39,7 @@ struct netns_ipv6 {#endif struct rt6_info *ip6_null_entry;struct rt6_statistics *rt6_stats; -struct timer_list *ip6_fib_timer; +struct timer_list ip6_fib_timer;struct hlist_head *fib_table_hash;struct fib6_table *fib6_main_tbl;struct dst_ops *ip6_dst_ops;
From: Stephen Hemminger <[email protected]>
Date: Tue, 22 Jul 2008 14:29:28 -0700
Quoted 4 lines
FIB timer list is a trivial size structure, avoid indirection and just put it in existing ns.
Signed-off-by Stephen Hemminger <[email protected]>
Applied.
PATCH 2/5 ipv6: use round_jiffies
In reply to a message not in the archiveThis timer normally happens once a minute, there is no need to cause an early wakeup for it, so align it to next second boundary to safe power. It can't be deferred because then it could take too long on cleanup or DoS.
net/ipv6/ip6_fib.c +3 -2
@@ -1462,8 +1462,9 @@ void fib6_run_gc(unsigned long expires,fib6_clean_all (net, fib6_age,0 ,NULL );if (gc_args.more) -mod_timer (&net->ipv6.ip6_fib_timer, jiffies + - net->ipv6.sysctl.ip6_rt_gc_interval); +mod_timer (&net->ipv6.ip6_fib_timer, +round_jiffies (jiffies + + net->ipv6.sysctl.ip6_rt_gc_interval));else del_timer (&net->ipv6.ip6_fib_timer);spin_unlock_bh (&fib6_gc_lock);
Re: [PATCH 2/5] ipv6: use round_jiffies
From: Stephen Hemminger <[email protected]>
Date: Tue, 22 Jul 2008 14:29:29 -0700
Quoted 5 lines
This timer normally happens once a minute, there is no need to cause an early wakeup for it, so align it to next second boundary to safe power. It can't be deferred because then it could take too long on cleanup or DoS.
Signed-off-by Stephen Hemminger <[email protected]>
Applied.
PATCH 3/5 ipv6: use spin_trylock_bh
In reply to a message not in the archiveNow there is spin_trylock_bh, use it rather than open coding.
net/ipv6/ip6_fib.c +1 -3
@@ -1447,10 +1447,8 @@ void fib6_run_gc(unsigned long expires, gc_args.timeout = expires ? (int )expires : net->ipv6.sysctl.ip6_rt_gc_interval; }else { -local_bh_disable (); -if (!spin_trylock (&fib6_gc_lock)) { +if (!spin_trylock_bh (&fib6_gc_lock)) {mod_timer (&net->ipv6.ip6_fib_timer, jiffies +HZ ); -local_bh_enable ();return ; } gc_args.timeout = net->ipv6.sysctl.ip6_rt_gc_interval;
Re: [PATCH 3/5] ipv6: use spin_trylock_bh
From: Stephen Hemminger <[email protected]>
Date: Tue, 22 Jul 2008 14:29:30 -0700
Quoted 3 lines
Now there is
spin_trylock_bh, use it rather than open coding.Signed-off-by Stephen Hemminger <[email protected]>
Applied.
PATCH 1/1 IPv6:Fix the return value of Set Hop-by-Hop options header with NULL data pointer
In reply to Stephen HemmingerWhen Set Hop-by-Hop options header with NULL data pointer and optlen is not zero use setsockopt(), the kernel successfully return 0 instead of return error EINVAL or EFAULT.
This patch fix the problem.
--- ipv6_sockglue.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
net/ipv6/ipv6_sockglue.c +2 -0
@@ -346,6 +346,8 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,*/ if (optlen ==0 ) optval =NULL ; +else if (optval ==NULL ) + goto e_inval;else if (optlen <sizeof (struct ipv6_opt_hdr ) || optlen &0x7 || optlen >8 *255 ) goto e_inval;
Signature · 1 line
1.5.3.8
PATCH 4/5 ipv6: use kcalloc
In reply to a message not in the archiveTh fib_table_hash is an array, so use kcalloc.
net/ipv6/ip6_fib.c +3 -3
@@ -1481,9 +1481,9 @@ static int fib6_net_init(struct net *netif (!net->ipv6.rt6_stats) goto out_timer; - net->ipv6.fib_table_hash = -kzalloc (sizeof (*net->ipv6.fib_table_hash)*FIB_TABLE_HASHSZ , -GFP_KERNEL ); + net->ipv6.fib_table_hash =kcalloc (FIB_TABLE_HASHSZ , +sizeof (*net->ipv6.fib_table_hash), +GFP_KERNEL );if (!net->ipv6.fib_table_hash) goto out_rt6_stats;
Re: [PATCH 4/5] ipv6: use kcalloc
From: Stephen Hemminger <[email protected]>
Date: Tue, 22 Jul 2008 14:29:31 -0700
Quoted 3 lines
Th
fib_table_hashis an array, so use kcalloc.Signed-off-by Stephen Hemminger <[email protected]>
Applied.
PATCH 5/5 ipv6: icmp6_dst_gc return change
In reply to a message not in the archiveChange icmp6_dst_gc to return the one value the caller cares about rather than using call by reference.
include/net/ip6_route.h +1 -1
@@ -68,7 +68,7 @@ extern struct rt6_info *rt6_lookup(struextern struct dst_entry *icmp6_dst_alloc (struct net_device *dev,struct neighbour *neigh,const struct in6_addr *addr); -extern int icmp6_dst_gc (int *more); +extern int icmp6_dst_gc (void );extern void fib6_force_start_gc (struct net *net);
net/ipv6/ip6_fib.c +1 -2
@@ -1453,9 +1453,8 @@ void fib6_run_gc(unsigned long expires, } gc_args.timeout = net->ipv6.sysctl.ip6_rt_gc_interval; } - gc_args.more =0 ; -icmp6_dst_gc (&gc_args.more); + gc_args.more =icmp6_dst_gc ();fib6_clean_all (net, fib6_age,0 ,NULL );
net/ipv6/route.c +4 -6
@@ -978,13 +978,12 @@ out:return &rt->u.dst; } -int icmp6_dst_gc (int *more) +int icmp6_dst_gc (void ) {struct dst_entry *dst, *next, **pprev; -int freed; +int more =0 ; next =NULL ; - freed =0 ;spin_lock_bh (&icmp6_dst_lock); pprev = &icmp6_dst_gc_list;
@@ -993,16 +992,15 @@ int icmp6_dst_gc(int *more)if (!atomic_read (&dst->__refcnt)) { *pprev = dst->next;dst_free (dst); - freed++; }else { pprev = &dst->next; - (*more)++; + ++more; } }spin_unlock_bh (&icmp6_dst_lock); -return freed; +return more; }static int ip6_dst_gc (struct dst_ops *ops)
David Miller
maintainerRe: [PATCH 5/5] ipv6: icmp6_dst_gc return change
From: Stephen Hemminger <[email protected]>
Date: Tue, 22 Jul 2008 14:29:32 -0700
Quoted 4 lines
Change
icmp6_dst_gcto return the one value the caller cares about rather than using call by reference.Signed-off-by Stephen Hemminger <[email protected]>
Also applied, thanks.