(no commit message)
[linux-2.6.git] / linux-2.6-595-vserver-new-netns.patch
index f946b50..77a7378 100644 (file)
@@ -1,56 +1,61 @@
---- linux-2.6.22-590/kernel/vserver/space.c.orig       2008-02-29 09:01:28.000000000 -0500
-+++ linux-2.6.22-590/kernel/vserver/space.c    2008-03-06 15:47:26.000000000 -0500
-@@ -15,6 +15,7 @@
- #include <linux/utsname.h>
- #include <linux/nsproxy.h>
- #include <linux/err.h>
-+#include <net/net_namespace.h>
- #include <asm/uaccess.h>
+diff -Nurb linux-2.6.22-594/net/core/dev.c linux-2.6.22-595/net/core/dev.c
+--- linux-2.6.22-594/net/core/dev.c    2008-03-20 01:27:55.000000000 -0400
++++ linux-2.6.22-595/net/core/dev.c    2008-03-20 01:32:22.000000000 -0400
+@@ -2207,7 +2207,7 @@
  
- #include <linux/vs_context.h>
-@@ -54,6 +55,7 @@
-       struct mnt_namespace *old_ns;
-       struct uts_namespace *old_uts;
-       struct ipc_namespace *old_ipc;
-+      struct net *old_net;
-       struct nsproxy *nsproxy;
+       total = 0;
+       for_each_netdev(net, dev) {
+-              if (!nx_dev_visible(current->nx_info, dev))
++              if (net==&init_net && !nx_dev_visible(current->nx_info, dev))
+                       continue;
+               for (i = 0; i < NPROTO; i++) {
+                       if (gifconf_list[i]) {
+@@ -2274,8 +2274,9 @@
+ static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
+ {
+       struct net_device_stats *stats = dev->get_stats(dev);
++      struct net *net = seq->private;
  
-       nsproxy = copy_nsproxy(old_nsproxy);
-@@ -83,6 +85,17 @@
-                       get_ipc_ns(nsproxy->ipc_ns);
-       } else
-               old_ipc = NULL;
-+      
-+      if (mask & CLONE_NEWNET) {
-+              old_net = nsproxy->net_ns;
-+              nsproxy->net_ns = new_nsproxy->net_ns;
-+              if (nsproxy->net_ns) {
-+                      get_net(nsproxy->net_ns);
-+                      printk(KERN_ALERT "Cloning network namespace\n"); 
-+              }       
-+      } else
-+              old_net = NULL;
-+
+-      if (!nx_dev_visible(current->nx_info, dev))
++      if (net==&init_net && !nx_dev_visible(current->nx_info, dev))
+               return;
  
-       if (old_ns)
-               put_mnt_ns(old_ns);
-@@ -90,6 +101,9 @@
-               put_uts_ns(old_uts);
-       if (old_ipc)
-               put_ipc_ns(old_ipc);
-+      if (old_net)
-+              put_net(old_net);
-+
+       seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
+diff -Nurb linux-2.6.22-594/net/core/net_namespace.c linux-2.6.22-595/net/core/net_namespace.c
+--- linux-2.6.22-594/net/core/net_namespace.c  2008-03-20 01:27:51.000000000 -0400
++++ linux-2.6.22-595/net/core/net_namespace.c  2008-03-20 01:28:00.000000000 -0400
+@@ -112,10 +112,12 @@
+               ops = list_entry(ptr, struct pernet_operations, list);
+               if (ops->init) {
+                       error = ops->init(net);
+-                      if (error < 0)
++                      if (error < 0) {
++                              printk(KERN_ALERT "Error setting up netns: %x\n", ops->init);
+                               goto out_undo;
+               }
+       }
++      }
  out:
-       return nsproxy;
- }
-@@ -250,7 +264,8 @@
+       return error;
+ out_undo:
+diff -Nurb linux-2.6.22-594/net/socket.c linux-2.6.22-595/net/socket.c
+--- linux-2.6.22-594/net/socket.c      2008-03-20 01:27:52.000000000 -0400
++++ linux-2.6.22-595/net/socket.c      2008-03-20 01:28:00.000000000 -0400
+@@ -1122,12 +1122,17 @@
+       if (type < 0 || type >= SOCK_MAX)
+               return -EINVAL;
  
- int vc_enter_space(struct vx_info *vxi, void __user *data)
- {
--      struct vcmd_space_mask vc_data = { .mask = 0 };
-+      /* Ask dhozac how to pass this flag from user space - Sapan*/
-+      struct vcmd_space_mask vc_data = { .mask = CLONE_NEWNET };
++      /*
++       * Hack no. 2 - Sapan
++       * Clean this up later
++       *
+       if (!nx_check(0, VS_ADMIN)) {
+               if (family == PF_INET && !current_nx_info_has_v4())
+                       return -EAFNOSUPPORT;
+               if (family == PF_INET6 && !current_nx_info_has_v6())
+                       return -EAFNOSUPPORT;
+       }
++      */
+       /* Compatibility.
  
-       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
-               return -EFAULT;