1
2
3
4
5
6#ifndef _IP_VS_H
7#define _IP_VS_H
8
9#include <linux/types.h>
10
11#define IP_VS_VERSION_CODE 0x010201
12#define NVERSION(version) \
13 (version >> 16) & 0xFF, \
14 (version >> 8) & 0xFF, \
15 version & 0xFF
16
17
18
19
20#define IP_VS_SVC_F_PERSISTENT 0x0001
21#define IP_VS_SVC_F_HASHED 0x0002
22#define IP_VS_SVC_F_ONEPACKET 0x0004
23#define IP_VS_SVC_F_SCHED1 0x0008
24#define IP_VS_SVC_F_SCHED2 0x0010
25#define IP_VS_SVC_F_SCHED3 0x0020
26
27#define IP_VS_SVC_F_SCHED_SH_FALLBACK IP_VS_SVC_F_SCHED1
28#define IP_VS_SVC_F_SCHED_SH_PORT IP_VS_SVC_F_SCHED2
29
30
31
32
33#define IP_VS_DEST_F_AVAILABLE 0x0001
34#define IP_VS_DEST_F_OVERLOAD 0x0002
35
36
37
38
39#define IP_VS_STATE_NONE 0x0000
40#define IP_VS_STATE_MASTER 0x0001
41#define IP_VS_STATE_BACKUP 0x0002
42
43
44
45
46#define IP_VS_BASE_CTL (64+1024+64)
47
48#define IP_VS_SO_SET_NONE IP_VS_BASE_CTL
49#define IP_VS_SO_SET_INSERT (IP_VS_BASE_CTL+1)
50#define IP_VS_SO_SET_ADD (IP_VS_BASE_CTL+2)
51#define IP_VS_SO_SET_EDIT (IP_VS_BASE_CTL+3)
52#define IP_VS_SO_SET_DEL (IP_VS_BASE_CTL+4)
53#define IP_VS_SO_SET_FLUSH (IP_VS_BASE_CTL+5)
54#define IP_VS_SO_SET_LIST (IP_VS_BASE_CTL+6)
55#define IP_VS_SO_SET_ADDDEST (IP_VS_BASE_CTL+7)
56#define IP_VS_SO_SET_DELDEST (IP_VS_BASE_CTL+8)
57#define IP_VS_SO_SET_EDITDEST (IP_VS_BASE_CTL+9)
58#define IP_VS_SO_SET_TIMEOUT (IP_VS_BASE_CTL+10)
59#define IP_VS_SO_SET_STARTDAEMON (IP_VS_BASE_CTL+11)
60#define IP_VS_SO_SET_STOPDAEMON (IP_VS_BASE_CTL+12)
61#define IP_VS_SO_SET_RESTORE (IP_VS_BASE_CTL+13)
62#define IP_VS_SO_SET_SAVE (IP_VS_BASE_CTL+14)
63#define IP_VS_SO_SET_ZERO (IP_VS_BASE_CTL+15)
64#define IP_VS_SO_SET_MAX IP_VS_SO_SET_ZERO
65
66#define IP_VS_SO_GET_VERSION IP_VS_BASE_CTL
67#define IP_VS_SO_GET_INFO (IP_VS_BASE_CTL+1)
68#define IP_VS_SO_GET_SERVICES (IP_VS_BASE_CTL+2)
69#define IP_VS_SO_GET_SERVICE (IP_VS_BASE_CTL+3)
70#define IP_VS_SO_GET_DESTS (IP_VS_BASE_CTL+4)
71#define IP_VS_SO_GET_DEST (IP_VS_BASE_CTL+5)
72#define IP_VS_SO_GET_TIMEOUT (IP_VS_BASE_CTL+6)
73#define IP_VS_SO_GET_DAEMON (IP_VS_BASE_CTL+7)
74#define IP_VS_SO_GET_MAX IP_VS_SO_GET_DAEMON
75
76
77
78
79
80
81#define IP_VS_CONN_F_FWD_MASK 0x0007
82#define IP_VS_CONN_F_MASQ 0x0000
83#define IP_VS_CONN_F_LOCALNODE 0x0001
84#define IP_VS_CONN_F_TUNNEL 0x0002
85#define IP_VS_CONN_F_DROUTE 0x0003
86#define IP_VS_CONN_F_BYPASS 0x0004
87#define IP_VS_CONN_F_SYNC 0x0020
88#define IP_VS_CONN_F_HASHED 0x0040
89#define IP_VS_CONN_F_NOOUTPUT 0x0080
90#define IP_VS_CONN_F_INACTIVE 0x0100
91#define IP_VS_CONN_F_OUT_SEQ 0x0200
92#define IP_VS_CONN_F_IN_SEQ 0x0400
93#define IP_VS_CONN_F_SEQ_MASK 0x0600
94#define IP_VS_CONN_F_NO_CPORT 0x0800
95#define IP_VS_CONN_F_TEMPLATE 0x1000
96#define IP_VS_CONN_F_ONE_PACKET 0x2000
97
98
99#define IP_VS_CONN_F_BACKUP_MASK (IP_VS_CONN_F_FWD_MASK | \
100 IP_VS_CONN_F_NOOUTPUT | \
101 IP_VS_CONN_F_INACTIVE | \
102 IP_VS_CONN_F_SEQ_MASK | \
103 IP_VS_CONN_F_NO_CPORT | \
104 IP_VS_CONN_F_TEMPLATE \
105 )
106
107
108#define IP_VS_CONN_F_BACKUP_UPD_MASK (IP_VS_CONN_F_INACTIVE | \
109 IP_VS_CONN_F_SEQ_MASK)
110
111
112#define IP_VS_CONN_F_NFCT (1 << 16)
113
114
115#define IP_VS_CONN_F_DEST_MASK (IP_VS_CONN_F_FWD_MASK | \
116 IP_VS_CONN_F_ONE_PACKET | \
117 IP_VS_CONN_F_NFCT | \
118 0)
119
120#define IP_VS_SCHEDNAME_MAXLEN 16
121#define IP_VS_PENAME_MAXLEN 16
122#define IP_VS_IFNAME_MAXLEN 16
123
124#define IP_VS_PEDATA_MAXLEN 255
125
126
127
128
129
130struct ip_vs_service_user {
131
132 __u16 protocol;
133 __be32 addr;
134 __be16 port;
135 __u32 fwmark;
136
137
138 char sched_name[IP_VS_SCHEDNAME_MAXLEN];
139 unsigned int flags;
140 unsigned int timeout;
141 __be32 netmask;
142};
143
144
145struct ip_vs_dest_user {
146
147 __be32 addr;
148 __be16 port;
149
150
151 unsigned int conn_flags;
152 int weight;
153
154
155 __u32 u_threshold;
156 __u32 l_threshold;
157};
158
159
160
161
162
163struct ip_vs_stats_user {
164 __u32 conns;
165 __u32 inpkts;
166 __u32 outpkts;
167 __u64 inbytes;
168 __u64 outbytes;
169
170 __u32 cps;
171 __u32 inpps;
172 __u32 outpps;
173 __u32 inbps;
174 __u32 outbps;
175};
176
177
178
179struct ip_vs_getinfo {
180
181 unsigned int version;
182
183
184 unsigned int size;
185
186
187 unsigned int num_services;
188};
189
190
191
192struct ip_vs_service_entry {
193
194 __u16 protocol;
195 __be32 addr;
196 __be16 port;
197 __u32 fwmark;
198
199
200 char sched_name[IP_VS_SCHEDNAME_MAXLEN];
201 unsigned int flags;
202 unsigned int timeout;
203 __be32 netmask;
204
205
206 unsigned int num_dests;
207
208
209 struct ip_vs_stats_user stats;
210};
211
212
213struct ip_vs_dest_entry {
214 __be32 addr;
215 __be16 port;
216 unsigned int conn_flags;
217 int weight;
218
219 __u32 u_threshold;
220 __u32 l_threshold;
221
222 __u32 activeconns;
223 __u32 inactconns;
224 __u32 persistconns;
225
226
227 struct ip_vs_stats_user stats;
228};
229
230
231
232struct ip_vs_get_dests {
233
234 __u16 protocol;
235 __be32 addr;
236 __be16 port;
237 __u32 fwmark;
238
239
240 unsigned int num_dests;
241
242
243 struct ip_vs_dest_entry entrytable[0];
244};
245
246
247
248struct ip_vs_get_services {
249
250 unsigned int num_services;
251
252
253 struct ip_vs_service_entry entrytable[0];
254};
255
256
257
258struct ip_vs_timeout_user {
259 int tcp_timeout;
260 int tcp_fin_timeout;
261 int udp_timeout;
262};
263
264
265
266struct ip_vs_daemon_user {
267
268 int state;
269
270
271 char mcast_ifn[IP_VS_IFNAME_MAXLEN];
272
273
274 int syncid;
275};
276
277
278
279
280
281
282
283
284
285#define IPVS_GENL_NAME "IPVS"
286#define IPVS_GENL_VERSION 0x1
287
288struct ip_vs_flags {
289 __u32 flags;
290 __u32 mask;
291};
292
293
294enum {
295 IPVS_CMD_UNSPEC = 0,
296
297 IPVS_CMD_NEW_SERVICE,
298 IPVS_CMD_SET_SERVICE,
299 IPVS_CMD_DEL_SERVICE,
300 IPVS_CMD_GET_SERVICE,
301
302 IPVS_CMD_NEW_DEST,
303 IPVS_CMD_SET_DEST,
304 IPVS_CMD_DEL_DEST,
305 IPVS_CMD_GET_DEST,
306
307 IPVS_CMD_NEW_DAEMON,
308 IPVS_CMD_DEL_DAEMON,
309 IPVS_CMD_GET_DAEMON,
310
311 IPVS_CMD_SET_CONFIG,
312 IPVS_CMD_GET_CONFIG,
313
314 IPVS_CMD_SET_INFO,
315 IPVS_CMD_GET_INFO,
316
317 IPVS_CMD_ZERO,
318 IPVS_CMD_FLUSH,
319
320 __IPVS_CMD_MAX,
321};
322
323#define IPVS_CMD_MAX (__IPVS_CMD_MAX - 1)
324
325
326enum {
327 IPVS_CMD_ATTR_UNSPEC = 0,
328 IPVS_CMD_ATTR_SERVICE,
329 IPVS_CMD_ATTR_DEST,
330 IPVS_CMD_ATTR_DAEMON,
331 IPVS_CMD_ATTR_TIMEOUT_TCP,
332 IPVS_CMD_ATTR_TIMEOUT_TCP_FIN,
333 IPVS_CMD_ATTR_TIMEOUT_UDP,
334 __IPVS_CMD_ATTR_MAX,
335};
336
337#define IPVS_CMD_ATTR_MAX (__IPVS_SVC_ATTR_MAX - 1)
338
339
340
341
342
343
344enum {
345 IPVS_SVC_ATTR_UNSPEC = 0,
346 IPVS_SVC_ATTR_AF,
347 IPVS_SVC_ATTR_PROTOCOL,
348 IPVS_SVC_ATTR_ADDR,
349 IPVS_SVC_ATTR_PORT,
350 IPVS_SVC_ATTR_FWMARK,
351
352 IPVS_SVC_ATTR_SCHED_NAME,
353 IPVS_SVC_ATTR_FLAGS,
354 IPVS_SVC_ATTR_TIMEOUT,
355 IPVS_SVC_ATTR_NETMASK,
356
357 IPVS_SVC_ATTR_STATS,
358
359 IPVS_SVC_ATTR_PE_NAME,
360
361 __IPVS_SVC_ATTR_MAX,
362};
363
364#define IPVS_SVC_ATTR_MAX (__IPVS_SVC_ATTR_MAX - 1)
365
366
367
368
369
370
371enum {
372 IPVS_DEST_ATTR_UNSPEC = 0,
373 IPVS_DEST_ATTR_ADDR,
374 IPVS_DEST_ATTR_PORT,
375
376 IPVS_DEST_ATTR_FWD_METHOD,
377 IPVS_DEST_ATTR_WEIGHT,
378
379 IPVS_DEST_ATTR_U_THRESH,
380 IPVS_DEST_ATTR_L_THRESH,
381
382 IPVS_DEST_ATTR_ACTIVE_CONNS,
383 IPVS_DEST_ATTR_INACT_CONNS,
384 IPVS_DEST_ATTR_PERSIST_CONNS,
385
386 IPVS_DEST_ATTR_STATS,
387 __IPVS_DEST_ATTR_MAX,
388};
389
390#define IPVS_DEST_ATTR_MAX (__IPVS_DEST_ATTR_MAX - 1)
391
392
393
394
395
396
397enum {
398 IPVS_DAEMON_ATTR_UNSPEC = 0,
399 IPVS_DAEMON_ATTR_STATE,
400 IPVS_DAEMON_ATTR_MCAST_IFN,
401 IPVS_DAEMON_ATTR_SYNC_ID,
402 __IPVS_DAEMON_ATTR_MAX,
403};
404
405#define IPVS_DAEMON_ATTR_MAX (__IPVS_DAEMON_ATTR_MAX - 1)
406
407
408
409
410
411
412enum {
413 IPVS_STATS_ATTR_UNSPEC = 0,
414 IPVS_STATS_ATTR_CONNS,
415 IPVS_STATS_ATTR_INPKTS,
416 IPVS_STATS_ATTR_OUTPKTS,
417 IPVS_STATS_ATTR_INBYTES,
418 IPVS_STATS_ATTR_OUTBYTES,
419
420 IPVS_STATS_ATTR_CPS,
421 IPVS_STATS_ATTR_INPPS,
422 IPVS_STATS_ATTR_OUTPPS,
423 IPVS_STATS_ATTR_INBPS,
424 IPVS_STATS_ATTR_OUTBPS,
425 __IPVS_STATS_ATTR_MAX,
426};
427
428#define IPVS_STATS_ATTR_MAX (__IPVS_STATS_ATTR_MAX - 1)
429
430
431enum {
432 IPVS_INFO_ATTR_UNSPEC = 0,
433 IPVS_INFO_ATTR_VERSION,
434 IPVS_INFO_ATTR_CONN_TAB_SIZE,
435 __IPVS_INFO_ATTR_MAX,
436};
437
438#define IPVS_INFO_ATTR_MAX (__IPVS_INFO_ATTR_MAX - 1)
439
440#endif
441