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