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_base.h>
16 #include <linux/vs_context.h>
17 #include <linux/vs_network.h>
18 #include <linux/vserver/legacy.h>
19 #include <linux/namespace.h>
20 #include <linux/err.h>
22 #include <asm/errno.h>
23 #include <asm/uaccess.h>
26 extern struct nx_info *create_nx_info(void);
28 /* set ipv4 root (syscall) */
30 int vc_set_ipv4root(uint32_t nbip, void __user *data)
33 struct vcmd_set_ipv4root_v3 vc_data;
34 struct nx_info *new_nxi, *nxi = current->nx_info;
36 if (nbip < 0 || nbip > NB_IPV4ROOT)
38 if (copy_from_user (&vc_data, data, sizeof(vc_data)))
41 if (!nxi || nxi->ipv4[0] == 0 || capable(CAP_NET_ADMIN))
42 /* We are allowed to change everything */
47 /* We are allowed to select a subset of the currently
48 installed IP numbers. No new one are allowed
49 We can't change the broadcast address though */
50 for (i=0; i<nbip; i++) {
52 __u32 nxip = vc_data.nx_mask_pair[i].ip;
53 for (j=0; j<nxi->nbipv4; j++) {
54 if (nxip == nxi->ipv4[j]) {
60 if ((found == nbip) &&
61 (vc_data.broadcast == nxi->v4_bcast))
67 new_nxi = create_nx_info();
71 new_nxi->nbipv4 = nbip;
72 for (i=0; i<nbip; i++) {
73 new_nxi->ipv4[i] = vc_data.nx_mask_pair[i].ip;
74 new_nxi->mask[i] = vc_data.nx_mask_pair[i].mask;
76 new_nxi->v4_bcast = vc_data.broadcast;
78 printk("!!! switching nx_info %p->%p\n", nxi, new_nxi);
80 nx_migrate_task(current, new_nxi);
81 release_nx_info(new_nxi, NULL);