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