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