[Devel] [PATCH] ve: wait for sub net namespaces to exit on ve cleanup

Kirill Tkhai ktkhai at odin.com
Thu Jun 11 08:13:17 PDT 2015


Porting patch diff-ve-net-netns-wait-for-sub-net-namespaces-to-exit-on-ve-cleanup
from 2.6.32 (ve_netns mustn't die, earlier than child net):

This is an alternative fix for PSBM-29810. Instead of messing with per
ve netns lists, just take a reference to the ve->ve_netns per each sub
net namespace.

https://jira.sw.ru/browse/PSBM-31246

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
Acked-by: Andrew Vagin <avagin at parallels.com>
Signed-off-by: Kirill Tkhai <ktkhai at odin.com>
---
 net/core/net_namespace.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 3f7da6a..9e73cc4 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -165,6 +165,8 @@ static __net_init int setup_net(struct net *net, struct user_namespace *user_ns)
 
 #ifdef CONFIG_VE
 	net->owner_ve = get_ve(get_exec_env());
+	if (net->owner_ve->ve_netns)
+		get_net(net->owner_ve->ve_netns);
 #endif
 
 	atomic_set(&net->count, 1);
@@ -233,6 +235,7 @@ static struct net *net_alloc(void)
 
 static void net_free(struct net *net)
 {
+	struct net *ve_netns = net->owner_ve->ve_netns;
 #ifdef NETNS_REFCNT_DEBUG
 	if (unlikely(atomic_read(&net->use_count) != 0)) {
 		pr_emerg("network namespace not free! Usage: %d\n",
@@ -242,6 +245,9 @@ static void net_free(struct net *net)
 #endif
 	kfree(net->gen);
 	kmem_cache_free(net_cachep, net);
+
+	if (ve_netns)
+		put_net(ve_netns);
 }
 
 void net_drop_ns(void *p)




More information about the Devel mailing list