netfilter: nf_tables: add set timeout API support
[linux-2.6-block.git] / include / uapi / linux / netfilter / nf_tables.h
CommitLineData
96518518
PM
1#ifndef _LINUX_NF_TABLES_H
2#define _LINUX_NF_TABLES_H
3
1cae565e 4#define NFT_TABLE_MAXNAMELEN 32
0768b3b3
PNA
5#define NFT_CHAIN_MAXNAMELEN 32
6#define NFT_USERDATA_MAXLEN 256
96518518
PM
7
8enum nft_registers {
9 NFT_REG_VERDICT,
10 NFT_REG_1,
11 NFT_REG_2,
12 NFT_REG_3,
13 NFT_REG_4,
14 __NFT_REG_MAX
15};
16#define NFT_REG_MAX (__NFT_REG_MAX - 1)
17
18/**
19 * enum nft_verdicts - nf_tables internal verdicts
20 *
21 * @NFT_CONTINUE: continue evaluation of the current rule
22 * @NFT_BREAK: terminate evaluation of the current rule
23 * @NFT_JUMP: push the current chain on the jump stack and jump to a chain
24 * @NFT_GOTO: jump to a chain without pushing the current chain on the jump stack
25 * @NFT_RETURN: return to the topmost chain on the jump stack
26 *
27 * The nf_tables verdicts share their numeric space with the netfilter verdicts.
28 */
29enum nft_verdicts {
30 NFT_CONTINUE = -1,
31 NFT_BREAK = -2,
32 NFT_JUMP = -3,
33 NFT_GOTO = -4,
34 NFT_RETURN = -5,
35};
36
37/**
38 * enum nf_tables_msg_types - nf_tables netlink message types
39 *
40 * @NFT_MSG_NEWTABLE: create a new table (enum nft_table_attributes)
41 * @NFT_MSG_GETTABLE: get a table (enum nft_table_attributes)
42 * @NFT_MSG_DELTABLE: delete a table (enum nft_table_attributes)
43 * @NFT_MSG_NEWCHAIN: create a new chain (enum nft_chain_attributes)
44 * @NFT_MSG_GETCHAIN: get a chain (enum nft_chain_attributes)
45 * @NFT_MSG_DELCHAIN: delete a chain (enum nft_chain_attributes)
46 * @NFT_MSG_NEWRULE: create a new rule (enum nft_rule_attributes)
47 * @NFT_MSG_GETRULE: get a rule (enum nft_rule_attributes)
48 * @NFT_MSG_DELRULE: delete a rule (enum nft_rule_attributes)
20a69341
PM
49 * @NFT_MSG_NEWSET: create a new set (enum nft_set_attributes)
50 * @NFT_MSG_GETSET: get a set (enum nft_set_attributes)
51 * @NFT_MSG_DELSET: delete a set (enum nft_set_attributes)
52 * @NFT_MSG_NEWSETELEM: create a new set element (enum nft_set_elem_attributes)
53 * @NFT_MSG_GETSETELEM: get a set element (enum nft_set_elem_attributes)
54 * @NFT_MSG_DELSETELEM: delete a set element (enum nft_set_elem_attributes)
84d7fce6
PNA
55 * @NFT_MSG_NEWGEN: announce a new generation, only for events (enum nft_gen_attributes)
56 * @NFT_MSG_GETGEN: get the rule-set generation (enum nft_gen_attributes)
96518518
PM
57 */
58enum nf_tables_msg_types {
59 NFT_MSG_NEWTABLE,
60 NFT_MSG_GETTABLE,
61 NFT_MSG_DELTABLE,
62 NFT_MSG_NEWCHAIN,
63 NFT_MSG_GETCHAIN,
64 NFT_MSG_DELCHAIN,
65 NFT_MSG_NEWRULE,
66 NFT_MSG_GETRULE,
67 NFT_MSG_DELRULE,
20a69341
PM
68 NFT_MSG_NEWSET,
69 NFT_MSG_GETSET,
70 NFT_MSG_DELSET,
71 NFT_MSG_NEWSETELEM,
72 NFT_MSG_GETSETELEM,
73 NFT_MSG_DELSETELEM,
84d7fce6
PNA
74 NFT_MSG_NEWGEN,
75 NFT_MSG_GETGEN,
96518518
PM
76 NFT_MSG_MAX,
77};
78
20a69341
PM
79/**
80 * enum nft_list_attributes - nf_tables generic list netlink attributes
81 *
82 * @NFTA_LIST_ELEM: list element (NLA_NESTED)
83 */
96518518
PM
84enum nft_list_attributes {
85 NFTA_LIST_UNPEC,
86 NFTA_LIST_ELEM,
87 __NFTA_LIST_MAX
88};
89#define NFTA_LIST_MAX (__NFTA_LIST_MAX - 1)
90
91/**
92 * enum nft_hook_attributes - nf_tables netfilter hook netlink attributes
93 *
94 * @NFTA_HOOK_HOOKNUM: netfilter hook number (NLA_U32)
95 * @NFTA_HOOK_PRIORITY: netfilter hook priority (NLA_U32)
96 */
97enum nft_hook_attributes {
98 NFTA_HOOK_UNSPEC,
99 NFTA_HOOK_HOOKNUM,
100 NFTA_HOOK_PRIORITY,
101 __NFTA_HOOK_MAX
102};
103#define NFTA_HOOK_MAX (__NFTA_HOOK_MAX - 1)
104
9ddf6323
PNA
105/**
106 * enum nft_table_flags - nf_tables table flags
107 *
108 * @NFT_TABLE_F_DORMANT: this table is not active
109 */
110enum nft_table_flags {
111 NFT_TABLE_F_DORMANT = 0x1,
112};
113
96518518
PM
114/**
115 * enum nft_table_attributes - nf_tables table netlink attributes
116 *
117 * @NFTA_TABLE_NAME: name of the table (NLA_STRING)
9ddf6323 118 * @NFTA_TABLE_FLAGS: bitmask of enum nft_table_flags (NLA_U32)
d8bcc768 119 * @NFTA_TABLE_USE: number of chains in this table (NLA_U32)
96518518
PM
120 */
121enum nft_table_attributes {
122 NFTA_TABLE_UNSPEC,
123 NFTA_TABLE_NAME,
9ddf6323 124 NFTA_TABLE_FLAGS,
d8bcc768 125 NFTA_TABLE_USE,
96518518
PM
126 __NFTA_TABLE_MAX
127};
128#define NFTA_TABLE_MAX (__NFTA_TABLE_MAX - 1)
129
130/**
131 * enum nft_chain_attributes - nf_tables chain netlink attributes
132 *
133 * @NFTA_CHAIN_TABLE: name of the table containing the chain (NLA_STRING)
134 * @NFTA_CHAIN_HANDLE: numeric handle of the chain (NLA_U64)
135 * @NFTA_CHAIN_NAME: name of the chain (NLA_STRING)
136 * @NFTA_CHAIN_HOOK: hook specification for basechains (NLA_NESTED: nft_hook_attributes)
0ca743a5
PNA
137 * @NFTA_CHAIN_POLICY: numeric policy of the chain (NLA_U32)
138 * @NFTA_CHAIN_USE: number of references to this chain (NLA_U32)
9370761c 139 * @NFTA_CHAIN_TYPE: type name of the string (NLA_NUL_STRING)
0ca743a5 140 * @NFTA_CHAIN_COUNTERS: counter specification of the chain (NLA_NESTED: nft_counter_attributes)
96518518
PM
141 */
142enum nft_chain_attributes {
143 NFTA_CHAIN_UNSPEC,
144 NFTA_CHAIN_TABLE,
145 NFTA_CHAIN_HANDLE,
146 NFTA_CHAIN_NAME,
147 NFTA_CHAIN_HOOK,
0ca743a5
PNA
148 NFTA_CHAIN_POLICY,
149 NFTA_CHAIN_USE,
9370761c 150 NFTA_CHAIN_TYPE,
0ca743a5 151 NFTA_CHAIN_COUNTERS,
96518518
PM
152 __NFTA_CHAIN_MAX
153};
154#define NFTA_CHAIN_MAX (__NFTA_CHAIN_MAX - 1)
155
156/**
157 * enum nft_rule_attributes - nf_tables rule netlink attributes
158 *
159 * @NFTA_RULE_TABLE: name of the table containing the rule (NLA_STRING)
160 * @NFTA_RULE_CHAIN: name of the chain containing the rule (NLA_STRING)
161 * @NFTA_RULE_HANDLE: numeric handle of the rule (NLA_U64)
162 * @NFTA_RULE_EXPRESSIONS: list of expressions (NLA_NESTED: nft_expr_attributes)
0ca743a5 163 * @NFTA_RULE_COMPAT: compatibility specifications of the rule (NLA_NESTED: nft_rule_compat_attributes)
5e948466 164 * @NFTA_RULE_POSITION: numeric handle of the previous rule (NLA_U64)
0768b3b3 165 * @NFTA_RULE_USERDATA: user data (NLA_BINARY, NFT_USERDATA_MAXLEN)
96518518
PM
166 */
167enum nft_rule_attributes {
168 NFTA_RULE_UNSPEC,
169 NFTA_RULE_TABLE,
170 NFTA_RULE_CHAIN,
171 NFTA_RULE_HANDLE,
172 NFTA_RULE_EXPRESSIONS,
0ca743a5 173 NFTA_RULE_COMPAT,
5e948466 174 NFTA_RULE_POSITION,
0768b3b3 175 NFTA_RULE_USERDATA,
96518518
PM
176 __NFTA_RULE_MAX
177};
178#define NFTA_RULE_MAX (__NFTA_RULE_MAX - 1)
179
0ca743a5
PNA
180/**
181 * enum nft_rule_compat_flags - nf_tables rule compat flags
182 *
183 * @NFT_RULE_COMPAT_F_INV: invert the check result
184 */
185enum nft_rule_compat_flags {
186 NFT_RULE_COMPAT_F_INV = (1 << 1),
187 NFT_RULE_COMPAT_F_MASK = NFT_RULE_COMPAT_F_INV,
188};
189
190/**
191 * enum nft_rule_compat_attributes - nf_tables rule compat attributes
192 *
193 * @NFTA_RULE_COMPAT_PROTO: numerice value of handled protocol (NLA_U32)
194 * @NFTA_RULE_COMPAT_FLAGS: bitmask of enum nft_rule_compat_flags (NLA_U32)
195 */
196enum nft_rule_compat_attributes {
197 NFTA_RULE_COMPAT_UNSPEC,
198 NFTA_RULE_COMPAT_PROTO,
199 NFTA_RULE_COMPAT_FLAGS,
200 __NFTA_RULE_COMPAT_MAX
201};
202#define NFTA_RULE_COMPAT_MAX (__NFTA_RULE_COMPAT_MAX - 1)
203
20a69341
PM
204/**
205 * enum nft_set_flags - nf_tables set flags
206 *
207 * @NFT_SET_ANONYMOUS: name allocation, automatic cleanup on unlink
208 * @NFT_SET_CONSTANT: set contents may not change while bound
209 * @NFT_SET_INTERVAL: set contains intervals
210 * @NFT_SET_MAP: set is used as a dictionary
761da293 211 * @NFT_SET_TIMEOUT: set uses timeouts
20a69341
PM
212 */
213enum nft_set_flags {
214 NFT_SET_ANONYMOUS = 0x1,
215 NFT_SET_CONSTANT = 0x2,
216 NFT_SET_INTERVAL = 0x4,
217 NFT_SET_MAP = 0x8,
761da293 218 NFT_SET_TIMEOUT = 0x10,
20a69341
PM
219};
220
c50b960c
PM
221/**
222 * enum nft_set_policies - set selection policy
223 *
224 * @NFT_SET_POL_PERFORMANCE: prefer high performance over low memory use
225 * @NFT_SET_POL_MEMORY: prefer low memory use over high performance
226 */
227enum nft_set_policies {
228 NFT_SET_POL_PERFORMANCE,
229 NFT_SET_POL_MEMORY,
230};
231
232/**
233 * enum nft_set_desc_attributes - set element description
234 *
235 * @NFTA_SET_DESC_SIZE: number of elements in set (NLA_U32)
236 */
237enum nft_set_desc_attributes {
238 NFTA_SET_DESC_UNSPEC,
239 NFTA_SET_DESC_SIZE,
240 __NFTA_SET_DESC_MAX
241};
242#define NFTA_SET_DESC_MAX (__NFTA_SET_DESC_MAX - 1)
243
20a69341
PM
244/**
245 * enum nft_set_attributes - nf_tables set netlink attributes
246 *
247 * @NFTA_SET_TABLE: table name (NLA_STRING)
248 * @NFTA_SET_NAME: set name (NLA_STRING)
249 * @NFTA_SET_FLAGS: bitmask of enum nft_set_flags (NLA_U32)
250 * @NFTA_SET_KEY_TYPE: key data type, informational purpose only (NLA_U32)
251 * @NFTA_SET_KEY_LEN: key data length (NLA_U32)
252 * @NFTA_SET_DATA_TYPE: mapping data type (NLA_U32)
253 * @NFTA_SET_DATA_LEN: mapping data length (NLA_U32)
c50b960c
PM
254 * @NFTA_SET_POLICY: selection policy (NLA_U32)
255 * @NFTA_SET_DESC: set description (NLA_NESTED)
958bee14 256 * @NFTA_SET_ID: uniquely identifies a set in a transaction (NLA_U32)
761da293
PM
257 * @NFTA_SET_TIMEOUT: default timeout value (NLA_U64)
258 * @NFTA_SET_GC_INTERVAL: garbage collection interval (NLA_U32)
20a69341
PM
259 */
260enum nft_set_attributes {
261 NFTA_SET_UNSPEC,
262 NFTA_SET_TABLE,
263 NFTA_SET_NAME,
264 NFTA_SET_FLAGS,
265 NFTA_SET_KEY_TYPE,
266 NFTA_SET_KEY_LEN,
267 NFTA_SET_DATA_TYPE,
268 NFTA_SET_DATA_LEN,
c50b960c
PM
269 NFTA_SET_POLICY,
270 NFTA_SET_DESC,
958bee14 271 NFTA_SET_ID,
761da293
PM
272 NFTA_SET_TIMEOUT,
273 NFTA_SET_GC_INTERVAL,
20a69341
PM
274 __NFTA_SET_MAX
275};
276#define NFTA_SET_MAX (__NFTA_SET_MAX - 1)
277
278/**
279 * enum nft_set_elem_flags - nf_tables set element flags
280 *
281 * @NFT_SET_ELEM_INTERVAL_END: element ends the previous interval
282 */
283enum nft_set_elem_flags {
284 NFT_SET_ELEM_INTERVAL_END = 0x1,
285};
286
287/**
288 * enum nft_set_elem_attributes - nf_tables set element netlink attributes
289 *
290 * @NFTA_SET_ELEM_KEY: key value (NLA_NESTED: nft_data)
291 * @NFTA_SET_ELEM_DATA: data value of mapping (NLA_NESTED: nft_data_attributes)
292 * @NFTA_SET_ELEM_FLAGS: bitmask of nft_set_elem_flags (NLA_U32)
293 */
294enum nft_set_elem_attributes {
295 NFTA_SET_ELEM_UNSPEC,
296 NFTA_SET_ELEM_KEY,
297 NFTA_SET_ELEM_DATA,
298 NFTA_SET_ELEM_FLAGS,
299 __NFTA_SET_ELEM_MAX
300};
301#define NFTA_SET_ELEM_MAX (__NFTA_SET_ELEM_MAX - 1)
302
303/**
304 * enum nft_set_elem_list_attributes - nf_tables set element list netlink attributes
305 *
306 * @NFTA_SET_ELEM_LIST_TABLE: table of the set to be changed (NLA_STRING)
307 * @NFTA_SET_ELEM_LIST_SET: name of the set to be changed (NLA_STRING)
308 * @NFTA_SET_ELEM_LIST_ELEMENTS: list of set elements (NLA_NESTED: nft_set_elem_attributes)
958bee14 309 * @NFTA_SET_ELEM_LIST_SET_ID: uniquely identifies a set in a transaction (NLA_U32)
20a69341
PM
310 */
311enum nft_set_elem_list_attributes {
312 NFTA_SET_ELEM_LIST_UNSPEC,
313 NFTA_SET_ELEM_LIST_TABLE,
314 NFTA_SET_ELEM_LIST_SET,
315 NFTA_SET_ELEM_LIST_ELEMENTS,
958bee14 316 NFTA_SET_ELEM_LIST_SET_ID,
20a69341
PM
317 __NFTA_SET_ELEM_LIST_MAX
318};
319#define NFTA_SET_ELEM_LIST_MAX (__NFTA_SET_ELEM_LIST_MAX - 1)
320
321/**
322 * enum nft_data_types - nf_tables data types
323 *
324 * @NFT_DATA_VALUE: generic data
325 * @NFT_DATA_VERDICT: netfilter verdict
326 *
327 * The type of data is usually determined by the kernel directly and is not
328 * explicitly specified by userspace. The only difference are sets, where
329 * userspace specifies the key and mapping data types.
330 *
331 * The values 0xffffff00-0xffffffff are reserved for internally used types.
332 * The remaining range can be freely used by userspace to encode types, all
333 * values are equivalent to NFT_DATA_VALUE.
334 */
335enum nft_data_types {
336 NFT_DATA_VALUE,
337 NFT_DATA_VERDICT = 0xffffff00U,
338};
339
340#define NFT_DATA_RESERVED_MASK 0xffffff00U
341
342/**
343 * enum nft_data_attributes - nf_tables data netlink attributes
344 *
345 * @NFTA_DATA_VALUE: generic data (NLA_BINARY)
346 * @NFTA_DATA_VERDICT: nf_tables verdict (NLA_NESTED: nft_verdict_attributes)
347 */
96518518
PM
348enum nft_data_attributes {
349 NFTA_DATA_UNSPEC,
350 NFTA_DATA_VALUE,
351 NFTA_DATA_VERDICT,
352 __NFTA_DATA_MAX
353};
354#define NFTA_DATA_MAX (__NFTA_DATA_MAX - 1)
355
356/**
357 * enum nft_verdict_attributes - nf_tables verdict netlink attributes
358 *
359 * @NFTA_VERDICT_CODE: nf_tables verdict (NLA_U32: enum nft_verdicts)
360 * @NFTA_VERDICT_CHAIN: jump target chain name (NLA_STRING)
361 */
362enum nft_verdict_attributes {
363 NFTA_VERDICT_UNSPEC,
364 NFTA_VERDICT_CODE,
365 NFTA_VERDICT_CHAIN,
366 __NFTA_VERDICT_MAX
367};
368#define NFTA_VERDICT_MAX (__NFTA_VERDICT_MAX - 1)
369
370/**
371 * enum nft_expr_attributes - nf_tables expression netlink attributes
372 *
373 * @NFTA_EXPR_NAME: name of the expression type (NLA_STRING)
374 * @NFTA_EXPR_DATA: type specific data (NLA_NESTED)
375 */
376enum nft_expr_attributes {
377 NFTA_EXPR_UNSPEC,
378 NFTA_EXPR_NAME,
379 NFTA_EXPR_DATA,
380 __NFTA_EXPR_MAX
381};
382#define NFTA_EXPR_MAX (__NFTA_EXPR_MAX - 1)
383
384/**
385 * enum nft_immediate_attributes - nf_tables immediate expression netlink attributes
386 *
387 * @NFTA_IMMEDIATE_DREG: destination register to load data into (NLA_U32)
388 * @NFTA_IMMEDIATE_DATA: data to load (NLA_NESTED: nft_data_attributes)
389 */
390enum nft_immediate_attributes {
391 NFTA_IMMEDIATE_UNSPEC,
392 NFTA_IMMEDIATE_DREG,
393 NFTA_IMMEDIATE_DATA,
394 __NFTA_IMMEDIATE_MAX
395};
396#define NFTA_IMMEDIATE_MAX (__NFTA_IMMEDIATE_MAX - 1)
397
398/**
399 * enum nft_bitwise_attributes - nf_tables bitwise expression netlink attributes
400 *
401 * @NFTA_BITWISE_SREG: source register (NLA_U32: nft_registers)
402 * @NFTA_BITWISE_DREG: destination register (NLA_U32: nft_registers)
403 * @NFTA_BITWISE_LEN: length of operands (NLA_U32)
404 * @NFTA_BITWISE_MASK: mask value (NLA_NESTED: nft_data_attributes)
405 * @NFTA_BITWISE_XOR: xor value (NLA_NESTED: nft_data_attributes)
406 *
407 * The bitwise expression performs the following operation:
408 *
409 * dreg = (sreg & mask) ^ xor
410 *
411 * which allow to express all bitwise operations:
412 *
413 * mask xor
414 * NOT: 1 1
415 * OR: 0 x
416 * XOR: 1 x
417 * AND: x 0
418 */
419enum nft_bitwise_attributes {
420 NFTA_BITWISE_UNSPEC,
421 NFTA_BITWISE_SREG,
422 NFTA_BITWISE_DREG,
423 NFTA_BITWISE_LEN,
424 NFTA_BITWISE_MASK,
425 NFTA_BITWISE_XOR,
426 __NFTA_BITWISE_MAX
427};
428#define NFTA_BITWISE_MAX (__NFTA_BITWISE_MAX - 1)
429
430/**
431 * enum nft_byteorder_ops - nf_tables byteorder operators
432 *
433 * @NFT_BYTEORDER_NTOH: network to host operator
434 * @NFT_BYTEORDER_HTON: host to network opertaor
435 */
436enum nft_byteorder_ops {
437 NFT_BYTEORDER_NTOH,
438 NFT_BYTEORDER_HTON,
439};
440
441/**
442 * enum nft_byteorder_attributes - nf_tables byteorder expression netlink attributes
443 *
444 * @NFTA_BYTEORDER_SREG: source register (NLA_U32: nft_registers)
445 * @NFTA_BYTEORDER_DREG: destination register (NLA_U32: nft_registers)
446 * @NFTA_BYTEORDER_OP: operator (NLA_U32: enum nft_byteorder_ops)
447 * @NFTA_BYTEORDER_LEN: length of the data (NLA_U32)
448 * @NFTA_BYTEORDER_SIZE: data size in bytes (NLA_U32: 2 or 4)
449 */
450enum nft_byteorder_attributes {
451 NFTA_BYTEORDER_UNSPEC,
452 NFTA_BYTEORDER_SREG,
453 NFTA_BYTEORDER_DREG,
454 NFTA_BYTEORDER_OP,
455 NFTA_BYTEORDER_LEN,
456 NFTA_BYTEORDER_SIZE,
457 __NFTA_BYTEORDER_MAX
458};
459#define NFTA_BYTEORDER_MAX (__NFTA_BYTEORDER_MAX - 1)
460
461/**
462 * enum nft_cmp_ops - nf_tables relational operator
463 *
464 * @NFT_CMP_EQ: equal
465 * @NFT_CMP_NEQ: not equal
466 * @NFT_CMP_LT: less than
467 * @NFT_CMP_LTE: less than or equal to
468 * @NFT_CMP_GT: greater than
469 * @NFT_CMP_GTE: greater than or equal to
470 */
471enum nft_cmp_ops {
472 NFT_CMP_EQ,
473 NFT_CMP_NEQ,
474 NFT_CMP_LT,
475 NFT_CMP_LTE,
476 NFT_CMP_GT,
477 NFT_CMP_GTE,
478};
479
480/**
481 * enum nft_cmp_attributes - nf_tables cmp expression netlink attributes
482 *
483 * @NFTA_CMP_SREG: source register of data to compare (NLA_U32: nft_registers)
484 * @NFTA_CMP_OP: cmp operation (NLA_U32: nft_cmp_ops)
485 * @NFTA_CMP_DATA: data to compare against (NLA_NESTED: nft_data_attributes)
486 */
487enum nft_cmp_attributes {
488 NFTA_CMP_UNSPEC,
489 NFTA_CMP_SREG,
490 NFTA_CMP_OP,
491 NFTA_CMP_DATA,
492 __NFTA_CMP_MAX
493};
494#define NFTA_CMP_MAX (__NFTA_CMP_MAX - 1)
495
20a69341
PM
496/**
497 * enum nft_lookup_attributes - nf_tables set lookup expression netlink attributes
498 *
499 * @NFTA_LOOKUP_SET: name of the set where to look for (NLA_STRING)
500 * @NFTA_LOOKUP_SREG: source register of the data to look for (NLA_U32: nft_registers)
501 * @NFTA_LOOKUP_DREG: destination register (NLA_U32: nft_registers)
958bee14 502 * @NFTA_LOOKUP_SET_ID: uniquely identifies a set in a transaction (NLA_U32)
20a69341
PM
503 */
504enum nft_lookup_attributes {
505 NFTA_LOOKUP_UNSPEC,
506 NFTA_LOOKUP_SET,
507 NFTA_LOOKUP_SREG,
508 NFTA_LOOKUP_DREG,
958bee14 509 NFTA_LOOKUP_SET_ID,
20a69341 510 __NFTA_LOOKUP_MAX
96518518 511};
20a69341 512#define NFTA_LOOKUP_MAX (__NFTA_LOOKUP_MAX - 1)
96518518
PM
513
514/**
515 * enum nft_payload_bases - nf_tables payload expression offset bases
516 *
517 * @NFT_PAYLOAD_LL_HEADER: link layer header
518 * @NFT_PAYLOAD_NETWORK_HEADER: network header
519 * @NFT_PAYLOAD_TRANSPORT_HEADER: transport header
520 */
521enum nft_payload_bases {
522 NFT_PAYLOAD_LL_HEADER,
523 NFT_PAYLOAD_NETWORK_HEADER,
524 NFT_PAYLOAD_TRANSPORT_HEADER,
525};
526
527/**
528 * enum nft_payload_attributes - nf_tables payload expression netlink attributes
529 *
530 * @NFTA_PAYLOAD_DREG: destination register to load data into (NLA_U32: nft_registers)
531 * @NFTA_PAYLOAD_BASE: payload base (NLA_U32: nft_payload_bases)
532 * @NFTA_PAYLOAD_OFFSET: payload offset relative to base (NLA_U32)
533 * @NFTA_PAYLOAD_LEN: payload length (NLA_U32)
534 */
535enum nft_payload_attributes {
536 NFTA_PAYLOAD_UNSPEC,
537 NFTA_PAYLOAD_DREG,
538 NFTA_PAYLOAD_BASE,
539 NFTA_PAYLOAD_OFFSET,
540 NFTA_PAYLOAD_LEN,
541 __NFTA_PAYLOAD_MAX
542};
543#define NFTA_PAYLOAD_MAX (__NFTA_PAYLOAD_MAX - 1)
544
545/**
546 * enum nft_exthdr_attributes - nf_tables IPv6 extension header expression netlink attributes
547 *
548 * @NFTA_EXTHDR_DREG: destination register (NLA_U32: nft_registers)
549 * @NFTA_EXTHDR_TYPE: extension header type (NLA_U8)
550 * @NFTA_EXTHDR_OFFSET: extension header offset (NLA_U32)
551 * @NFTA_EXTHDR_LEN: extension header length (NLA_U32)
552 */
553enum nft_exthdr_attributes {
554 NFTA_EXTHDR_UNSPEC,
555 NFTA_EXTHDR_DREG,
556 NFTA_EXTHDR_TYPE,
557 NFTA_EXTHDR_OFFSET,
558 NFTA_EXTHDR_LEN,
559 __NFTA_EXTHDR_MAX
560};
561#define NFTA_EXTHDR_MAX (__NFTA_EXTHDR_MAX - 1)
562
563/**
564 * enum nft_meta_keys - nf_tables meta expression keys
565 *
566 * @NFT_META_LEN: packet length (skb->len)
567 * @NFT_META_PROTOCOL: packet ethertype protocol (skb->protocol), invalid in OUTPUT
568 * @NFT_META_PRIORITY: packet priority (skb->priority)
569 * @NFT_META_MARK: packet mark (skb->mark)
570 * @NFT_META_IIF: packet input interface index (dev->ifindex)
571 * @NFT_META_OIF: packet output interface index (dev->ifindex)
572 * @NFT_META_IIFNAME: packet input interface name (dev->name)
573 * @NFT_META_OIFNAME: packet output interface name (dev->name)
574 * @NFT_META_IIFTYPE: packet input interface type (dev->type)
575 * @NFT_META_OIFTYPE: packet output interface type (dev->type)
576 * @NFT_META_SKUID: originating socket UID (fsuid)
577 * @NFT_META_SKGID: originating socket GID (fsgid)
578 * @NFT_META_NFTRACE: packet nftrace bit
579 * @NFT_META_RTCLASSID: realm value of packet's route (skb->dst->tclassid)
580 * @NFT_META_SECMARK: packet secmark (skb->secmark)
124edfa9 581 * @NFT_META_NFPROTO: netfilter protocol
4566bf27 582 * @NFT_META_L4PROTO: layer 4 protocol number
f5efc696
TB
583 * @NFT_META_BRI_IIFNAME: packet input bridge interface name
584 * @NFT_META_BRI_OIFNAME: packet output bridge interface name
e2a093ff 585 * @NFT_META_PKTTYPE: packet type (skb->pkt_type), special handling for loopback
afc5be30 586 * @NFT_META_CPU: cpu id through smp_processor_id()
3045d760
AR
587 * @NFT_META_IIFGROUP: packet input interface group
588 * @NFT_META_OIFGROUP: packet output interface group
ce674173 589 * @NFT_META_CGROUP: socket control group (skb->sk->sk_classid)
96518518
PM
590 */
591enum nft_meta_keys {
592 NFT_META_LEN,
593 NFT_META_PROTOCOL,
594 NFT_META_PRIORITY,
595 NFT_META_MARK,
596 NFT_META_IIF,
597 NFT_META_OIF,
598 NFT_META_IIFNAME,
599 NFT_META_OIFNAME,
600 NFT_META_IIFTYPE,
601 NFT_META_OIFTYPE,
602 NFT_META_SKUID,
603 NFT_META_SKGID,
604 NFT_META_NFTRACE,
605 NFT_META_RTCLASSID,
606 NFT_META_SECMARK,
124edfa9 607 NFT_META_NFPROTO,
4566bf27 608 NFT_META_L4PROTO,
f5efc696
TB
609 NFT_META_BRI_IIFNAME,
610 NFT_META_BRI_OIFNAME,
e2a093ff 611 NFT_META_PKTTYPE,
afc5be30 612 NFT_META_CPU,
3045d760
AR
613 NFT_META_IIFGROUP,
614 NFT_META_OIFGROUP,
ce674173 615 NFT_META_CGROUP,
96518518
PM
616};
617
618/**
619 * enum nft_meta_attributes - nf_tables meta expression netlink attributes
620 *
621 * @NFTA_META_DREG: destination register (NLA_U32)
622 * @NFTA_META_KEY: meta data item to load (NLA_U32: nft_meta_keys)
e035b77a 623 * @NFTA_META_SREG: source register (NLA_U32)
96518518
PM
624 */
625enum nft_meta_attributes {
626 NFTA_META_UNSPEC,
627 NFTA_META_DREG,
628 NFTA_META_KEY,
e035b77a 629 NFTA_META_SREG,
96518518
PM
630 __NFTA_META_MAX
631};
632#define NFTA_META_MAX (__NFTA_META_MAX - 1)
633
634/**
635 * enum nft_ct_keys - nf_tables ct expression keys
636 *
637 * @NFT_CT_STATE: conntrack state (bitmask of enum ip_conntrack_info)
638 * @NFT_CT_DIRECTION: conntrack direction (enum ip_conntrack_dir)
639 * @NFT_CT_STATUS: conntrack status (bitmask of enum ip_conntrack_status)
640 * @NFT_CT_MARK: conntrack mark value
641 * @NFT_CT_SECMARK: conntrack secmark value
642 * @NFT_CT_EXPIRATION: relative conntrack expiration time in ms
643 * @NFT_CT_HELPER: connection tracking helper assigned to conntrack
644 * @NFT_CT_L3PROTOCOL: conntrack layer 3 protocol
645 * @NFT_CT_SRC: conntrack layer 3 protocol source (IPv4/IPv6 address)
646 * @NFT_CT_DST: conntrack layer 3 protocol destination (IPv4/IPv6 address)
647 * @NFT_CT_PROTOCOL: conntrack layer 4 protocol
648 * @NFT_CT_PROTO_SRC: conntrack layer 4 protocol source
649 * @NFT_CT_PROTO_DST: conntrack layer 4 protocol destination
650 */
651enum nft_ct_keys {
652 NFT_CT_STATE,
653 NFT_CT_DIRECTION,
654 NFT_CT_STATUS,
655 NFT_CT_MARK,
656 NFT_CT_SECMARK,
657 NFT_CT_EXPIRATION,
658 NFT_CT_HELPER,
659 NFT_CT_L3PROTOCOL,
660 NFT_CT_SRC,
661 NFT_CT_DST,
662 NFT_CT_PROTOCOL,
663 NFT_CT_PROTO_SRC,
664 NFT_CT_PROTO_DST,
d2bf2f34 665 NFT_CT_LABELS,
96518518
PM
666};
667
668/**
669 * enum nft_ct_attributes - nf_tables ct expression netlink attributes
670 *
671 * @NFTA_CT_DREG: destination register (NLA_U32)
672 * @NFTA_CT_KEY: conntrack data item to load (NLA_U32: nft_ct_keys)
673 * @NFTA_CT_DIRECTION: direction in case of directional keys (NLA_U8)
c4ede3d3 674 * @NFTA_CT_SREG: source register (NLA_U32)
96518518
PM
675 */
676enum nft_ct_attributes {
677 NFTA_CT_UNSPEC,
678 NFTA_CT_DREG,
679 NFTA_CT_KEY,
680 NFTA_CT_DIRECTION,
c4ede3d3 681 NFTA_CT_SREG,
96518518
PM
682 __NFTA_CT_MAX
683};
684#define NFTA_CT_MAX (__NFTA_CT_MAX - 1)
685
686/**
687 * enum nft_limit_attributes - nf_tables limit expression netlink attributes
688 *
689 * @NFTA_LIMIT_RATE: refill rate (NLA_U64)
690 * @NFTA_LIMIT_UNIT: refill unit (NLA_U64)
691 */
692enum nft_limit_attributes {
693 NFTA_LIMIT_UNSPEC,
694 NFTA_LIMIT_RATE,
695 NFTA_LIMIT_UNIT,
696 __NFTA_LIMIT_MAX
697};
698#define NFTA_LIMIT_MAX (__NFTA_LIMIT_MAX - 1)
699
700/**
701 * enum nft_counter_attributes - nf_tables counter expression netlink attributes
702 *
703 * @NFTA_COUNTER_BYTES: number of bytes (NLA_U64)
704 * @NFTA_COUNTER_PACKETS: number of packets (NLA_U64)
705 */
706enum nft_counter_attributes {
707 NFTA_COUNTER_UNSPEC,
708 NFTA_COUNTER_BYTES,
709 NFTA_COUNTER_PACKETS,
710 __NFTA_COUNTER_MAX
711};
712#define NFTA_COUNTER_MAX (__NFTA_COUNTER_MAX - 1)
713
714/**
715 * enum nft_log_attributes - nf_tables log expression netlink attributes
716 *
717 * @NFTA_LOG_GROUP: netlink group to send messages to (NLA_U32)
718 * @NFTA_LOG_PREFIX: prefix to prepend to log messages (NLA_STRING)
719 * @NFTA_LOG_SNAPLEN: length of payload to include in netlink message (NLA_U32)
720 * @NFTA_LOG_QTHRESHOLD: queue threshold (NLA_U32)
09d27b88
PNA
721 * @NFTA_LOG_LEVEL: log level (NLA_U32)
722 * @NFTA_LOG_FLAGS: logging flags (NLA_U32)
96518518
PM
723 */
724enum nft_log_attributes {
725 NFTA_LOG_UNSPEC,
726 NFTA_LOG_GROUP,
727 NFTA_LOG_PREFIX,
728 NFTA_LOG_SNAPLEN,
729 NFTA_LOG_QTHRESHOLD,
09d27b88
PNA
730 NFTA_LOG_LEVEL,
731 NFTA_LOG_FLAGS,
96518518
PM
732 __NFTA_LOG_MAX
733};
734#define NFTA_LOG_MAX (__NFTA_LOG_MAX - 1)
735
0aff078d
EL
736/**
737 * enum nft_queue_attributes - nf_tables queue expression netlink attributes
738 *
739 * @NFTA_QUEUE_NUM: netlink queue to send messages to (NLA_U16)
740 * @NFTA_QUEUE_TOTAL: number of queues to load balance packets on (NLA_U16)
741 * @NFTA_QUEUE_FLAGS: various flags (NLA_U16)
742 */
743enum nft_queue_attributes {
744 NFTA_QUEUE_UNSPEC,
745 NFTA_QUEUE_NUM,
746 NFTA_QUEUE_TOTAL,
747 NFTA_QUEUE_FLAGS,
748 __NFTA_QUEUE_MAX
749};
750#define NFTA_QUEUE_MAX (__NFTA_QUEUE_MAX - 1)
751
752#define NFT_QUEUE_FLAG_BYPASS 0x01 /* for compatibility with v2 */
753#define NFT_QUEUE_FLAG_CPU_FANOUT 0x02 /* use current CPU (no hashing) */
754#define NFT_QUEUE_FLAG_MASK 0x03
755
96518518
PM
756/**
757 * enum nft_reject_types - nf_tables reject expression reject types
758 *
759 * @NFT_REJECT_ICMP_UNREACH: reject using ICMP unreachable
760 * @NFT_REJECT_TCP_RST: reject using TCP RST
51b0a5d8 761 * @NFT_REJECT_ICMPX_UNREACH: abstracted ICMP unreachable for bridge and inet
96518518
PM
762 */
763enum nft_reject_types {
764 NFT_REJECT_ICMP_UNREACH,
765 NFT_REJECT_TCP_RST,
51b0a5d8 766 NFT_REJECT_ICMPX_UNREACH,
96518518
PM
767};
768
51b0a5d8
PNA
769/**
770 * enum nft_reject_code - Generic reject codes for IPv4/IPv6
771 *
772 * @NFT_REJECT_ICMPX_NO_ROUTE: no route to host / network unreachable
773 * @NFT_REJECT_ICMPX_PORT_UNREACH: port unreachable
774 * @NFT_REJECT_ICMPX_HOST_UNREACH: host unreachable
775 * @NFT_REJECT_ICMPX_ADMIN_PROHIBITED: administratively prohibited
776 *
777 * These codes are mapped to real ICMP and ICMPv6 codes.
778 */
779enum nft_reject_inet_code {
780 NFT_REJECT_ICMPX_NO_ROUTE = 0,
781 NFT_REJECT_ICMPX_PORT_UNREACH,
782 NFT_REJECT_ICMPX_HOST_UNREACH,
783 NFT_REJECT_ICMPX_ADMIN_PROHIBITED,
784 __NFT_REJECT_ICMPX_MAX
785};
f0d1f04f 786#define NFT_REJECT_ICMPX_MAX (__NFT_REJECT_ICMPX_MAX - 1)
51b0a5d8 787
96518518
PM
788/**
789 * enum nft_reject_attributes - nf_tables reject expression netlink attributes
790 *
791 * @NFTA_REJECT_TYPE: packet type to use (NLA_U32: nft_reject_types)
792 * @NFTA_REJECT_ICMP_CODE: ICMP code to use (NLA_U8)
793 */
794enum nft_reject_attributes {
795 NFTA_REJECT_UNSPEC,
796 NFTA_REJECT_TYPE,
797 NFTA_REJECT_ICMP_CODE,
798 __NFTA_REJECT_MAX
799};
800#define NFTA_REJECT_MAX (__NFTA_REJECT_MAX - 1)
801
802/**
803 * enum nft_nat_types - nf_tables nat expression NAT types
804 *
805 * @NFT_NAT_SNAT: source NAT
806 * @NFT_NAT_DNAT: destination NAT
807 */
808enum nft_nat_types {
809 NFT_NAT_SNAT,
810 NFT_NAT_DNAT,
811};
812
813/**
814 * enum nft_nat_attributes - nf_tables nat expression netlink attributes
815 *
816 * @NFTA_NAT_TYPE: NAT type (NLA_U32: nft_nat_types)
eb31628e
TB
817 * @NFTA_NAT_FAMILY: NAT family (NLA_U32)
818 * @NFTA_NAT_REG_ADDR_MIN: source register of address range start (NLA_U32: nft_registers)
819 * @NFTA_NAT_REG_ADDR_MAX: source register of address range end (NLA_U32: nft_registers)
820 * @NFTA_NAT_REG_PROTO_MIN: source register of proto range start (NLA_U32: nft_registers)
821 * @NFTA_NAT_REG_PROTO_MAX: source register of proto range end (NLA_U32: nft_registers)
e42eff8a 822 * @NFTA_NAT_FLAGS: NAT flags (see NF_NAT_RANGE_* in linux/netfilter/nf_nat.h) (NLA_U32)
96518518
PM
823 */
824enum nft_nat_attributes {
825 NFTA_NAT_UNSPEC,
826 NFTA_NAT_TYPE,
eb31628e
TB
827 NFTA_NAT_FAMILY,
828 NFTA_NAT_REG_ADDR_MIN,
829 NFTA_NAT_REG_ADDR_MAX,
830 NFTA_NAT_REG_PROTO_MIN,
831 NFTA_NAT_REG_PROTO_MAX,
e42eff8a 832 NFTA_NAT_FLAGS,
96518518
PM
833 __NFTA_NAT_MAX
834};
835#define NFTA_NAT_MAX (__NFTA_NAT_MAX - 1)
836
9ba1f726
AB
837/**
838 * enum nft_masq_attributes - nf_tables masquerade expression attributes
839 *
840 * @NFTA_MASQ_FLAGS: NAT flags (see NF_NAT_RANGE_* in linux/netfilter/nf_nat.h) (NLA_U32)
841 */
842enum nft_masq_attributes {
39e393bb 843 NFTA_MASQ_UNSPEC,
9ba1f726
AB
844 NFTA_MASQ_FLAGS,
845 __NFTA_MASQ_MAX
846};
847#define NFTA_MASQ_MAX (__NFTA_MASQ_MAX - 1)
848
e9105f1b
AB
849/**
850 * enum nft_redir_attributes - nf_tables redirect expression netlink attributes
851 *
852 * @NFTA_REDIR_REG_PROTO_MIN: source register of proto range start (NLA_U32: nft_registers)
853 * @NFTA_REDIR_REG_PROTO_MAX: source register of proto range end (NLA_U32: nft_registers)
854 * @NFTA_REDIR_FLAGS: NAT flags (see NF_NAT_RANGE_* in linux/netfilter/nf_nat.h) (NLA_U32)
855 */
856enum nft_redir_attributes {
857 NFTA_REDIR_UNSPEC,
858 NFTA_REDIR_REG_PROTO_MIN,
859 NFTA_REDIR_REG_PROTO_MAX,
860 NFTA_REDIR_FLAGS,
861 __NFTA_REDIR_MAX
862};
863#define NFTA_REDIR_MAX (__NFTA_REDIR_MAX - 1)
864
84d7fce6
PNA
865/**
866 * enum nft_gen_attributes - nf_tables ruleset generation attributes
867 *
868 * @NFTA_GEN_ID: Ruleset generation ID (NLA_U32)
869 */
870enum nft_gen_attributes {
871 NFTA_GEN_UNSPEC,
872 NFTA_GEN_ID,
873 __NFTA_GEN_MAX
874};
875#define NFTA_GEN_MAX (__NFTA_GEN_MAX - 1)
876
96518518 877#endif /* _LINUX_NF_TABLES_H */