3 * linux/kernel/vserver/legacynet.c
5 * Virtual Server: Legacy Network Funtions
7 * Copyright (C) 2001-2003 Jacques Gelinas
8 * Copyright (C) 2003-2005 Herbert Pƶtzl
10 * V0.01 broken out from legacy.c
14 #include <linux/config.h>
15 #include <linux/sched.h>
16 #include <linux/vs_context.h>
17 #include <linux/vs_network.h>
18 #include <linux/vserver/legacy.h>
19 // #include <linux/vserver/namespace.h>
20 #include <linux/namespace.h>
21 #include <linux/err.h>
23 #include <asm/errno.h>
24 #include <asm/uaccess.h>
27 extern struct nx_info *create_nx_info(void);
29 /* set ipv4 root (syscall) */
31 int vc_set_ipv4root(uint32_t nbip, void __user *data)
34 struct vcmd_set_ipv4root_v3 vc_data;
35 struct nx_info *new_nxi, *nxi = current->nx_info;
37 if (nbip < 0 || nbip > NB_IPV4ROOT)
39 if (copy_from_user (&vc_data, data, sizeof(vc_data)))
42 if (!nxi || nxi->ipv4[0] == 0 || capable(CAP_NET_ADMIN))
43 /* We are allowed to change everything */
48 /* We are allowed to select a subset of the currently
49 installed IP numbers. No new one are allowed
50 We can't change the broadcast address though */
51 for (i=0; i<nbip; i++) {
53 __u32 nxip = vc_data.nx_mask_pair[i].ip;
54 for (j=0; j<nxi->nbipv4; j++) {
55 if (nxip == nxi->ipv4[j]) {
61 if ((found == nbip) &&
62 (vc_data.broadcast == nxi->v4_bcast))
68 new_nxi = create_nx_info();
72 new_nxi->nbipv4 = nbip;
73 for (i=0; i<nbip; i++) {
74 new_nxi->ipv4[i] = vc_data.nx_mask_pair[i].ip;
75 new_nxi->mask[i] = vc_data.nx_mask_pair[i].mask;
77 new_nxi->v4_bcast = vc_data.broadcast;
79 printk("!!! switching nx_info %p->%p\n", nxi, new_nxi);
81 nx_migrate_task(current, new_nxi);