Merge to Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.13-vs2...
[linux-2.6.git] / include / linux / vserver / network.h
1 #ifndef _VX_NETWORK_H
2 #define _VX_NETWORK_H
3
4 #include <linux/types.h>
5
6
7 #define MAX_N_CONTEXT   65535   /* Arbitrary limit */
8
9 #define NX_DYNAMIC_ID   ((uint32_t)-1)          /* id for dynamic context */
10
11 #define NB_IPV4ROOT     16
12
13
14 /* network flags */
15
16 #define NXF_STATE_SETUP         (1ULL<<32)
17
18 #define NXF_SC_HELPER           (1ULL<<36)
19 #define NXF_PERSISTENT          (1ULL<<38)
20
21 #define NXF_ONE_TIME            (0x0001ULL<<32)
22
23 #define NXF_INIT_SET            (0)
24
25
26 /* address types */
27
28 #define NXA_TYPE_IPV4           1
29 #define NXA_TYPE_IPV6           2
30
31 #define NXA_MOD_BCAST           (1<<8)
32
33 #define NXA_TYPE_ANY            ((uint16_t)-1)
34
35
36 #ifdef  __KERNEL__
37
38 #include <linux/list.h>
39 #include <linux/spinlock.h>
40 #include <linux/rcupdate.h>
41 #include <asm/atomic.h>
42
43
44 struct nx_info {
45         struct hlist_node nx_hlist;     /* linked list of nxinfos */
46         nid_t nx_id;                    /* vnet id */
47         atomic_t nx_usecnt;             /* usage count */
48         atomic_t nx_tasks;              /* tasks count */
49         int nx_state;                   /* context state */
50
51         uint64_t nx_flags;              /* network flag word */
52         uint64_t nx_ncaps;              /* network capabilities */
53
54         int nbipv4;
55         __u32 ipv4[NB_IPV4ROOT];        /* Process can only bind to these IPs */
56                                         /* The first one is used to connect */
57                                         /* and for bind any service */
58                                         /* The other must be used explicity */
59         __u32 mask[NB_IPV4ROOT];        /* Netmask for each ipv4 */
60                                         /* Used to select the proper source */
61                                         /* address for sockets */
62         __u32 v4_bcast;                 /* Broadcast address to receive UDP  */
63
64         char nx_name[65];               /* network context name */
65 };
66
67
68 /* status flags */
69
70 #define NXS_HASHED      0x0001
71 #define NXS_SHUTDOWN    0x0100
72 #define NXS_RELEASED    0x8000
73
74 extern struct nx_info *lookup_nx_info(int);
75
76 extern int get_nid_list(int, unsigned int *, int);
77 extern int nid_is_hashed(nid_t);
78
79 extern int nx_migrate_task(struct task_struct *, struct nx_info *);
80
81 extern long vs_net_change(struct nx_info *, unsigned int);
82
83 struct in_ifaddr;
84 struct net_device;
85
86 #ifdef CONFIG_INET
87 int ifa_in_nx_info(struct in_ifaddr *, struct nx_info *);
88 int dev_in_nx_info(struct net_device *, struct nx_info *);
89
90 #else /* CONFIG_INET */
91 static inline
92 int ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
93 {
94         return 1;
95 }
96
97 static inline
98 int dev_in_nx_info(struct net_device *d, struct nx_info *n)
99 {
100         return 1;
101 }
102 #endif /* CONFIG_INET */
103
104 struct sock;
105
106 #ifdef CONFIG_INET
107 int nx_addr_conflict(struct nx_info *, uint32_t, struct sock *);
108 #else /* CONFIG_INET */
109 static inline
110 int nx_addr_conflict(struct nx_info *n, uint32_t a, struct sock *s)
111 {
112         return 1;
113 }
114 #endif /* CONFIG_INET */
115
116 #endif  /* __KERNEL__ */
117 #else   /* _VX_NETWORK_H */
118 #warning duplicate inclusion
119 #endif  /* _VX_NETWORK_H */