From: Denis V. Lunev <hidden> Date: 2008-04-15 12:37:33
Network namespace has two referrence counters:
- count
- use_count.
The namespace is scheduled to destruction automatically when the count
becomes 0.
There are several SLAB objects with a pointer to a namespace on them.
These objects are cleaned up during namespace stop. Some of them
increment use_count, some don't. This set fixes this discrepancy,
i.e. now all such objects increment the use_count.
Though, the use_count itself is used in a very debug manner and checked
only during namespace stop. So, I have placed it under
NETNS_REFCNT_DEBUG definition exactly like this is done for socket
refcounting code to remove extra atomic from any possible fast paths.
Signed-off-by: Denis V. Lunev <redacted>
From: Denis V. Lunev <hidden> Date: 2008-04-15 12:38:18
Make release_net/hold_net noop for performance-hungry people. This is a debug
staff and should be used in the debug mode only.
Add check for net != NULL in hold/release calls. This will be required
later on.
Signed-off-by: Denis V. Lunev <redacted>
---
include/net/net_namespace.h | 44 +++++++++++++++++++++++++++---------------
net/core/net_namespace.c | 4 +++
2 files changed, 30 insertions(+), 16 deletions(-)
@@ -21,9 +21,11 @@ struct net_device;atomic_tcount;/* To decided when the network*namespaceshouldbefreed.*/+#ifdef NETNS_REFCNT_DEBUGatomic_tuse_count;/* To track references we*destroyondemand*/+#endifstructlist_headlist;/* list of network namespaces */structwork_structwork;/* work struct for freeing */
@@ -115,17 +119,6 @@ static inline void put_net(struct net *net)__put_net(net);}-staticinlinestructnet*hold_net(structnet*net)-{-atomic_inc(&net->use_count);-returnnet;-}--staticinlinevoidrelease_net(structnet*net)-{-atomic_dec(&net->use_count);-}-staticinlineintnet_eq(conststructnet*net1,conststructnet*net2){
@@ -2622,7 +2622,7 @@ static int ip6_route_net_init(struct net *net)GFP_KERNEL);if(!net->ipv6.ip6_dst_ops)gotoout;-net->ipv6.ip6_dst_ops->dst_net=net;+net->ipv6.ip6_dst_ops->dst_net=hold_net(net);net->ipv6.ip6_null_entry=kmemdup(&ip6_null_entry_template,sizeof(*net->ipv6.ip6_null_entry),
From: Denis V. Lunev <hidden> Date: 2008-04-15 12:38:21
Protocol control sockets and netlink kernel sockets should not prevent the
namespace stop request. They are initialized and disposed in a special way by
sk_change_net/sk_release_kernel.
Signed-off-by: Denis V. Lunev <redacted>
---
include/net/sock.h | 2 +-
net/core/sock.c | 1 +
2 files changed, 2 insertions(+), 1 deletions(-)
@@ -29,7 +29,7 @@ int fib_default_rule_add(struct fib_rules_ops *ops,r->pref=pref;r->table=table;r->flags=flags;-r->fr_net=ops->fro_net;+r->fr_net=hold_net(ops->fro_net);/* The lock is not required here, the list in unreacheable*atthemomentthisfunctioniscalled*/
From: Denis V. Lunev <hidden> Date: 2008-04-15 12:39:16
dev_set_net is called for
- just allocated devices
- devices moving from one namespace to another
release_net has proper check inside to distinguish these cases.
Signed-off-by: Denis V. Lunev <redacted>
---
include/linux/netdevice.h | 3 ++-
net/core/dev.c | 2 ++
2 files changed, 4 insertions(+), 1 deletions(-)
Network namespace has two referrence counters:
- count
- use_count.
The namespace is scheduled to destruction automatically when the count
becomes 0.
There are several SLAB objects with a pointer to a namespace on them.
These objects are cleaned up during namespace stop. Some of them
increment use_count, some don't. This set fixes this discrepancy,
i.e. now all such objects increment the use_count.
Though, the use_count itself is used in a very debug manner and checked
only during namespace stop. So, I have placed it under
NETNS_REFCNT_DEBUG definition exactly like this is done for socket
refcounting code to remove extra atomic from any possible fast paths.
Signed-off-by: Denis V. Lunev <redacted>
This is a notification that the Linux NETDEV Patch Robot has used all
automated tools known to man to validate your patches, and has decided
to apply then to the net-2.6.26 GIT tree.
*beep* *beep*
You may continue hacking.
*beep* *beep*
Have a pleasant day.