]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/core/net_namespace.c
[IPV6]: Sparse: Reuse previous delaration where appropriate.
[linux-2.6-omap-h63xx.git] / net / core / net_namespace.c
index e9f0964ce70bf89eef873b23c2ad9c2f80a4cf57..7b660834a4c207a08b23ff6f63fa8ae719ca4fba 100644 (file)
@@ -18,7 +18,7 @@ static DEFINE_MUTEX(net_mutex);
 LIST_HEAD(net_namespace_list);
 
 struct net init_net;
-EXPORT_SYMBOL_GPL(init_net);
+EXPORT_SYMBOL(init_net);
 
 /*
  * setup_net runs the initializers for the network namespace object.
@@ -58,12 +58,27 @@ out_undo:
 
 #ifdef CONFIG_NET_NS
 static struct kmem_cache *net_cachep;
+static struct workqueue_struct *netns_wq;
 
 static struct net *net_alloc(void)
 {
        return kmem_cache_zalloc(net_cachep, GFP_KERNEL);
 }
 
+static void net_free(struct net *net)
+{
+       if (!net)
+               return;
+
+       if (unlikely(atomic_read(&net->use_count) != 0)) {
+               printk(KERN_EMERG "network namespace not free! Usage: %d\n",
+                       atomic_read(&net->use_count));
+               return;
+       }
+
+       kmem_cache_free(net_cachep, net);
+}
+
 struct net *copy_net_ns(unsigned long flags, struct net *old_net)
 {
        struct net *new_net = NULL;
@@ -100,20 +115,6 @@ out:
        return new_net;
 }
 
-static void net_free(struct net *net)
-{
-       if (!net)
-               return;
-
-       if (unlikely(atomic_read(&net->use_count) != 0)) {
-               printk(KERN_EMERG "network namespace not free! Usage: %d\n",
-                       atomic_read(&net->use_count));
-               return;
-       }
-
-       kmem_cache_free(net_cachep, net);
-}
-
 static void cleanup_net(struct work_struct *work)
 {
        struct pernet_operations *ops;
@@ -149,7 +150,7 @@ void __put_net(struct net *net)
 {
        /* Cleanup the network namespace in process context */
        INIT_WORK(&net->work, cleanup_net);
-       schedule_work(&net->work);
+       queue_work(netns_wq, &net->work);
 }
 EXPORT_SYMBOL_GPL(__put_net);
 
@@ -171,7 +172,13 @@ static int __init net_ns_init(void)
        net_cachep = kmem_cache_create("net_namespace", sizeof(struct net),
                                        SMP_CACHE_BYTES,
                                        SLAB_PANIC, NULL);
+
+       /* Create workqueue for cleanup */
+       netns_wq = create_singlethread_workqueue("netns");
+       if (!netns_wq)
+               panic("Could not create netns workq");
 #endif
+
        mutex_lock(&net_mutex);
        err = setup_net(&init_net);
 
@@ -188,6 +195,7 @@ static int __init net_ns_init(void)
 
 pure_initcall(net_ns_init);
 
+#ifdef CONFIG_NET_NS
 static int register_pernet_operations(struct list_head *list,
                                      struct pernet_operations *ops)
 {
@@ -228,6 +236,23 @@ static void unregister_pernet_operations(struct pernet_operations *ops)
                        ops->exit(net);
 }
 
+#else
+
+static int register_pernet_operations(struct list_head *list,
+                                     struct pernet_operations *ops)
+{
+       if (ops->init == NULL)
+               return 0;
+       return ops->init(&init_net);
+}
+
+static void unregister_pernet_operations(struct pernet_operations *ops)
+{
+       if (ops->exit)
+               ops->exit(&init_net);
+}
+#endif
+
 /**
  *      register_pernet_subsys - register a network namespace subsystem
  *     @ops:  pernet operations structure for the subsystem
@@ -262,7 +287,7 @@ EXPORT_SYMBOL_GPL(register_pernet_subsys);
  *     @ops: pernet operations structure to manipulate
  *
  *     Remove the pernet operations structure from the list to be
- *     used when network namespaces are created or destoryed.  In
+ *     used when network namespaces are created or destroyed.  In
  *     addition run the exit method for all existing network
  *     namespaces.
  */
@@ -310,7 +335,7 @@ EXPORT_SYMBOL_GPL(register_pernet_device);
  *     @ops: pernet operations structure to manipulate
  *
  *     Remove the pernet operations structure from the list to be
- *     used when network namespaces are created or destoryed.  In
+ *     used when network namespaces are created or destroyed.  In
  *     addition run the exit method for all existing network
  *     namespaces.
  */