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/sched.h>
15 #include <linux/vs_context.h>
16 #include <linux/vs_network.h>
17 #include <linux/vserver/legacy.h>
18 #include <linux/namespace.h>
19 #include <linux/err.h>
21 #include <asm/errno.h>
22 #include <asm/uaccess.h>
25 extern struct nx_info *create_nx_info(void);
27 /* set ipv4 root (syscall) */
29 int vc_set_ipv4root(uint32_t nbip, void __user *data)
32 struct vcmd_set_ipv4root_v3 vc_data;
33 struct nx_info *new_nxi, *nxi = current->nx_info;
35 if (nbip < 0 || nbip > NB_IPV4ROOT)
37 if (copy_from_user (&vc_data, data, sizeof(vc_data)))
40 if (!nxi || nxi->ipv4[0] == 0 || capable(CAP_NET_ADMIN))
41 /* We are allowed to change everything */
46 /* We are allowed to select a subset of the currently
47 installed IP numbers. No new one are allowed
48 We can't change the broadcast address though */
49 for (i=0; i<nbip; i++) {
51 __u32 nxip = vc_data.nx_mask_pair[i].ip;
52 for (j=0; j<nxi->nbipv4; j++) {
53 if (nxip == nxi->ipv4[j]) {
59 if ((found == nbip) &&
60 (vc_data.broadcast == nxi->v4_bcast))
66 new_nxi = create_nx_info();
70 new_nxi->nbipv4 = nbip;
71 for (i=0; i<nbip; i++) {
72 new_nxi->ipv4[i] = vc_data.nx_mask_pair[i].ip;
73 new_nxi->mask[i] = vc_data.nx_mask_pair[i].mask;
75 new_nxi->v4_bcast = vc_data.broadcast;
77 printk("!!! switching nx_info %p->%p\n", nxi, new_nxi);
79 nx_migrate_task(current, new_nxi);