]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/uapi/linux/ip_vs.h
Merge tag 'for-linus-20171120' of git://git.infradead.org/linux-mtd
[mirror_ubuntu-bionic-kernel.git] / include / uapi / linux / ip_vs.h
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3 * IP Virtual Server
4 * data structure and functionality definitions
5 */
6
7 #ifndef _IP_VS_H
8 #define _IP_VS_H
9
10 #include <linux/types.h> /* For __beXX types in userland */
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 * Virtual Service Flags
20 */
21 #define IP_VS_SVC_F_PERSISTENT 0x0001 /* persistent port */
22 #define IP_VS_SVC_F_HASHED 0x0002 /* hashed entry */
23 #define IP_VS_SVC_F_ONEPACKET 0x0004 /* one-packet scheduling */
24 #define IP_VS_SVC_F_SCHED1 0x0008 /* scheduler flag 1 */
25 #define IP_VS_SVC_F_SCHED2 0x0010 /* scheduler flag 2 */
26 #define IP_VS_SVC_F_SCHED3 0x0020 /* scheduler flag 3 */
27
28 #define IP_VS_SVC_F_SCHED_SH_FALLBACK IP_VS_SVC_F_SCHED1 /* SH fallback */
29 #define IP_VS_SVC_F_SCHED_SH_PORT IP_VS_SVC_F_SCHED2 /* SH use port */
30
31 /*
32 * Destination Server Flags
33 */
34 #define IP_VS_DEST_F_AVAILABLE 0x0001 /* server is available */
35 #define IP_VS_DEST_F_OVERLOAD 0x0002 /* server is overloaded */
36
37 /*
38 * IPVS sync daemon states
39 */
40 #define IP_VS_STATE_NONE 0x0000 /* daemon is stopped */
41 #define IP_VS_STATE_MASTER 0x0001 /* started as master */
42 #define IP_VS_STATE_BACKUP 0x0002 /* started as backup */
43
44 /*
45 * IPVS socket options
46 */
47 #define IP_VS_BASE_CTL (64+1024+64) /* base */
48
49 #define IP_VS_SO_SET_NONE IP_VS_BASE_CTL /* just peek */
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) /* not used now */
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 * IPVS Connection Flags
80 * Only flags 0..15 are sent to backup server
81 */
82 #define IP_VS_CONN_F_FWD_MASK 0x0007 /* mask for the fwd methods */
83 #define IP_VS_CONN_F_MASQ 0x0000 /* masquerading/NAT */
84 #define IP_VS_CONN_F_LOCALNODE 0x0001 /* local node */
85 #define IP_VS_CONN_F_TUNNEL 0x0002 /* tunneling */
86 #define IP_VS_CONN_F_DROUTE 0x0003 /* direct routing */
87 #define IP_VS_CONN_F_BYPASS 0x0004 /* cache bypass */
88 #define IP_VS_CONN_F_SYNC 0x0020 /* entry created by sync */
89 #define IP_VS_CONN_F_HASHED 0x0040 /* hashed entry */
90 #define IP_VS_CONN_F_NOOUTPUT 0x0080 /* no output packets */
91 #define IP_VS_CONN_F_INACTIVE 0x0100 /* not established */
92 #define IP_VS_CONN_F_OUT_SEQ 0x0200 /* must do output seq adjust */
93 #define IP_VS_CONN_F_IN_SEQ 0x0400 /* must do input seq adjust */
94 #define IP_VS_CONN_F_SEQ_MASK 0x0600 /* in/out sequence mask */
95 #define IP_VS_CONN_F_NO_CPORT 0x0800 /* no client port set yet */
96 #define IP_VS_CONN_F_TEMPLATE 0x1000 /* template, not connection */
97 #define IP_VS_CONN_F_ONE_PACKET 0x2000 /* forward only one packet */
98
99 /* Initial bits allowed in backup server */
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 /* Bits allowed to update in backup server */
109 #define IP_VS_CONN_F_BACKUP_UPD_MASK (IP_VS_CONN_F_INACTIVE | \
110 IP_VS_CONN_F_SEQ_MASK)
111
112 /* Flags that are not sent to backup server start from bit 16 */
113 #define IP_VS_CONN_F_NFCT (1 << 16) /* use netfilter conntrack */
114
115 /* Connection flags from destination that can be changed by user space */
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 * The struct ip_vs_service_user and struct ip_vs_dest_user are
129 * used to set IPVS rules through setsockopt.
130 */
131 struct ip_vs_service_user {
132 /* virtual service addresses */
133 __u16 protocol;
134 __be32 addr; /* virtual ip address */
135 __be16 port;
136 __u32 fwmark; /* firwall mark of service */
137
138 /* virtual service options */
139 char sched_name[IP_VS_SCHEDNAME_MAXLEN];
140 unsigned int flags; /* virtual service flags */
141 unsigned int timeout; /* persistent timeout in sec */
142 __be32 netmask; /* persistent netmask */
143 };
144
145
146 struct ip_vs_dest_user {
147 /* destination server address */
148 __be32 addr;
149 __be16 port;
150
151 /* real server options */
152 unsigned int conn_flags; /* connection flags */
153 int weight; /* destination weight */
154
155 /* thresholds for active connections */
156 __u32 u_threshold; /* upper threshold */
157 __u32 l_threshold; /* lower threshold */
158 };
159
160
161 /*
162 * IPVS statistics object (for user space)
163 */
164 struct ip_vs_stats_user {
165 __u32 conns; /* connections scheduled */
166 __u32 inpkts; /* incoming packets */
167 __u32 outpkts; /* outgoing packets */
168 __u64 inbytes; /* incoming bytes */
169 __u64 outbytes; /* outgoing bytes */
170
171 __u32 cps; /* current connection rate */
172 __u32 inpps; /* current in packet rate */
173 __u32 outpps; /* current out packet rate */
174 __u32 inbps; /* current in byte rate */
175 __u32 outbps; /* current out byte rate */
176 };
177
178
179 /* The argument to IP_VS_SO_GET_INFO */
180 struct ip_vs_getinfo {
181 /* version number */
182 unsigned int version;
183
184 /* size of connection hash table */
185 unsigned int size;
186
187 /* number of virtual services */
188 unsigned int num_services;
189 };
190
191
192 /* The argument to IP_VS_SO_GET_SERVICE */
193 struct ip_vs_service_entry {
194 /* which service: user fills in these */
195 __u16 protocol;
196 __be32 addr; /* virtual address */
197 __be16 port;
198 __u32 fwmark; /* firwall mark of service */
199
200 /* service options */
201 char sched_name[IP_VS_SCHEDNAME_MAXLEN];
202 unsigned int flags; /* virtual service flags */
203 unsigned int timeout; /* persistent timeout */
204 __be32 netmask; /* persistent netmask */
205
206 /* number of real servers */
207 unsigned int num_dests;
208
209 /* statistics */
210 struct ip_vs_stats_user stats;
211 };
212
213
214 struct ip_vs_dest_entry {
215 __be32 addr; /* destination address */
216 __be16 port;
217 unsigned int conn_flags; /* connection flags */
218 int weight; /* destination weight */
219
220 __u32 u_threshold; /* upper threshold */
221 __u32 l_threshold; /* lower threshold */
222
223 __u32 activeconns; /* active connections */
224 __u32 inactconns; /* inactive connections */
225 __u32 persistconns; /* persistent connections */
226
227 /* statistics */
228 struct ip_vs_stats_user stats;
229 };
230
231
232 /* The argument to IP_VS_SO_GET_DESTS */
233 struct ip_vs_get_dests {
234 /* which service: user fills in these */
235 __u16 protocol;
236 __be32 addr; /* virtual address */
237 __be16 port;
238 __u32 fwmark; /* firwall mark of service */
239
240 /* number of real servers */
241 unsigned int num_dests;
242
243 /* the real servers */
244 struct ip_vs_dest_entry entrytable[0];
245 };
246
247
248 /* The argument to IP_VS_SO_GET_SERVICES */
249 struct ip_vs_get_services {
250 /* number of virtual services */
251 unsigned int num_services;
252
253 /* service table */
254 struct ip_vs_service_entry entrytable[0];
255 };
256
257
258 /* The argument to IP_VS_SO_GET_TIMEOUT */
259 struct ip_vs_timeout_user {
260 int tcp_timeout;
261 int tcp_fin_timeout;
262 int udp_timeout;
263 };
264
265
266 /* The argument to IP_VS_SO_GET_DAEMON */
267 struct ip_vs_daemon_user {
268 /* sync daemon state (master/backup) */
269 int state;
270
271 /* multicast interface name */
272 char mcast_ifn[IP_VS_IFNAME_MAXLEN];
273
274 /* SyncID we belong to */
275 int syncid;
276 };
277
278 /*
279 *
280 * IPVS Generic Netlink interface definitions
281 *
282 */
283
284 /* Generic Netlink family info */
285
286 #define IPVS_GENL_NAME "IPVS"
287 #define IPVS_GENL_VERSION 0x1
288
289 struct ip_vs_flags {
290 __u32 flags;
291 __u32 mask;
292 };
293
294 /* Generic Netlink command attributes */
295 enum {
296 IPVS_CMD_UNSPEC = 0,
297
298 IPVS_CMD_NEW_SERVICE, /* add service */
299 IPVS_CMD_SET_SERVICE, /* modify service */
300 IPVS_CMD_DEL_SERVICE, /* delete service */
301 IPVS_CMD_GET_SERVICE, /* get service info */
302
303 IPVS_CMD_NEW_DEST, /* add destination */
304 IPVS_CMD_SET_DEST, /* modify destination */
305 IPVS_CMD_DEL_DEST, /* delete destination */
306 IPVS_CMD_GET_DEST, /* get destination info */
307
308 IPVS_CMD_NEW_DAEMON, /* start sync daemon */
309 IPVS_CMD_DEL_DAEMON, /* stop sync daemon */
310 IPVS_CMD_GET_DAEMON, /* get sync daemon status */
311
312 IPVS_CMD_SET_CONFIG, /* set config settings */
313 IPVS_CMD_GET_CONFIG, /* get config settings */
314
315 IPVS_CMD_SET_INFO, /* only used in GET_INFO reply */
316 IPVS_CMD_GET_INFO, /* get general IPVS info */
317
318 IPVS_CMD_ZERO, /* zero all counters and stats */
319 IPVS_CMD_FLUSH, /* flush services and dests */
320
321 __IPVS_CMD_MAX,
322 };
323
324 #define IPVS_CMD_MAX (__IPVS_CMD_MAX - 1)
325
326 /* Attributes used in the first level of commands */
327 enum {
328 IPVS_CMD_ATTR_UNSPEC = 0,
329 IPVS_CMD_ATTR_SERVICE, /* nested service attribute */
330 IPVS_CMD_ATTR_DEST, /* nested destination attribute */
331 IPVS_CMD_ATTR_DAEMON, /* nested sync daemon attribute */
332 IPVS_CMD_ATTR_TIMEOUT_TCP, /* TCP connection timeout */
333 IPVS_CMD_ATTR_TIMEOUT_TCP_FIN, /* TCP FIN wait timeout */
334 IPVS_CMD_ATTR_TIMEOUT_UDP, /* UDP timeout */
335 __IPVS_CMD_ATTR_MAX,
336 };
337
338 #define IPVS_CMD_ATTR_MAX (__IPVS_CMD_ATTR_MAX - 1)
339
340 /*
341 * Attributes used to describe a service
342 *
343 * Used inside nested attribute IPVS_CMD_ATTR_SERVICE
344 */
345 enum {
346 IPVS_SVC_ATTR_UNSPEC = 0,
347 IPVS_SVC_ATTR_AF, /* address family */
348 IPVS_SVC_ATTR_PROTOCOL, /* virtual service protocol */
349 IPVS_SVC_ATTR_ADDR, /* virtual service address */
350 IPVS_SVC_ATTR_PORT, /* virtual service port */
351 IPVS_SVC_ATTR_FWMARK, /* firewall mark of service */
352
353 IPVS_SVC_ATTR_SCHED_NAME, /* name of scheduler */
354 IPVS_SVC_ATTR_FLAGS, /* virtual service flags */
355 IPVS_SVC_ATTR_TIMEOUT, /* persistent timeout */
356 IPVS_SVC_ATTR_NETMASK, /* persistent netmask */
357
358 IPVS_SVC_ATTR_STATS, /* nested attribute for service stats */
359
360 IPVS_SVC_ATTR_PE_NAME, /* name of ct retriever */
361
362 IPVS_SVC_ATTR_STATS64, /* nested attribute for service stats */
363
364 __IPVS_SVC_ATTR_MAX,
365 };
366
367 #define IPVS_SVC_ATTR_MAX (__IPVS_SVC_ATTR_MAX - 1)
368
369 /*
370 * Attributes used to describe a destination (real server)
371 *
372 * Used inside nested attribute IPVS_CMD_ATTR_DEST
373 */
374 enum {
375 IPVS_DEST_ATTR_UNSPEC = 0,
376 IPVS_DEST_ATTR_ADDR, /* real server address */
377 IPVS_DEST_ATTR_PORT, /* real server port */
378
379 IPVS_DEST_ATTR_FWD_METHOD, /* forwarding method */
380 IPVS_DEST_ATTR_WEIGHT, /* destination weight */
381
382 IPVS_DEST_ATTR_U_THRESH, /* upper threshold */
383 IPVS_DEST_ATTR_L_THRESH, /* lower threshold */
384
385 IPVS_DEST_ATTR_ACTIVE_CONNS, /* active connections */
386 IPVS_DEST_ATTR_INACT_CONNS, /* inactive connections */
387 IPVS_DEST_ATTR_PERSIST_CONNS, /* persistent connections */
388
389 IPVS_DEST_ATTR_STATS, /* nested attribute for dest stats */
390
391 IPVS_DEST_ATTR_ADDR_FAMILY, /* Address family of address */
392
393 IPVS_DEST_ATTR_STATS64, /* nested attribute for dest stats */
394
395 __IPVS_DEST_ATTR_MAX,
396 };
397
398 #define IPVS_DEST_ATTR_MAX (__IPVS_DEST_ATTR_MAX - 1)
399
400 /*
401 * Attributes describing a sync daemon
402 *
403 * Used inside nested attribute IPVS_CMD_ATTR_DAEMON
404 */
405 enum {
406 IPVS_DAEMON_ATTR_UNSPEC = 0,
407 IPVS_DAEMON_ATTR_STATE, /* sync daemon state (master/backup) */
408 IPVS_DAEMON_ATTR_MCAST_IFN, /* multicast interface name */
409 IPVS_DAEMON_ATTR_SYNC_ID, /* SyncID we belong to */
410 IPVS_DAEMON_ATTR_SYNC_MAXLEN, /* UDP Payload Size */
411 IPVS_DAEMON_ATTR_MCAST_GROUP, /* IPv4 Multicast Address */
412 IPVS_DAEMON_ATTR_MCAST_GROUP6, /* IPv6 Multicast Address */
413 IPVS_DAEMON_ATTR_MCAST_PORT, /* Multicast Port (base) */
414 IPVS_DAEMON_ATTR_MCAST_TTL, /* Multicast TTL */
415 __IPVS_DAEMON_ATTR_MAX,
416 };
417
418 #define IPVS_DAEMON_ATTR_MAX (__IPVS_DAEMON_ATTR_MAX - 1)
419
420 /*
421 * Attributes used to describe service or destination entry statistics
422 *
423 * Used inside nested attributes IPVS_SVC_ATTR_STATS, IPVS_DEST_ATTR_STATS,
424 * IPVS_SVC_ATTR_STATS64 and IPVS_DEST_ATTR_STATS64.
425 */
426 enum {
427 IPVS_STATS_ATTR_UNSPEC = 0,
428 IPVS_STATS_ATTR_CONNS, /* connections scheduled */
429 IPVS_STATS_ATTR_INPKTS, /* incoming packets */
430 IPVS_STATS_ATTR_OUTPKTS, /* outgoing packets */
431 IPVS_STATS_ATTR_INBYTES, /* incoming bytes */
432 IPVS_STATS_ATTR_OUTBYTES, /* outgoing bytes */
433
434 IPVS_STATS_ATTR_CPS, /* current connection rate */
435 IPVS_STATS_ATTR_INPPS, /* current in packet rate */
436 IPVS_STATS_ATTR_OUTPPS, /* current out packet rate */
437 IPVS_STATS_ATTR_INBPS, /* current in byte rate */
438 IPVS_STATS_ATTR_OUTBPS, /* current out byte rate */
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 /* Attributes used in response to IPVS_CMD_GET_INFO command */
446 enum {
447 IPVS_INFO_ATTR_UNSPEC = 0,
448 IPVS_INFO_ATTR_VERSION, /* IPVS version number */
449 IPVS_INFO_ATTR_CONN_TAB_SIZE, /* size of connection hash table */
450 __IPVS_INFO_ATTR_MAX,
451 };
452
453 #define IPVS_INFO_ATTR_MAX (__IPVS_INFO_ATTR_MAX - 1)
454
455 #endif /* _IP_VS_H */