[Devel] [patch 07/20] [Network namespace] Temporary remove the loopback initialization for layer 3. Allow l3 child to see l2 route and dev.
dlezcano at fr.ibm.com
dlezcano at fr.ibm.com
Sun Dec 10 13:58:24 PST 2006
Signed-off-by: Daniel Lezcano <dlezcano at fr.ibm.com>
---
net/core/net_namespace.c | 32 +++++++++++++++++++-------------
1 files changed, 19 insertions(+), 13 deletions(-)
Index: 2.6.19-rc6-mm2/net/core/net_namespace.c
===================================================================
--- 2.6.19-rc6-mm2.orig/net/core/net_namespace.c
+++ 2.6.19-rc6-mm2/net/core/net_namespace.c
@@ -46,14 +46,12 @@ static struct net_namespace *clone_net_n
if (current_net_ns->level == NET_NS_LEVEL3)
return ERR_PTR(-EPERM);
- ns = kmalloc(sizeof(struct net_namespace), GFP_KERNEL);
+ ns = kmemdup(old_ns, sizeof(struct net_namespace), GFP_KERNEL);
if (!ns)
return NULL;
kref_init(&ns->kref);
ns->ns = old_ns->ns;
- ns->dev_base_p = NULL;
- ns->dev_tail_p = &ns->dev_base_p;
ns->hash = net_random();
INIT_LIST_HEAD(&ns->child_list);
spin_lock_irq(&net_ns_list_lock);
@@ -63,15 +61,20 @@ static struct net_namespace *clone_net_n
spin_unlock_irq(&net_ns_list_lock);
if (level == NET_NS_LEVEL2) {
+
+ ns->dev_base_p = NULL;
+ ns->dev_tail_p = &ns->dev_base_p;
+
#ifdef CONFIG_IP_MULTIPLE_TABLES
INIT_LIST_HEAD(&ns->fib_rules_ops_list);
#endif
if (ip_fib_struct_init(ns))
goto out_fib4;
+ if (loopback_init(ns))
+ goto out_loopback;
}
ns->level = level;
- if (loopback_init(ns))
- goto out_loopback;
+
printk(KERN_DEBUG "NET_NS: created new netcontext %p, level %u, "
"for %s (pid=%d)\n", ns, (ns->level == NET_NS_LEVEL2) ?
2 : 3, current->comm, current->tgid);
@@ -133,16 +136,19 @@ void free_net_ns(struct kref *kref)
spin_unlock_irqrestore(&net_ns_list_lock, flags);
put_net_ns(ns->parent);
- unregister_netdev(ns->loopback_dev_p);
- if (ns->dev_base_p != NULL) {
- printk("NET_NS: BUG: namespace %p has devices! ref %d\n",
- ns, atomic_read(&ns->kref.refcount));
- return;
- }
- if (ns->level == NET_NS_LEVEL2)
+ if (ns->level == NET_NS_LEVEL2) {
ip_fib_struct_cleanup();
+ unregister_netdev(ns->loopback_dev_p);
+ if (ns->dev_base_p != NULL) {
+ printk("NET_NS: BUG: namespace %p has devices! ref %d\n",
+ ns, atomic_read(&ns->kref.refcount));
+ return;
+ }
+ }
+
printk(KERN_DEBUG "NET_NS: net namespace %p (%u) destroyed\n",
- ns, ns->id);
+ ns, ns->id);
+
kfree(ns);
}
/* because of put_net_ns() */
--
_______________________________________________
Containers mailing list
Containers at lists.osdl.org
https://lists.osdl.org/mailman/listinfo/containers
More information about the Devel
mailing list