Reset to the original
[linux-2.6.git] / linux-2.6-595-vserver-new-netns.patch
1 --- linux-2.6.22-590/kernel/vserver/space.c.orig        2008-02-29 09:01:28.000000000 -0500
2 +++ linux-2.6.22-590/kernel/vserver/space.c     2008-03-06 15:47:26.000000000 -0500
3 @@ -15,6 +15,7 @@
4  #include <linux/utsname.h>
5  #include <linux/nsproxy.h>
6  #include <linux/err.h>
7 +#include <net/net_namespace.h>
8  #include <asm/uaccess.h>
9  
10  #include <linux/vs_context.h>
11 @@ -54,6 +55,7 @@
12         struct mnt_namespace *old_ns;
13         struct uts_namespace *old_uts;
14         struct ipc_namespace *old_ipc;
15 +       struct net *old_net;
16         struct nsproxy *nsproxy;
17  
18         nsproxy = copy_nsproxy(old_nsproxy);
19 @@ -83,6 +85,17 @@
20                         get_ipc_ns(nsproxy->ipc_ns);
21         } else
22                 old_ipc = NULL;
23 +       
24 +       if (mask & CLONE_NEWNET) {
25 +               old_net = nsproxy->net_ns;
26 +               nsproxy->net_ns = new_nsproxy->net_ns;
27 +               if (nsproxy->net_ns) {
28 +                       get_net(nsproxy->net_ns);
29 +                       printk(KERN_ALERT "Cloning network namespace\n"); 
30 +               }       
31 +       } else
32 +               old_net = NULL;
33 +
34  
35         if (old_ns)
36                 put_mnt_ns(old_ns);
37 @@ -90,6 +101,9 @@
38                 put_uts_ns(old_uts);
39         if (old_ipc)
40                 put_ipc_ns(old_ipc);
41 +       if (old_net)
42 +               put_net(old_net);
43 +
44  out:
45         return nsproxy;
46  }
47 @@ -250,7 +264,8 @@
48  
49  int vc_enter_space(struct vx_info *vxi, void __user *data)
50  {
51 -       struct vcmd_space_mask vc_data = { .mask = 0 };
52 +       /* Ask dhozac how to pass this flag from user space - Sapan*/
53 +       struct vcmd_space_mask vc_data = { .mask = CLONE_NEWNET };
54  
55         if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
56                 return -EFAULT;