OpenVZ Forum


Home » Mailing lists » Devel » [patch 00/12] net namespace : L3 namespace - introduction
[patch 02/12] net namespace : store L2 parent namespace [message #17281 is a reply to message #17279] Fri, 19 January 2007 15:47 Go to previous messageGo to previous message
Daniel Lezcano is currently offline  Daniel Lezcano
Messages: 417
Registered: June 2006
Senior Member
From: Daniel Lezcano <dlezcano@fr.ibm.com>

All L3 namespaces are the final nodes of the L2 namespaces
tree. Because their share some ressources coming from the L2
namespace. The L2 parent namespace should be stored into the L3 child
when it is created.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>

---
 include/linux/net_namespace.h |    1 +
 net/core/net_namespace.c      |   11 +++++++++++
 2 files changed, 12 insertions(+)

Index: 2.6.20-rc4-mm1/include/linux/net_namespace.h
===================================================================
--- 2.6.20-rc4-mm1.orig/include/linux/net_namespace.h
+++ 2.6.20-rc4-mm1/include/linux/net_namespace.h
@@ -27,6 +27,7 @@
 #define NET_NS_LEVEL2		1
 #define NET_NS_LEVEL3		2
 	unsigned int		level;
+	struct net_namespace    *parent;
 };
 
 extern struct net_namespace init_net_ns;
Index: 2.6.20-rc4-mm1/net/core/net_namespace.c
===================================================================
--- 2.6.20-rc4-mm1.orig/net/core/net_namespace.c
+++ 2.6.20-rc4-mm1/net/core/net_namespace.c
@@ -22,6 +22,7 @@
 	.loopback_dev_p	= NULL,
 	.pcpu_lstats_p	= NULL,
 	.level          = NET_NS_LEVEL2,
+	.parent         = NULL,
 };
 
 #ifdef CONFIG_NET_NS
@@ -62,6 +63,12 @@
 		if (ip_fib_struct_init())
 			goto out_fib4;
 	}
+
+	if (level == NET_NS_LEVEL3) {
+		get_net_ns(old_ns);
+		ns->parent = old_ns;
+	}
+
 	ns->level = level;
 	if (loopback_init())
 		goto out_loopback;
@@ -126,8 +133,12 @@
 				ns, atomic_read(&ns->kref.refcount));
 		return;
 	}
+
 	if (ns->level == NET_NS_LEVEL2)
 		ip_fib_struct_cleanup(ns);
+	if (ns->level == NET_NS_LEVEL3)
+		put_net_ns(ns->parent);
+
 	printk(KERN_DEBUG "NET_NS: net namespace %p destroyed\n", ns);
 	kfree(ns);
 }

-- 
_______________________________________________
Containers mailing list
Containers@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/containers
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [PATCH] Statically initialize struct pid for swapper
Next Topic: [PATCH 0/6] containers: Generic Process Containers (V6)
Goto Forum:
  


Current Time: Mon Sep 30 04:11:47 GMT 2024

Total time taken to generate the page: 0.03337 seconds