1 diff -Nurb linux-2.6.22-594/arch/i386/kernel/syscall_table.S linux-2.6.22-595/arch/i386/kernel/syscall_table.S
2 --- linux-2.6.22-594/arch/i386/kernel/syscall_table.S 2008-03-21 15:19:20.000000000 -0400
3 +++ linux-2.6.22-595/arch/i386/kernel/syscall_table.S 2008-03-21 15:19:27.000000000 -0400
6 .long sys_frevoke /* 325 */
9 diff -Nurb linux-2.6.22-594/kernel/nsproxy.c linux-2.6.22-595/kernel/nsproxy.c
10 --- linux-2.6.22-594/kernel/nsproxy.c 2008-03-21 15:19:21.000000000 -0400
11 +++ linux-2.6.22-595/kernel/nsproxy.c 2008-03-21 15:26:13.000000000 -0400
13 #include <linux/pid_namespace.h>
14 #include <linux/vserver/global.h>
15 #include <linux/vserver/debug.h>
16 +#include <linux/sched.h>
18 +#include <net/net_namespace.h>
20 +int vx_enter_space(struct task_struct *, struct vx_info *, unsigned long);
22 static struct kmem_cache *nsproxy_cachep;
24 struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy);
26 +asmlinkage long sys_set_space(int pid, int id, int toggle, unsigned long unshare_flags) {
27 + struct task_struct *p;
28 + struct fs_struct *fs_cur;
29 + struct nsproxy *proxy_cur;
32 + if (unshare_flags & ~CLONE_NEWNET) {
33 + printk(KERN_ALERT "sys_set_space currently only supports CLONE_NEWNET\n");
37 + p = find_task_by_pid(pid);
38 + if (p && (p->xid == id)) {
39 + struct vx_info *vxi;
42 + atomic_inc(&fs_cur->count);
43 + proxy_cur = p->nsproxy;
44 + get_nsproxy(proxy_cur);
48 + ret = vx_enter_space(p, vxi, unshare_flags);
51 + /* Major hack - use nsproxy not namespaces here */
52 + if (unshare_flags & CLONE_NEWNET) {
53 + struct net *old_net = proxy_cur->net_ns;
54 + proxy_cur->net_ns = &init_net;
55 + get_net(proxy_cur->net_ns);
58 + atomic_dec(&fs_cur->count);
59 + put_nsproxy(proxy_cur);
62 + printk(KERN_ALERT "Invalid process id\n");
69 void get_task_namespaces(struct task_struct *tsk)
71 struct nsproxy *ns = tsk->nsproxy;
72 diff -Nurb linux-2.6.22-594/kernel/vserver/space.c linux-2.6.22-595/kernel/vserver/space.c
73 --- linux-2.6.22-594/kernel/vserver/space.c 2008-03-21 15:19:25.000000000 -0400
74 +++ linux-2.6.22-595/kernel/vserver/space.c 2008-03-21 15:19:27.000000000 -0400
79 -int vx_enter_space(struct vx_info *vxi, unsigned long mask)
80 +int vx_enter_space(struct task_struct *p, struct vx_info *vxi, unsigned long mask)
82 struct nsproxy *proxy, *proxy_cur, *proxy_new;
83 struct fs_struct *fs, *fs_cur, *fs_new;
85 proxy = vxi->vx_nsproxy;
89 - fs_cur = current->fs;
92 atomic_inc(&fs_cur->count);
93 - proxy_cur = current->nsproxy;
94 + proxy_cur = p->nsproxy;
95 get_nsproxy(proxy_cur);
96 - task_unlock(current);
99 fs_new = __vs_merge_fs(fs_cur, fs, mask);
100 if (IS_ERR(fs_new)) {
105 - fs_new = xchg(¤t->fs, fs_new);
106 - proxy_new = xchg(¤t->nsproxy, proxy_new);
107 + fs_new = xchg(&p->fs, fs_new);
108 + proxy_new = xchg(&p->nsproxy, proxy_new);
113 if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
116 - return vx_enter_space(vxi, vc_data.mask);
117 + return vx_enter_space(current, vxi, vc_data.mask);
120 int vc_set_space(struct vx_info *vxi, void __user *data)
121 diff -Nurb linux-2.6.22-594/net/core/dev.c linux-2.6.22-595/net/core/dev.c
122 --- linux-2.6.22-594/net/core/dev.c 2008-03-21 15:19:25.000000000 -0400
123 +++ linux-2.6.22-595/net/core/dev.c 2008-03-21 15:19:27.000000000 -0400
124 @@ -2207,7 +2207,7 @@
127 for_each_netdev(net, dev) {
128 - if (!nx_dev_visible(current->nx_info, dev))
129 + if (net==&init_net && !nx_dev_visible(current->nx_info, dev))
131 for (i = 0; i < NPROTO; i++) {
132 if (gifconf_list[i]) {
133 @@ -2274,8 +2274,9 @@
134 static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
136 struct net_device_stats *stats = dev->get_stats(dev);
137 + struct net *net = seq->private;
139 - if (!nx_dev_visible(current->nx_info, dev))
140 + if (net==&init_net && !nx_dev_visible(current->nx_info, dev))
143 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
144 diff -Nurb linux-2.6.22-594/net/core/net_namespace.c linux-2.6.22-595/net/core/net_namespace.c
145 --- linux-2.6.22-594/net/core/net_namespace.c 2008-03-21 15:19:21.000000000 -0400
146 +++ linux-2.6.22-595/net/core/net_namespace.c 2008-03-21 15:19:27.000000000 -0400
147 @@ -112,10 +112,12 @@
148 ops = list_entry(ptr, struct pernet_operations, list);
150 error = ops->init(net);
153 + printk(KERN_ALERT "Error setting up netns: %x\n", ops->init);
161 diff -Nurb linux-2.6.22-594/net/socket.c linux-2.6.22-595/net/socket.c
162 --- linux-2.6.22-594/net/socket.c 2008-03-21 15:19:24.000000000 -0400
163 +++ linux-2.6.22-595/net/socket.c 2008-03-21 15:19:27.000000000 -0400
164 @@ -1122,12 +1122,17 @@
165 if (type < 0 || type >= SOCK_MAX)
169 + * Hack no. 2 - Sapan
170 + * Clean this up later
172 if (!nx_check(0, VS_ADMIN)) {
173 if (family == PF_INET && !current_nx_info_has_v4())
174 return -EAFNOSUPPORT;
175 if (family == PF_INET6 && !current_nx_info_has_v6())
176 return -EAFNOSUPPORT;