]> err.no Git - linux-2.6/blobdiff - kernel/nsproxy.c
sched: group scheduler wakeup latency fix
[linux-2.6] / kernel / nsproxy.c
index 4b7fcc8f9a48f9f329c9a1de80c53c5b17ff87cc..f1decd21a534c248054bef7c1c6f9f6ec7da072c 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/mnt_namespace.h>
 #include <linux/utsname.h>
 #include <linux/pid_namespace.h>
+#include <net/net_namespace.h>
 
 static struct kmem_cache *nsproxy_cachep;
 
@@ -58,8 +59,8 @@ static inline struct nsproxy *clone_nsproxy(struct nsproxy *orig)
  * Return the newly created nsproxy.  Do not attach this to the task,
  * leave it to the caller to do proper locking and attach it to task.
  */
-static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
-                       struct fs_struct *new_fs)
+static struct nsproxy *create_new_namespaces(unsigned long flags,
+                       struct task_struct *tsk, struct fs_struct *new_fs)
 {
        struct nsproxy *new_nsp;
        int err;
@@ -98,8 +99,17 @@ static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
                goto out_user;
        }
 
+       new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
+       if (IS_ERR(new_nsp->net_ns)) {
+               err = PTR_ERR(new_nsp->net_ns);
+               goto out_net;
+       }
+
        return new_nsp;
 
+out_net:
+       if (new_nsp->user_ns)
+               put_user_ns(new_nsp->user_ns);
 out_user:
        if (new_nsp->pid_ns)
                put_pid_ns(new_nsp->pid_ns);
@@ -121,7 +131,7 @@ out_ns:
  * called from clone.  This now handles copy for nsproxy and all
  * namespaces therein.
  */
-int copy_namespaces(int flags, struct task_struct *tsk)
+int copy_namespaces(unsigned long flags, struct task_struct *tsk)
 {
        struct nsproxy *old_ns = tsk->nsproxy;
        struct nsproxy *new_ns;
@@ -132,7 +142,7 @@ int copy_namespaces(int flags, struct task_struct *tsk)
 
        get_nsproxy(old_ns);
 
-       if (!(flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER)))
+       if (!(flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER | CLONE_NEWNET)))
                return 0;
 
        if (!capable(CAP_SYS_ADMIN)) {
@@ -164,6 +174,7 @@ void free_nsproxy(struct nsproxy *ns)
                put_pid_ns(ns->pid_ns);
        if (ns->user_ns)
                put_user_ns(ns->user_ns);
+       put_net(ns->net_ns);
        kmem_cache_free(nsproxy_cachep, ns);
 }
 
@@ -177,7 +188,7 @@ int unshare_nsproxy_namespaces(unsigned long unshare_flags,
        int err = 0;
 
        if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
-                              CLONE_NEWUSER)))
+                              CLONE_NEWUSER | CLONE_NEWNET)))
                return 0;
 
        if (!capable(CAP_SYS_ADMIN))
@@ -193,7 +204,7 @@ int unshare_nsproxy_namespaces(unsigned long unshare_flags,
 static int __init nsproxy_cache_init(void)
 {
        nsproxy_cachep = kmem_cache_create("nsproxy", sizeof(struct nsproxy),
-                                          0, SLAB_PANIC, NULL, NULL);
+                                          0, SLAB_PANIC, NULL);
        return 0;
 }