]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/uapi/linux/netfilter/nf_tables.h
netfilter: nft_exthdr: add TCP option matching
[mirror_ubuntu-artful-kernel.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 5#define NFT_CHAIN_MAXNAMELEN 32
cb39ad8b 6#define NFT_SET_MAXNAMELEN 32
e5009240 7#define NFT_OBJ_MAXNAMELEN 32
0768b3b3 8#define NFT_USERDATA_MAXLEN 256
96518518 9
49499c3e
PM
10/**
11 * enum nft_registers - nf_tables registers
12 *
13 * nf_tables used to have five registers: a verdict register and four data
14 * registers of size 16. The data registers have been changed to 16 registers
15 * of size 4. For compatibility reasons, the NFT_REG_[1-4] registers still
16 * map to areas of size 16, the 4 byte registers are addressed using
17 * NFT_REG32_00 - NFT_REG32_15.
18 */
96518518
PM
19enum nft_registers {
20 NFT_REG_VERDICT,
21 NFT_REG_1,
22 NFT_REG_2,
23 NFT_REG_3,
24 NFT_REG_4,
49499c3e
PM
25 __NFT_REG_MAX,
26
27 NFT_REG32_00 = 8,
2c86943c 28 NFT_REG32_01,
49499c3e
PM
29 NFT_REG32_02,
30 NFT_REG32_03,
31 NFT_REG32_04,
32 NFT_REG32_05,
33 NFT_REG32_06,
34 NFT_REG32_07,
35 NFT_REG32_08,
36 NFT_REG32_09,
37 NFT_REG32_10,
38 NFT_REG32_11,
39 NFT_REG32_12,
40 NFT_REG32_13,
41 NFT_REG32_14,
42 NFT_REG32_15,
96518518
PM
43};
44#define NFT_REG_MAX (__NFT_REG_MAX - 1)
45
49499c3e
PM
46#define NFT_REG_SIZE 16
47#define NFT_REG32_SIZE 4
48
96518518
PM
49/**
50 * enum nft_verdicts - nf_tables internal verdicts
51 *
52 * @NFT_CONTINUE: continue evaluation of the current rule
53 * @NFT_BREAK: terminate evaluation of the current rule
54 * @NFT_JUMP: push the current chain on the jump stack and jump to a chain
55 * @NFT_GOTO: jump to a chain without pushing the current chain on the jump stack
56 * @NFT_RETURN: return to the topmost chain on the jump stack
57 *
58 * The nf_tables verdicts share their numeric space with the netfilter verdicts.
59 */
60enum nft_verdicts {
61 NFT_CONTINUE = -1,
62 NFT_BREAK = -2,
63 NFT_JUMP = -3,
64 NFT_GOTO = -4,
65 NFT_RETURN = -5,
66};
67
68/**
69 * enum nf_tables_msg_types - nf_tables netlink message types
70 *
71 * @NFT_MSG_NEWTABLE: create a new table (enum nft_table_attributes)
72 * @NFT_MSG_GETTABLE: get a table (enum nft_table_attributes)
73 * @NFT_MSG_DELTABLE: delete a table (enum nft_table_attributes)
74 * @NFT_MSG_NEWCHAIN: create a new chain (enum nft_chain_attributes)
75 * @NFT_MSG_GETCHAIN: get a chain (enum nft_chain_attributes)
76 * @NFT_MSG_DELCHAIN: delete a chain (enum nft_chain_attributes)
77 * @NFT_MSG_NEWRULE: create a new rule (enum nft_rule_attributes)
78 * @NFT_MSG_GETRULE: get a rule (enum nft_rule_attributes)
79 * @NFT_MSG_DELRULE: delete a rule (enum nft_rule_attributes)
20a69341
PM
80 * @NFT_MSG_NEWSET: create a new set (enum nft_set_attributes)
81 * @NFT_MSG_GETSET: get a set (enum nft_set_attributes)
82 * @NFT_MSG_DELSET: delete a set (enum nft_set_attributes)
83 * @NFT_MSG_NEWSETELEM: create a new set element (enum nft_set_elem_attributes)
84 * @NFT_MSG_GETSETELEM: get a set element (enum nft_set_elem_attributes)
85 * @NFT_MSG_DELSETELEM: delete a set element (enum nft_set_elem_attributes)
84d7fce6
PNA
86 * @NFT_MSG_NEWGEN: announce a new generation, only for events (enum nft_gen_attributes)
87 * @NFT_MSG_GETGEN: get the rule-set generation (enum nft_gen_attributes)
33d5a7b1 88 * @NFT_MSG_TRACE: trace event (enum nft_trace_attributes)
e5009240
PNA
89 * @NFT_MSG_NEWOBJ: create a stateful object (enum nft_obj_attributes)
90 * @NFT_MSG_GETOBJ: get a stateful object (enum nft_obj_attributes)
91 * @NFT_MSG_DELOBJ: delete a stateful object (enum nft_obj_attributes)
43da04a5 92 * @NFT_MSG_GETOBJ_RESET: get and reset a stateful object (enum nft_obj_attributes)
96518518
PM
93 */
94enum nf_tables_msg_types {
95 NFT_MSG_NEWTABLE,
96 NFT_MSG_GETTABLE,
97 NFT_MSG_DELTABLE,
98 NFT_MSG_NEWCHAIN,
99 NFT_MSG_GETCHAIN,
100 NFT_MSG_DELCHAIN,
101 NFT_MSG_NEWRULE,
102 NFT_MSG_GETRULE,
103 NFT_MSG_DELRULE,
20a69341
PM
104 NFT_MSG_NEWSET,
105 NFT_MSG_GETSET,
106 NFT_MSG_DELSET,
107 NFT_MSG_NEWSETELEM,
108 NFT_MSG_GETSETELEM,
109 NFT_MSG_DELSETELEM,
84d7fce6
PNA
110 NFT_MSG_NEWGEN,
111 NFT_MSG_GETGEN,
33d5a7b1 112 NFT_MSG_TRACE,
e5009240
PNA
113 NFT_MSG_NEWOBJ,
114 NFT_MSG_GETOBJ,
115 NFT_MSG_DELOBJ,
43da04a5 116 NFT_MSG_GETOBJ_RESET,
96518518
PM
117 NFT_MSG_MAX,
118};
119
20a69341
PM
120/**
121 * enum nft_list_attributes - nf_tables generic list netlink attributes
122 *
123 * @NFTA_LIST_ELEM: list element (NLA_NESTED)
124 */
96518518
PM
125enum nft_list_attributes {
126 NFTA_LIST_UNPEC,
127 NFTA_LIST_ELEM,
128 __NFTA_LIST_MAX
129};
130#define NFTA_LIST_MAX (__NFTA_LIST_MAX - 1)
131
132/**
133 * enum nft_hook_attributes - nf_tables netfilter hook netlink attributes
134 *
135 * @NFTA_HOOK_HOOKNUM: netfilter hook number (NLA_U32)
136 * @NFTA_HOOK_PRIORITY: netfilter hook priority (NLA_U32)
2cbce139 137 * @NFTA_HOOK_DEV: netdevice name (NLA_STRING)
96518518
PM
138 */
139enum nft_hook_attributes {
140 NFTA_HOOK_UNSPEC,
141 NFTA_HOOK_HOOKNUM,
142 NFTA_HOOK_PRIORITY,
2cbce139 143 NFTA_HOOK_DEV,
96518518
PM
144 __NFTA_HOOK_MAX
145};
146#define NFTA_HOOK_MAX (__NFTA_HOOK_MAX - 1)
147
9ddf6323
PNA
148/**
149 * enum nft_table_flags - nf_tables table flags
150 *
151 * @NFT_TABLE_F_DORMANT: this table is not active
152 */
153enum nft_table_flags {
154 NFT_TABLE_F_DORMANT = 0x1,
155};
156
96518518
PM
157/**
158 * enum nft_table_attributes - nf_tables table netlink attributes
159 *
160 * @NFTA_TABLE_NAME: name of the table (NLA_STRING)
9ddf6323 161 * @NFTA_TABLE_FLAGS: bitmask of enum nft_table_flags (NLA_U32)
d8bcc768 162 * @NFTA_TABLE_USE: number of chains in this table (NLA_U32)
96518518
PM
163 */
164enum nft_table_attributes {
165 NFTA_TABLE_UNSPEC,
166 NFTA_TABLE_NAME,
9ddf6323 167 NFTA_TABLE_FLAGS,
d8bcc768 168 NFTA_TABLE_USE,
96518518
PM
169 __NFTA_TABLE_MAX
170};
171#define NFTA_TABLE_MAX (__NFTA_TABLE_MAX - 1)
172
173/**
174 * enum nft_chain_attributes - nf_tables chain netlink attributes
175 *
176 * @NFTA_CHAIN_TABLE: name of the table containing the chain (NLA_STRING)
177 * @NFTA_CHAIN_HANDLE: numeric handle of the chain (NLA_U64)
178 * @NFTA_CHAIN_NAME: name of the chain (NLA_STRING)
179 * @NFTA_CHAIN_HOOK: hook specification for basechains (NLA_NESTED: nft_hook_attributes)
0ca743a5
PNA
180 * @NFTA_CHAIN_POLICY: numeric policy of the chain (NLA_U32)
181 * @NFTA_CHAIN_USE: number of references to this chain (NLA_U32)
9370761c 182 * @NFTA_CHAIN_TYPE: type name of the string (NLA_NUL_STRING)
0ca743a5 183 * @NFTA_CHAIN_COUNTERS: counter specification of the chain (NLA_NESTED: nft_counter_attributes)
96518518
PM
184 */
185enum nft_chain_attributes {
186 NFTA_CHAIN_UNSPEC,
187 NFTA_CHAIN_TABLE,
188 NFTA_CHAIN_HANDLE,
189 NFTA_CHAIN_NAME,
190 NFTA_CHAIN_HOOK,
0ca743a5
PNA
191 NFTA_CHAIN_POLICY,
192 NFTA_CHAIN_USE,
9370761c 193 NFTA_CHAIN_TYPE,
0ca743a5 194 NFTA_CHAIN_COUNTERS,
b46f6ded 195 NFTA_CHAIN_PAD,
96518518
PM
196 __NFTA_CHAIN_MAX
197};
198#define NFTA_CHAIN_MAX (__NFTA_CHAIN_MAX - 1)
199
200/**
201 * enum nft_rule_attributes - nf_tables rule netlink attributes
202 *
203 * @NFTA_RULE_TABLE: name of the table containing the rule (NLA_STRING)
204 * @NFTA_RULE_CHAIN: name of the chain containing the rule (NLA_STRING)
205 * @NFTA_RULE_HANDLE: numeric handle of the rule (NLA_U64)
206 * @NFTA_RULE_EXPRESSIONS: list of expressions (NLA_NESTED: nft_expr_attributes)
0ca743a5 207 * @NFTA_RULE_COMPAT: compatibility specifications of the rule (NLA_NESTED: nft_rule_compat_attributes)
5e948466 208 * @NFTA_RULE_POSITION: numeric handle of the previous rule (NLA_U64)
0768b3b3 209 * @NFTA_RULE_USERDATA: user data (NLA_BINARY, NFT_USERDATA_MAXLEN)
96518518
PM
210 */
211enum nft_rule_attributes {
212 NFTA_RULE_UNSPEC,
213 NFTA_RULE_TABLE,
214 NFTA_RULE_CHAIN,
215 NFTA_RULE_HANDLE,
216 NFTA_RULE_EXPRESSIONS,
0ca743a5 217 NFTA_RULE_COMPAT,
5e948466 218 NFTA_RULE_POSITION,
0768b3b3 219 NFTA_RULE_USERDATA,
b46f6ded 220 NFTA_RULE_PAD,
96518518
PM
221 __NFTA_RULE_MAX
222};
223#define NFTA_RULE_MAX (__NFTA_RULE_MAX - 1)
224
0ca743a5
PNA
225/**
226 * enum nft_rule_compat_flags - nf_tables rule compat flags
227 *
228 * @NFT_RULE_COMPAT_F_INV: invert the check result
229 */
230enum nft_rule_compat_flags {
231 NFT_RULE_COMPAT_F_INV = (1 << 1),
232 NFT_RULE_COMPAT_F_MASK = NFT_RULE_COMPAT_F_INV,
233};
234
235/**
236 * enum nft_rule_compat_attributes - nf_tables rule compat attributes
237 *
d7f5762c 238 * @NFTA_RULE_COMPAT_PROTO: numeric value of handled protocol (NLA_U32)
0ca743a5
PNA
239 * @NFTA_RULE_COMPAT_FLAGS: bitmask of enum nft_rule_compat_flags (NLA_U32)
240 */
241enum nft_rule_compat_attributes {
242 NFTA_RULE_COMPAT_UNSPEC,
243 NFTA_RULE_COMPAT_PROTO,
244 NFTA_RULE_COMPAT_FLAGS,
245 __NFTA_RULE_COMPAT_MAX
246};
247#define NFTA_RULE_COMPAT_MAX (__NFTA_RULE_COMPAT_MAX - 1)
248
20a69341
PM
249/**
250 * enum nft_set_flags - nf_tables set flags
251 *
252 * @NFT_SET_ANONYMOUS: name allocation, automatic cleanup on unlink
253 * @NFT_SET_CONSTANT: set contents may not change while bound
254 * @NFT_SET_INTERVAL: set contains intervals
255 * @NFT_SET_MAP: set is used as a dictionary
761da293 256 * @NFT_SET_TIMEOUT: set uses timeouts
7c6c6e95 257 * @NFT_SET_EVAL: set contains expressions for evaluation
8aeff920 258 * @NFT_SET_OBJECT: set contains stateful objects
20a69341
PM
259 */
260enum nft_set_flags {
261 NFT_SET_ANONYMOUS = 0x1,
262 NFT_SET_CONSTANT = 0x2,
263 NFT_SET_INTERVAL = 0x4,
264 NFT_SET_MAP = 0x8,
761da293 265 NFT_SET_TIMEOUT = 0x10,
7c6c6e95 266 NFT_SET_EVAL = 0x20,
8aeff920 267 NFT_SET_OBJECT = 0x40,
20a69341
PM
268};
269
c50b960c
PM
270/**
271 * enum nft_set_policies - set selection policy
272 *
273 * @NFT_SET_POL_PERFORMANCE: prefer high performance over low memory use
274 * @NFT_SET_POL_MEMORY: prefer low memory use over high performance
275 */
276enum nft_set_policies {
277 NFT_SET_POL_PERFORMANCE,
278 NFT_SET_POL_MEMORY,
279};
280
281/**
282 * enum nft_set_desc_attributes - set element description
283 *
284 * @NFTA_SET_DESC_SIZE: number of elements in set (NLA_U32)
285 */
286enum nft_set_desc_attributes {
287 NFTA_SET_DESC_UNSPEC,
288 NFTA_SET_DESC_SIZE,
289 __NFTA_SET_DESC_MAX
290};
291#define NFTA_SET_DESC_MAX (__NFTA_SET_DESC_MAX - 1)
292
20a69341
PM
293/**
294 * enum nft_set_attributes - nf_tables set netlink attributes
295 *
296 * @NFTA_SET_TABLE: table name (NLA_STRING)
297 * @NFTA_SET_NAME: set name (NLA_STRING)
298 * @NFTA_SET_FLAGS: bitmask of enum nft_set_flags (NLA_U32)
299 * @NFTA_SET_KEY_TYPE: key data type, informational purpose only (NLA_U32)
300 * @NFTA_SET_KEY_LEN: key data length (NLA_U32)
301 * @NFTA_SET_DATA_TYPE: mapping data type (NLA_U32)
302 * @NFTA_SET_DATA_LEN: mapping data length (NLA_U32)
c50b960c
PM
303 * @NFTA_SET_POLICY: selection policy (NLA_U32)
304 * @NFTA_SET_DESC: set description (NLA_NESTED)
958bee14 305 * @NFTA_SET_ID: uniquely identifies a set in a transaction (NLA_U32)
761da293
PM
306 * @NFTA_SET_TIMEOUT: default timeout value (NLA_U64)
307 * @NFTA_SET_GC_INTERVAL: garbage collection interval (NLA_U32)
e6d8ecac 308 * @NFTA_SET_USERDATA: user data (NLA_BINARY)
8aeff920 309 * @NFTA_SET_OBJ_TYPE: stateful object type (NLA_U32: NFT_OBJECT_*)
20a69341
PM
310 */
311enum nft_set_attributes {
312 NFTA_SET_UNSPEC,
313 NFTA_SET_TABLE,
314 NFTA_SET_NAME,
315 NFTA_SET_FLAGS,
316 NFTA_SET_KEY_TYPE,
317 NFTA_SET_KEY_LEN,
318 NFTA_SET_DATA_TYPE,
319 NFTA_SET_DATA_LEN,
c50b960c
PM
320 NFTA_SET_POLICY,
321 NFTA_SET_DESC,
958bee14 322 NFTA_SET_ID,
761da293
PM
323 NFTA_SET_TIMEOUT,
324 NFTA_SET_GC_INTERVAL,
e6d8ecac 325 NFTA_SET_USERDATA,
b46f6ded 326 NFTA_SET_PAD,
8aeff920 327 NFTA_SET_OBJ_TYPE,
20a69341
PM
328 __NFTA_SET_MAX
329};
330#define NFTA_SET_MAX (__NFTA_SET_MAX - 1)
331
332/**
333 * enum nft_set_elem_flags - nf_tables set element flags
334 *
335 * @NFT_SET_ELEM_INTERVAL_END: element ends the previous interval
336 */
337enum nft_set_elem_flags {
338 NFT_SET_ELEM_INTERVAL_END = 0x1,
339};
340
341/**
342 * enum nft_set_elem_attributes - nf_tables set element netlink attributes
343 *
344 * @NFTA_SET_ELEM_KEY: key value (NLA_NESTED: nft_data)
345 * @NFTA_SET_ELEM_DATA: data value of mapping (NLA_NESTED: nft_data_attributes)
346 * @NFTA_SET_ELEM_FLAGS: bitmask of nft_set_elem_flags (NLA_U32)
c3e1b005
PM
347 * @NFTA_SET_ELEM_TIMEOUT: timeout value (NLA_U64)
348 * @NFTA_SET_ELEM_EXPIRATION: expiration time (NLA_U64)
68e942e8 349 * @NFTA_SET_ELEM_USERDATA: user data (NLA_BINARY)
f25ad2e9 350 * @NFTA_SET_ELEM_EXPR: expression (NLA_NESTED: nft_expr_attributes)
8aeff920 351 * @NFTA_SET_ELEM_OBJREF: stateful object reference (NLA_STRING)
20a69341
PM
352 */
353enum nft_set_elem_attributes {
354 NFTA_SET_ELEM_UNSPEC,
355 NFTA_SET_ELEM_KEY,
356 NFTA_SET_ELEM_DATA,
357 NFTA_SET_ELEM_FLAGS,
c3e1b005
PM
358 NFTA_SET_ELEM_TIMEOUT,
359 NFTA_SET_ELEM_EXPIRATION,
68e942e8 360 NFTA_SET_ELEM_USERDATA,
f25ad2e9 361 NFTA_SET_ELEM_EXPR,
b46f6ded 362 NFTA_SET_ELEM_PAD,
8aeff920 363 NFTA_SET_ELEM_OBJREF,
20a69341
PM
364 __NFTA_SET_ELEM_MAX
365};
366#define NFTA_SET_ELEM_MAX (__NFTA_SET_ELEM_MAX - 1)
367
368/**
369 * enum nft_set_elem_list_attributes - nf_tables set element list netlink attributes
370 *
371 * @NFTA_SET_ELEM_LIST_TABLE: table of the set to be changed (NLA_STRING)
372 * @NFTA_SET_ELEM_LIST_SET: name of the set to be changed (NLA_STRING)
373 * @NFTA_SET_ELEM_LIST_ELEMENTS: list of set elements (NLA_NESTED: nft_set_elem_attributes)
958bee14 374 * @NFTA_SET_ELEM_LIST_SET_ID: uniquely identifies a set in a transaction (NLA_U32)
20a69341
PM
375 */
376enum nft_set_elem_list_attributes {
377 NFTA_SET_ELEM_LIST_UNSPEC,
378 NFTA_SET_ELEM_LIST_TABLE,
379 NFTA_SET_ELEM_LIST_SET,
380 NFTA_SET_ELEM_LIST_ELEMENTS,
958bee14 381 NFTA_SET_ELEM_LIST_SET_ID,
20a69341
PM
382 __NFTA_SET_ELEM_LIST_MAX
383};
384#define NFTA_SET_ELEM_LIST_MAX (__NFTA_SET_ELEM_LIST_MAX - 1)
385
386/**
387 * enum nft_data_types - nf_tables data types
388 *
389 * @NFT_DATA_VALUE: generic data
390 * @NFT_DATA_VERDICT: netfilter verdict
391 *
392 * The type of data is usually determined by the kernel directly and is not
393 * explicitly specified by userspace. The only difference are sets, where
394 * userspace specifies the key and mapping data types.
395 *
396 * The values 0xffffff00-0xffffffff are reserved for internally used types.
397 * The remaining range can be freely used by userspace to encode types, all
398 * values are equivalent to NFT_DATA_VALUE.
399 */
400enum nft_data_types {
401 NFT_DATA_VALUE,
402 NFT_DATA_VERDICT = 0xffffff00U,
403};
404
405#define NFT_DATA_RESERVED_MASK 0xffffff00U
406
407/**
408 * enum nft_data_attributes - nf_tables data netlink attributes
409 *
410 * @NFTA_DATA_VALUE: generic data (NLA_BINARY)
411 * @NFTA_DATA_VERDICT: nf_tables verdict (NLA_NESTED: nft_verdict_attributes)
412 */
96518518
PM
413enum nft_data_attributes {
414 NFTA_DATA_UNSPEC,
415 NFTA_DATA_VALUE,
416 NFTA_DATA_VERDICT,
417 __NFTA_DATA_MAX
418};
419#define NFTA_DATA_MAX (__NFTA_DATA_MAX - 1)
420
7d740264
PM
421/* Maximum length of a value */
422#define NFT_DATA_VALUE_MAXLEN 64
423
96518518
PM
424/**
425 * enum nft_verdict_attributes - nf_tables verdict netlink attributes
426 *
427 * @NFTA_VERDICT_CODE: nf_tables verdict (NLA_U32: enum nft_verdicts)
428 * @NFTA_VERDICT_CHAIN: jump target chain name (NLA_STRING)
429 */
430enum nft_verdict_attributes {
431 NFTA_VERDICT_UNSPEC,
432 NFTA_VERDICT_CODE,
433 NFTA_VERDICT_CHAIN,
434 __NFTA_VERDICT_MAX
435};
436#define NFTA_VERDICT_MAX (__NFTA_VERDICT_MAX - 1)
437
438/**
439 * enum nft_expr_attributes - nf_tables expression netlink attributes
440 *
441 * @NFTA_EXPR_NAME: name of the expression type (NLA_STRING)
442 * @NFTA_EXPR_DATA: type specific data (NLA_NESTED)
443 */
444enum nft_expr_attributes {
445 NFTA_EXPR_UNSPEC,
446 NFTA_EXPR_NAME,
447 NFTA_EXPR_DATA,
448 __NFTA_EXPR_MAX
449};
450#define NFTA_EXPR_MAX (__NFTA_EXPR_MAX - 1)
451
452/**
453 * enum nft_immediate_attributes - nf_tables immediate expression netlink attributes
454 *
455 * @NFTA_IMMEDIATE_DREG: destination register to load data into (NLA_U32)
456 * @NFTA_IMMEDIATE_DATA: data to load (NLA_NESTED: nft_data_attributes)
457 */
458enum nft_immediate_attributes {
459 NFTA_IMMEDIATE_UNSPEC,
460 NFTA_IMMEDIATE_DREG,
461 NFTA_IMMEDIATE_DATA,
462 __NFTA_IMMEDIATE_MAX
463};
464#define NFTA_IMMEDIATE_MAX (__NFTA_IMMEDIATE_MAX - 1)
465
466/**
467 * enum nft_bitwise_attributes - nf_tables bitwise expression netlink attributes
468 *
469 * @NFTA_BITWISE_SREG: source register (NLA_U32: nft_registers)
470 * @NFTA_BITWISE_DREG: destination register (NLA_U32: nft_registers)
471 * @NFTA_BITWISE_LEN: length of operands (NLA_U32)
472 * @NFTA_BITWISE_MASK: mask value (NLA_NESTED: nft_data_attributes)
473 * @NFTA_BITWISE_XOR: xor value (NLA_NESTED: nft_data_attributes)
474 *
475 * The bitwise expression performs the following operation:
476 *
477 * dreg = (sreg & mask) ^ xor
478 *
479 * which allow to express all bitwise operations:
480 *
481 * mask xor
482 * NOT: 1 1
483 * OR: 0 x
484 * XOR: 1 x
485 * AND: x 0
486 */
487enum nft_bitwise_attributes {
488 NFTA_BITWISE_UNSPEC,
489 NFTA_BITWISE_SREG,
490 NFTA_BITWISE_DREG,
491 NFTA_BITWISE_LEN,
492 NFTA_BITWISE_MASK,
493 NFTA_BITWISE_XOR,
494 __NFTA_BITWISE_MAX
495};
496#define NFTA_BITWISE_MAX (__NFTA_BITWISE_MAX - 1)
497
498/**
499 * enum nft_byteorder_ops - nf_tables byteorder operators
500 *
501 * @NFT_BYTEORDER_NTOH: network to host operator
d7f5762c 502 * @NFT_BYTEORDER_HTON: host to network operator
96518518
PM
503 */
504enum nft_byteorder_ops {
505 NFT_BYTEORDER_NTOH,
506 NFT_BYTEORDER_HTON,
507};
508
509/**
510 * enum nft_byteorder_attributes - nf_tables byteorder expression netlink attributes
511 *
512 * @NFTA_BYTEORDER_SREG: source register (NLA_U32: nft_registers)
513 * @NFTA_BYTEORDER_DREG: destination register (NLA_U32: nft_registers)
514 * @NFTA_BYTEORDER_OP: operator (NLA_U32: enum nft_byteorder_ops)
515 * @NFTA_BYTEORDER_LEN: length of the data (NLA_U32)
516 * @NFTA_BYTEORDER_SIZE: data size in bytes (NLA_U32: 2 or 4)
517 */
518enum nft_byteorder_attributes {
519 NFTA_BYTEORDER_UNSPEC,
520 NFTA_BYTEORDER_SREG,
521 NFTA_BYTEORDER_DREG,
522 NFTA_BYTEORDER_OP,
523 NFTA_BYTEORDER_LEN,
524 NFTA_BYTEORDER_SIZE,
525 __NFTA_BYTEORDER_MAX
526};
527#define NFTA_BYTEORDER_MAX (__NFTA_BYTEORDER_MAX - 1)
528
529/**
530 * enum nft_cmp_ops - nf_tables relational operator
531 *
532 * @NFT_CMP_EQ: equal
533 * @NFT_CMP_NEQ: not equal
534 * @NFT_CMP_LT: less than
535 * @NFT_CMP_LTE: less than or equal to
536 * @NFT_CMP_GT: greater than
537 * @NFT_CMP_GTE: greater than or equal to
538 */
539enum nft_cmp_ops {
540 NFT_CMP_EQ,
541 NFT_CMP_NEQ,
542 NFT_CMP_LT,
543 NFT_CMP_LTE,
544 NFT_CMP_GT,
545 NFT_CMP_GTE,
546};
547
548/**
549 * enum nft_cmp_attributes - nf_tables cmp expression netlink attributes
550 *
551 * @NFTA_CMP_SREG: source register of data to compare (NLA_U32: nft_registers)
552 * @NFTA_CMP_OP: cmp operation (NLA_U32: nft_cmp_ops)
553 * @NFTA_CMP_DATA: data to compare against (NLA_NESTED: nft_data_attributes)
554 */
555enum nft_cmp_attributes {
556 NFTA_CMP_UNSPEC,
557 NFTA_CMP_SREG,
558 NFTA_CMP_OP,
559 NFTA_CMP_DATA,
560 __NFTA_CMP_MAX
561};
562#define NFTA_CMP_MAX (__NFTA_CMP_MAX - 1)
563
0f3cd9b3
PNA
564/**
565 * enum nft_range_ops - nf_tables range operator
566 *
567 * @NFT_RANGE_EQ: equal
568 * @NFT_RANGE_NEQ: not equal
569 */
570enum nft_range_ops {
571 NFT_RANGE_EQ,
572 NFT_RANGE_NEQ,
573};
574
575/**
576 * enum nft_range_attributes - nf_tables range expression netlink attributes
577 *
578 * @NFTA_RANGE_SREG: source register of data to compare (NLA_U32: nft_registers)
579 * @NFTA_RANGE_OP: cmp operation (NLA_U32: nft_cmp_ops)
580 * @NFTA_RANGE_FROM_DATA: data range from (NLA_NESTED: nft_data_attributes)
581 * @NFTA_RANGE_TO_DATA: data range to (NLA_NESTED: nft_data_attributes)
582 */
583enum nft_range_attributes {
584 NFTA_RANGE_UNSPEC,
585 NFTA_RANGE_SREG,
586 NFTA_RANGE_OP,
587 NFTA_RANGE_FROM_DATA,
588 NFTA_RANGE_TO_DATA,
589 __NFTA_RANGE_MAX
590};
591#define NFTA_RANGE_MAX (__NFTA_RANGE_MAX - 1)
592
0071e184
AB
593enum nft_lookup_flags {
594 NFT_LOOKUP_F_INV = (1 << 0),
595};
596
20a69341
PM
597/**
598 * enum nft_lookup_attributes - nf_tables set lookup expression netlink attributes
599 *
600 * @NFTA_LOOKUP_SET: name of the set where to look for (NLA_STRING)
601 * @NFTA_LOOKUP_SREG: source register of the data to look for (NLA_U32: nft_registers)
602 * @NFTA_LOOKUP_DREG: destination register (NLA_U32: nft_registers)
958bee14 603 * @NFTA_LOOKUP_SET_ID: uniquely identifies a set in a transaction (NLA_U32)
0071e184 604 * @NFTA_LOOKUP_FLAGS: flags (NLA_U32: enum nft_lookup_flags)
20a69341
PM
605 */
606enum nft_lookup_attributes {
607 NFTA_LOOKUP_UNSPEC,
608 NFTA_LOOKUP_SET,
609 NFTA_LOOKUP_SREG,
610 NFTA_LOOKUP_DREG,
958bee14 611 NFTA_LOOKUP_SET_ID,
0071e184 612 NFTA_LOOKUP_FLAGS,
20a69341 613 __NFTA_LOOKUP_MAX
96518518 614};
20a69341 615#define NFTA_LOOKUP_MAX (__NFTA_LOOKUP_MAX - 1)
96518518 616
22fe54d5
PM
617enum nft_dynset_ops {
618 NFT_DYNSET_OP_ADD,
619 NFT_DYNSET_OP_UPDATE,
620};
621
dbd2be06
PNA
622enum nft_dynset_flags {
623 NFT_DYNSET_F_INV = (1 << 0),
624};
625
22fe54d5
PM
626/**
627 * enum nft_dynset_attributes - dynset expression attributes
628 *
629 * @NFTA_DYNSET_SET_NAME: name of set the to add data to (NLA_STRING)
630 * @NFTA_DYNSET_SET_ID: uniquely identifier of the set in the transaction (NLA_U32)
631 * @NFTA_DYNSET_OP: operation (NLA_U32)
632 * @NFTA_DYNSET_SREG_KEY: source register of the key (NLA_U32)
633 * @NFTA_DYNSET_SREG_DATA: source register of the data (NLA_U32)
634 * @NFTA_DYNSET_TIMEOUT: timeout value for the new element (NLA_U64)
3e135cd4 635 * @NFTA_DYNSET_EXPR: expression (NLA_NESTED: nft_expr_attributes)
dbd2be06 636 * @NFTA_DYNSET_FLAGS: flags (NLA_U32)
22fe54d5
PM
637 */
638enum nft_dynset_attributes {
639 NFTA_DYNSET_UNSPEC,
640 NFTA_DYNSET_SET_NAME,
641 NFTA_DYNSET_SET_ID,
642 NFTA_DYNSET_OP,
643 NFTA_DYNSET_SREG_KEY,
644 NFTA_DYNSET_SREG_DATA,
645 NFTA_DYNSET_TIMEOUT,
3e135cd4 646 NFTA_DYNSET_EXPR,
b46f6ded 647 NFTA_DYNSET_PAD,
dbd2be06 648 NFTA_DYNSET_FLAGS,
22fe54d5
PM
649 __NFTA_DYNSET_MAX,
650};
651#define NFTA_DYNSET_MAX (__NFTA_DYNSET_MAX - 1)
652
96518518
PM
653/**
654 * enum nft_payload_bases - nf_tables payload expression offset bases
655 *
656 * @NFT_PAYLOAD_LL_HEADER: link layer header
657 * @NFT_PAYLOAD_NETWORK_HEADER: network header
658 * @NFT_PAYLOAD_TRANSPORT_HEADER: transport header
659 */
660enum nft_payload_bases {
661 NFT_PAYLOAD_LL_HEADER,
662 NFT_PAYLOAD_NETWORK_HEADER,
663 NFT_PAYLOAD_TRANSPORT_HEADER,
664};
665
7ec3f7b4
PM
666/**
667 * enum nft_payload_csum_types - nf_tables payload expression checksum types
668 *
669 * @NFT_PAYLOAD_CSUM_NONE: no checksumming
670 * @NFT_PAYLOAD_CSUM_INET: internet checksum (RFC 791)
671 */
672enum nft_payload_csum_types {
673 NFT_PAYLOAD_CSUM_NONE,
674 NFT_PAYLOAD_CSUM_INET,
675};
676
18140969
PNA
677enum nft_payload_csum_flags {
678 NFT_PAYLOAD_L4CSUM_PSEUDOHDR = (1 << 0),
679};
680
96518518
PM
681/**
682 * enum nft_payload_attributes - nf_tables payload expression netlink attributes
683 *
684 * @NFTA_PAYLOAD_DREG: destination register to load data into (NLA_U32: nft_registers)
685 * @NFTA_PAYLOAD_BASE: payload base (NLA_U32: nft_payload_bases)
686 * @NFTA_PAYLOAD_OFFSET: payload offset relative to base (NLA_U32)
687 * @NFTA_PAYLOAD_LEN: payload length (NLA_U32)
7ec3f7b4
PM
688 * @NFTA_PAYLOAD_SREG: source register to load data from (NLA_U32: nft_registers)
689 * @NFTA_PAYLOAD_CSUM_TYPE: checksum type (NLA_U32)
690 * @NFTA_PAYLOAD_CSUM_OFFSET: checksum offset relative to base (NLA_U32)
18140969 691 * @NFTA_PAYLOAD_CSUM_FLAGS: checksum flags (NLA_U32)
96518518
PM
692 */
693enum nft_payload_attributes {
694 NFTA_PAYLOAD_UNSPEC,
695 NFTA_PAYLOAD_DREG,
696 NFTA_PAYLOAD_BASE,
697 NFTA_PAYLOAD_OFFSET,
698 NFTA_PAYLOAD_LEN,
7ec3f7b4
PM
699 NFTA_PAYLOAD_SREG,
700 NFTA_PAYLOAD_CSUM_TYPE,
701 NFTA_PAYLOAD_CSUM_OFFSET,
18140969 702 NFTA_PAYLOAD_CSUM_FLAGS,
96518518
PM
703 __NFTA_PAYLOAD_MAX
704};
705#define NFTA_PAYLOAD_MAX (__NFTA_PAYLOAD_MAX - 1)
706
c078ca3b
PS
707enum nft_exthdr_flags {
708 NFT_EXTHDR_F_PRESENT = (1 << 0),
709};
710
96518518 711/**
935b7f64
MM
712 * enum nft_exthdr_op - nf_tables match options
713 *
714 * @NFT_EXTHDR_OP_IPV6: match against ipv6 extension headers
715 * @NFT_EXTHDR_OP_TCP: match against tcp options
716 */
717enum nft_exthdr_op {
718 NFT_EXTHDR_OP_IPV6,
719 NFT_EXTHDR_OP_TCPOPT,
720 __NFT_EXTHDR_OP_MAX
721};
722#define NFT_EXTHDR_OP_MAX (__NFT_EXTHDR_OP_MAX - 1)
723
724/**
725 * enum nft_exthdr_attributes - nf_tables extension header expression netlink attributes
96518518
PM
726 *
727 * @NFTA_EXTHDR_DREG: destination register (NLA_U32: nft_registers)
728 * @NFTA_EXTHDR_TYPE: extension header type (NLA_U8)
729 * @NFTA_EXTHDR_OFFSET: extension header offset (NLA_U32)
730 * @NFTA_EXTHDR_LEN: extension header length (NLA_U32)
c078ca3b 731 * @NFTA_EXTHDR_FLAGS: extension header flags (NLA_U32)
935b7f64 732 * @NFTA_EXTHDR_OP: option match type (NLA_U8)
96518518
PM
733 */
734enum nft_exthdr_attributes {
735 NFTA_EXTHDR_UNSPEC,
736 NFTA_EXTHDR_DREG,
737 NFTA_EXTHDR_TYPE,
738 NFTA_EXTHDR_OFFSET,
739 NFTA_EXTHDR_LEN,
c078ca3b 740 NFTA_EXTHDR_FLAGS,
935b7f64 741 NFTA_EXTHDR_OP,
96518518
PM
742 __NFTA_EXTHDR_MAX
743};
744#define NFTA_EXTHDR_MAX (__NFTA_EXTHDR_MAX - 1)
745
746/**
747 * enum nft_meta_keys - nf_tables meta expression keys
748 *
749 * @NFT_META_LEN: packet length (skb->len)
750 * @NFT_META_PROTOCOL: packet ethertype protocol (skb->protocol), invalid in OUTPUT
751 * @NFT_META_PRIORITY: packet priority (skb->priority)
752 * @NFT_META_MARK: packet mark (skb->mark)
753 * @NFT_META_IIF: packet input interface index (dev->ifindex)
754 * @NFT_META_OIF: packet output interface index (dev->ifindex)
755 * @NFT_META_IIFNAME: packet input interface name (dev->name)
756 * @NFT_META_OIFNAME: packet output interface name (dev->name)
757 * @NFT_META_IIFTYPE: packet input interface type (dev->type)
758 * @NFT_META_OIFTYPE: packet output interface type (dev->type)
759 * @NFT_META_SKUID: originating socket UID (fsuid)
760 * @NFT_META_SKGID: originating socket GID (fsgid)
761 * @NFT_META_NFTRACE: packet nftrace bit
762 * @NFT_META_RTCLASSID: realm value of packet's route (skb->dst->tclassid)
763 * @NFT_META_SECMARK: packet secmark (skb->secmark)
124edfa9 764 * @NFT_META_NFPROTO: netfilter protocol
4566bf27 765 * @NFT_META_L4PROTO: layer 4 protocol number
f5efc696
TB
766 * @NFT_META_BRI_IIFNAME: packet input bridge interface name
767 * @NFT_META_BRI_OIFNAME: packet output bridge interface name
e2a093ff 768 * @NFT_META_PKTTYPE: packet type (skb->pkt_type), special handling for loopback
afc5be30 769 * @NFT_META_CPU: cpu id through smp_processor_id()
3045d760
AR
770 * @NFT_META_IIFGROUP: packet input interface group
771 * @NFT_META_OIFGROUP: packet output interface group
ce674173 772 * @NFT_META_CGROUP: socket control group (skb->sk->sk_classid)
b07edbe1 773 * @NFT_META_PRANDOM: a 32bit pseudo-random number
96518518
PM
774 */
775enum nft_meta_keys {
776 NFT_META_LEN,
777 NFT_META_PROTOCOL,
778 NFT_META_PRIORITY,
779 NFT_META_MARK,
780 NFT_META_IIF,
781 NFT_META_OIF,
782 NFT_META_IIFNAME,
783 NFT_META_OIFNAME,
784 NFT_META_IIFTYPE,
785 NFT_META_OIFTYPE,
786 NFT_META_SKUID,
787 NFT_META_SKGID,
788 NFT_META_NFTRACE,
789 NFT_META_RTCLASSID,
790 NFT_META_SECMARK,
124edfa9 791 NFT_META_NFPROTO,
4566bf27 792 NFT_META_L4PROTO,
f5efc696
TB
793 NFT_META_BRI_IIFNAME,
794 NFT_META_BRI_OIFNAME,
e2a093ff 795 NFT_META_PKTTYPE,
afc5be30 796 NFT_META_CPU,
3045d760
AR
797 NFT_META_IIFGROUP,
798 NFT_META_OIFGROUP,
ce674173 799 NFT_META_CGROUP,
b07edbe1 800 NFT_META_PRANDOM,
96518518
PM
801};
802
2fa84193
AP
803/**
804 * enum nft_rt_keys - nf_tables routing expression keys
805 *
806 * @NFT_RT_CLASSID: realm value of packet's route (skb->dst->tclassid)
807 * @NFT_RT_NEXTHOP4: routing nexthop for IPv4
808 * @NFT_RT_NEXTHOP6: routing nexthop for IPv6
809 */
810enum nft_rt_keys {
811 NFT_RT_CLASSID,
812 NFT_RT_NEXTHOP4,
813 NFT_RT_NEXTHOP6,
814};
815
cb1b69b0
LGL
816/**
817 * enum nft_hash_attributes - nf_tables hash expression netlink attributes
818 *
819 * @NFTA_HASH_SREG: source register (NLA_U32)
820 * @NFTA_HASH_DREG: destination register (NLA_U32)
821 * @NFTA_HASH_LEN: source data length (NLA_U32)
822 * @NFTA_HASH_MODULUS: modulus value (NLA_U32)
823 * @NFTA_HASH_SEED: seed value (NLA_U32)
70ca767e 824 * @NFTA_HASH_OFFSET: add this offset value to hash result (NLA_U32)
cb1b69b0
LGL
825 */
826enum nft_hash_attributes {
827 NFTA_HASH_UNSPEC,
828 NFTA_HASH_SREG,
829 NFTA_HASH_DREG,
830 NFTA_HASH_LEN,
831 NFTA_HASH_MODULUS,
832 NFTA_HASH_SEED,
70ca767e 833 NFTA_HASH_OFFSET,
cb1b69b0
LGL
834 __NFTA_HASH_MAX,
835};
836#define NFTA_HASH_MAX (__NFTA_HASH_MAX - 1)
837
96518518
PM
838/**
839 * enum nft_meta_attributes - nf_tables meta expression netlink attributes
840 *
841 * @NFTA_META_DREG: destination register (NLA_U32)
842 * @NFTA_META_KEY: meta data item to load (NLA_U32: nft_meta_keys)
e035b77a 843 * @NFTA_META_SREG: source register (NLA_U32)
96518518
PM
844 */
845enum nft_meta_attributes {
846 NFTA_META_UNSPEC,
847 NFTA_META_DREG,
848 NFTA_META_KEY,
e035b77a 849 NFTA_META_SREG,
96518518
PM
850 __NFTA_META_MAX
851};
852#define NFTA_META_MAX (__NFTA_META_MAX - 1)
853
2fa84193
AP
854/**
855 * enum nft_rt_attributes - nf_tables routing expression netlink attributes
856 *
857 * @NFTA_RT_DREG: destination register (NLA_U32)
858 * @NFTA_RT_KEY: routing data item to load (NLA_U32: nft_rt_keys)
859 */
860enum nft_rt_attributes {
861 NFTA_RT_UNSPEC,
862 NFTA_RT_DREG,
863 NFTA_RT_KEY,
864 __NFTA_RT_MAX
865};
866#define NFTA_RT_MAX (__NFTA_RT_MAX - 1)
867
96518518
PM
868/**
869 * enum nft_ct_keys - nf_tables ct expression keys
870 *
871 * @NFT_CT_STATE: conntrack state (bitmask of enum ip_conntrack_info)
872 * @NFT_CT_DIRECTION: conntrack direction (enum ip_conntrack_dir)
873 * @NFT_CT_STATUS: conntrack status (bitmask of enum ip_conntrack_status)
874 * @NFT_CT_MARK: conntrack mark value
875 * @NFT_CT_SECMARK: conntrack secmark value
876 * @NFT_CT_EXPIRATION: relative conntrack expiration time in ms
877 * @NFT_CT_HELPER: connection tracking helper assigned to conntrack
878 * @NFT_CT_L3PROTOCOL: conntrack layer 3 protocol
879 * @NFT_CT_SRC: conntrack layer 3 protocol source (IPv4/IPv6 address)
880 * @NFT_CT_DST: conntrack layer 3 protocol destination (IPv4/IPv6 address)
881 * @NFT_CT_PROTOCOL: conntrack layer 4 protocol
882 * @NFT_CT_PROTO_SRC: conntrack layer 4 protocol source
883 * @NFT_CT_PROTO_DST: conntrack layer 4 protocol destination
237bab66
LZ
884 * @NFT_CT_LABELS: conntrack labels
885 * @NFT_CT_PKTS: conntrack packets
886 * @NFT_CT_BYTES: conntrack bytes
949a3584 887 * @NFT_CT_AVGPKT: conntrack average bytes per packet
ab23821f 888 * @NFT_CT_ZONE: conntrack zone
96518518
PM
889 */
890enum nft_ct_keys {
891 NFT_CT_STATE,
892 NFT_CT_DIRECTION,
893 NFT_CT_STATUS,
894 NFT_CT_MARK,
895 NFT_CT_SECMARK,
896 NFT_CT_EXPIRATION,
897 NFT_CT_HELPER,
898 NFT_CT_L3PROTOCOL,
899 NFT_CT_SRC,
900 NFT_CT_DST,
901 NFT_CT_PROTOCOL,
902 NFT_CT_PROTO_SRC,
903 NFT_CT_PROTO_DST,
d2bf2f34 904 NFT_CT_LABELS,
48f66c90
FW
905 NFT_CT_PKTS,
906 NFT_CT_BYTES,
949a3584 907 NFT_CT_AVGPKT,
ab23821f 908 NFT_CT_ZONE,
96518518
PM
909};
910
911/**
912 * enum nft_ct_attributes - nf_tables ct expression netlink attributes
913 *
914 * @NFTA_CT_DREG: destination register (NLA_U32)
915 * @NFTA_CT_KEY: conntrack data item to load (NLA_U32: nft_ct_keys)
916 * @NFTA_CT_DIRECTION: direction in case of directional keys (NLA_U8)
c4ede3d3 917 * @NFTA_CT_SREG: source register (NLA_U32)
96518518
PM
918 */
919enum nft_ct_attributes {
920 NFTA_CT_UNSPEC,
921 NFTA_CT_DREG,
922 NFTA_CT_KEY,
923 NFTA_CT_DIRECTION,
c4ede3d3 924 NFTA_CT_SREG,
96518518
PM
925 __NFTA_CT_MAX
926};
927#define NFTA_CT_MAX (__NFTA_CT_MAX - 1)
928
d2168e84
PNA
929enum nft_limit_type {
930 NFT_LIMIT_PKTS,
931 NFT_LIMIT_PKT_BYTES
932};
933
c7862a5f
PNA
934enum nft_limit_flags {
935 NFT_LIMIT_F_INV = (1 << 0),
936};
937
96518518
PM
938/**
939 * enum nft_limit_attributes - nf_tables limit expression netlink attributes
940 *
941 * @NFTA_LIMIT_RATE: refill rate (NLA_U64)
942 * @NFTA_LIMIT_UNIT: refill unit (NLA_U64)
3e87baaf 943 * @NFTA_LIMIT_BURST: burst (NLA_U32)
d2168e84 944 * @NFTA_LIMIT_TYPE: type of limit (NLA_U32: enum nft_limit_type)
c7862a5f 945 * @NFTA_LIMIT_FLAGS: flags (NLA_U32: enum nft_limit_flags)
96518518
PM
946 */
947enum nft_limit_attributes {
948 NFTA_LIMIT_UNSPEC,
949 NFTA_LIMIT_RATE,
950 NFTA_LIMIT_UNIT,
3e87baaf 951 NFTA_LIMIT_BURST,
d2168e84 952 NFTA_LIMIT_TYPE,
c7862a5f 953 NFTA_LIMIT_FLAGS,
b46f6ded 954 NFTA_LIMIT_PAD,
96518518
PM
955 __NFTA_LIMIT_MAX
956};
957#define NFTA_LIMIT_MAX (__NFTA_LIMIT_MAX - 1)
958
959/**
960 * enum nft_counter_attributes - nf_tables counter expression netlink attributes
961 *
962 * @NFTA_COUNTER_BYTES: number of bytes (NLA_U64)
963 * @NFTA_COUNTER_PACKETS: number of packets (NLA_U64)
964 */
965enum nft_counter_attributes {
966 NFTA_COUNTER_UNSPEC,
967 NFTA_COUNTER_BYTES,
968 NFTA_COUNTER_PACKETS,
b46f6ded 969 NFTA_COUNTER_PAD,
96518518
PM
970 __NFTA_COUNTER_MAX
971};
972#define NFTA_COUNTER_MAX (__NFTA_COUNTER_MAX - 1)
973
974/**
975 * enum nft_log_attributes - nf_tables log expression netlink attributes
976 *
977 * @NFTA_LOG_GROUP: netlink group to send messages to (NLA_U32)
978 * @NFTA_LOG_PREFIX: prefix to prepend to log messages (NLA_STRING)
979 * @NFTA_LOG_SNAPLEN: length of payload to include in netlink message (NLA_U32)
980 * @NFTA_LOG_QTHRESHOLD: queue threshold (NLA_U32)
09d27b88
PNA
981 * @NFTA_LOG_LEVEL: log level (NLA_U32)
982 * @NFTA_LOG_FLAGS: logging flags (NLA_U32)
96518518
PM
983 */
984enum nft_log_attributes {
985 NFTA_LOG_UNSPEC,
986 NFTA_LOG_GROUP,
987 NFTA_LOG_PREFIX,
988 NFTA_LOG_SNAPLEN,
989 NFTA_LOG_QTHRESHOLD,
09d27b88
PNA
990 NFTA_LOG_LEVEL,
991 NFTA_LOG_FLAGS,
96518518
PM
992 __NFTA_LOG_MAX
993};
994#define NFTA_LOG_MAX (__NFTA_LOG_MAX - 1)
995
0aff078d
EL
996/**
997 * enum nft_queue_attributes - nf_tables queue expression netlink attributes
998 *
999 * @NFTA_QUEUE_NUM: netlink queue to send messages to (NLA_U16)
1000 * @NFTA_QUEUE_TOTAL: number of queues to load balance packets on (NLA_U16)
1001 * @NFTA_QUEUE_FLAGS: various flags (NLA_U16)
8061bb54 1002 * @NFTA_QUEUE_SREG_QNUM: source register of queue number (NLA_U32: nft_registers)
0aff078d
EL
1003 */
1004enum nft_queue_attributes {
1005 NFTA_QUEUE_UNSPEC,
1006 NFTA_QUEUE_NUM,
1007 NFTA_QUEUE_TOTAL,
1008 NFTA_QUEUE_FLAGS,
8061bb54 1009 NFTA_QUEUE_SREG_QNUM,
0aff078d
EL
1010 __NFTA_QUEUE_MAX
1011};
1012#define NFTA_QUEUE_MAX (__NFTA_QUEUE_MAX - 1)
1013
1014#define NFT_QUEUE_FLAG_BYPASS 0x01 /* for compatibility with v2 */
1015#define NFT_QUEUE_FLAG_CPU_FANOUT 0x02 /* use current CPU (no hashing) */
1016#define NFT_QUEUE_FLAG_MASK 0x03
1017
3d2f30a1
PNA
1018enum nft_quota_flags {
1019 NFT_QUOTA_F_INV = (1 << 0),
18965317 1020 NFT_QUOTA_F_DEPLETED = (1 << 1),
3d2f30a1
PNA
1021};
1022
1023/**
1024 * enum nft_quota_attributes - nf_tables quota expression netlink attributes
1025 *
1026 * @NFTA_QUOTA_BYTES: quota in bytes (NLA_U16)
1027 * @NFTA_QUOTA_FLAGS: flags (NLA_U32)
795595f6 1028 * @NFTA_QUOTA_CONSUMED: quota already consumed in bytes (NLA_U64)
3d2f30a1
PNA
1029 */
1030enum nft_quota_attributes {
1031 NFTA_QUOTA_UNSPEC,
1032 NFTA_QUOTA_BYTES,
1033 NFTA_QUOTA_FLAGS,
1034 NFTA_QUOTA_PAD,
795595f6 1035 NFTA_QUOTA_CONSUMED,
3d2f30a1
PNA
1036 __NFTA_QUOTA_MAX
1037};
1038#define NFTA_QUOTA_MAX (__NFTA_QUOTA_MAX - 1)
1039
96518518
PM
1040/**
1041 * enum nft_reject_types - nf_tables reject expression reject types
1042 *
1043 * @NFT_REJECT_ICMP_UNREACH: reject using ICMP unreachable
1044 * @NFT_REJECT_TCP_RST: reject using TCP RST
51b0a5d8 1045 * @NFT_REJECT_ICMPX_UNREACH: abstracted ICMP unreachable for bridge and inet
96518518
PM
1046 */
1047enum nft_reject_types {
1048 NFT_REJECT_ICMP_UNREACH,
1049 NFT_REJECT_TCP_RST,
51b0a5d8 1050 NFT_REJECT_ICMPX_UNREACH,
96518518
PM
1051};
1052
51b0a5d8
PNA
1053/**
1054 * enum nft_reject_code - Generic reject codes for IPv4/IPv6
1055 *
1056 * @NFT_REJECT_ICMPX_NO_ROUTE: no route to host / network unreachable
1057 * @NFT_REJECT_ICMPX_PORT_UNREACH: port unreachable
1058 * @NFT_REJECT_ICMPX_HOST_UNREACH: host unreachable
1059 * @NFT_REJECT_ICMPX_ADMIN_PROHIBITED: administratively prohibited
1060 *
1061 * These codes are mapped to real ICMP and ICMPv6 codes.
1062 */
1063enum nft_reject_inet_code {
1064 NFT_REJECT_ICMPX_NO_ROUTE = 0,
1065 NFT_REJECT_ICMPX_PORT_UNREACH,
1066 NFT_REJECT_ICMPX_HOST_UNREACH,
1067 NFT_REJECT_ICMPX_ADMIN_PROHIBITED,
1068 __NFT_REJECT_ICMPX_MAX
1069};
f0d1f04f 1070#define NFT_REJECT_ICMPX_MAX (__NFT_REJECT_ICMPX_MAX - 1)
51b0a5d8 1071
96518518
PM
1072/**
1073 * enum nft_reject_attributes - nf_tables reject expression netlink attributes
1074 *
1075 * @NFTA_REJECT_TYPE: packet type to use (NLA_U32: nft_reject_types)
1076 * @NFTA_REJECT_ICMP_CODE: ICMP code to use (NLA_U8)
1077 */
1078enum nft_reject_attributes {
1079 NFTA_REJECT_UNSPEC,
1080 NFTA_REJECT_TYPE,
1081 NFTA_REJECT_ICMP_CODE,
1082 __NFTA_REJECT_MAX
1083};
1084#define NFTA_REJECT_MAX (__NFTA_REJECT_MAX - 1)
1085
1086/**
1087 * enum nft_nat_types - nf_tables nat expression NAT types
1088 *
1089 * @NFT_NAT_SNAT: source NAT
1090 * @NFT_NAT_DNAT: destination NAT
1091 */
1092enum nft_nat_types {
1093 NFT_NAT_SNAT,
1094 NFT_NAT_DNAT,
1095};
1096
1097/**
1098 * enum nft_nat_attributes - nf_tables nat expression netlink attributes
1099 *
1100 * @NFTA_NAT_TYPE: NAT type (NLA_U32: nft_nat_types)
eb31628e
TB
1101 * @NFTA_NAT_FAMILY: NAT family (NLA_U32)
1102 * @NFTA_NAT_REG_ADDR_MIN: source register of address range start (NLA_U32: nft_registers)
1103 * @NFTA_NAT_REG_ADDR_MAX: source register of address range end (NLA_U32: nft_registers)
1104 * @NFTA_NAT_REG_PROTO_MIN: source register of proto range start (NLA_U32: nft_registers)
1105 * @NFTA_NAT_REG_PROTO_MAX: source register of proto range end (NLA_U32: nft_registers)
e42eff8a 1106 * @NFTA_NAT_FLAGS: NAT flags (see NF_NAT_RANGE_* in linux/netfilter/nf_nat.h) (NLA_U32)
96518518
PM
1107 */
1108enum nft_nat_attributes {
1109 NFTA_NAT_UNSPEC,
1110 NFTA_NAT_TYPE,
eb31628e
TB
1111 NFTA_NAT_FAMILY,
1112 NFTA_NAT_REG_ADDR_MIN,
1113 NFTA_NAT_REG_ADDR_MAX,
1114 NFTA_NAT_REG_PROTO_MIN,
1115 NFTA_NAT_REG_PROTO_MAX,
e42eff8a 1116 NFTA_NAT_FLAGS,
96518518
PM
1117 __NFTA_NAT_MAX
1118};
1119#define NFTA_NAT_MAX (__NFTA_NAT_MAX - 1)
1120
9ba1f726
AB
1121/**
1122 * enum nft_masq_attributes - nf_tables masquerade expression attributes
1123 *
1124 * @NFTA_MASQ_FLAGS: NAT flags (see NF_NAT_RANGE_* in linux/netfilter/nf_nat.h) (NLA_U32)
8a6bf5da
PNA
1125 * @NFTA_MASQ_REG_PROTO_MIN: source register of proto range start (NLA_U32: nft_registers)
1126 * @NFTA_MASQ_REG_PROTO_MAX: source register of proto range end (NLA_U32: nft_registers)
9ba1f726
AB
1127 */
1128enum nft_masq_attributes {
39e393bb 1129 NFTA_MASQ_UNSPEC,
9ba1f726 1130 NFTA_MASQ_FLAGS,
8a6bf5da
PNA
1131 NFTA_MASQ_REG_PROTO_MIN,
1132 NFTA_MASQ_REG_PROTO_MAX,
9ba1f726
AB
1133 __NFTA_MASQ_MAX
1134};
1135#define NFTA_MASQ_MAX (__NFTA_MASQ_MAX - 1)
1136
e9105f1b
AB
1137/**
1138 * enum nft_redir_attributes - nf_tables redirect expression netlink attributes
1139 *
1140 * @NFTA_REDIR_REG_PROTO_MIN: source register of proto range start (NLA_U32: nft_registers)
1141 * @NFTA_REDIR_REG_PROTO_MAX: source register of proto range end (NLA_U32: nft_registers)
1142 * @NFTA_REDIR_FLAGS: NAT flags (see NF_NAT_RANGE_* in linux/netfilter/nf_nat.h) (NLA_U32)
1143 */
1144enum nft_redir_attributes {
1145 NFTA_REDIR_UNSPEC,
1146 NFTA_REDIR_REG_PROTO_MIN,
1147 NFTA_REDIR_REG_PROTO_MAX,
1148 NFTA_REDIR_FLAGS,
1149 __NFTA_REDIR_MAX
1150};
1151#define NFTA_REDIR_MAX (__NFTA_REDIR_MAX - 1)
1152
d877f071
PNA
1153/**
1154 * enum nft_dup_attributes - nf_tables dup expression netlink attributes
1155 *
1156 * @NFTA_DUP_SREG_ADDR: source register of address (NLA_U32: nft_registers)
1157 * @NFTA_DUP_SREG_DEV: source register of output interface (NLA_U32: nft_register)
1158 */
1159enum nft_dup_attributes {
1160 NFTA_DUP_UNSPEC,
1161 NFTA_DUP_SREG_ADDR,
1162 NFTA_DUP_SREG_DEV,
1163 __NFTA_DUP_MAX
1164};
1165#define NFTA_DUP_MAX (__NFTA_DUP_MAX - 1)
1166
39e6dea2
PNA
1167/**
1168 * enum nft_fwd_attributes - nf_tables fwd expression netlink attributes
1169 *
1170 * @NFTA_FWD_SREG_DEV: source register of output interface (NLA_U32: nft_register)
1171 */
1172enum nft_fwd_attributes {
1173 NFTA_FWD_UNSPEC,
1174 NFTA_FWD_SREG_DEV,
1175 __NFTA_FWD_MAX
1176};
1177#define NFTA_FWD_MAX (__NFTA_FWD_MAX - 1)
1178
c97d22e6
PNA
1179/**
1180 * enum nft_objref_attributes - nf_tables stateful object expression netlink attributes
1181 *
1182 * @NFTA_OBJREF_IMM_TYPE: object type for immediate reference (NLA_U32: nft_register)
1183 * @NFTA_OBJREF_IMM_NAME: object name for immediate reference (NLA_STRING)
63aea290
PNA
1184 * @NFTA_OBJREF_SET_SREG: source register of the data to look for (NLA_U32: nft_registers)
1185 * @NFTA_OBJREF_SET_NAME: name of the set where to look for (NLA_STRING)
1186 * @NFTA_OBJREF_SET_ID: id of the set where to look for in this transaction (NLA_U32)
c97d22e6
PNA
1187 */
1188enum nft_objref_attributes {
1189 NFTA_OBJREF_UNSPEC,
1190 NFTA_OBJREF_IMM_TYPE,
1191 NFTA_OBJREF_IMM_NAME,
63aea290
PNA
1192 NFTA_OBJREF_SET_SREG,
1193 NFTA_OBJREF_SET_NAME,
1194 NFTA_OBJREF_SET_ID,
c97d22e6
PNA
1195 __NFTA_OBJREF_MAX
1196};
1197#define NFTA_OBJREF_MAX (__NFTA_OBJREF_MAX - 1)
1198
84d7fce6
PNA
1199/**
1200 * enum nft_gen_attributes - nf_tables ruleset generation attributes
1201 *
1202 * @NFTA_GEN_ID: Ruleset generation ID (NLA_U32)
1203 */
1204enum nft_gen_attributes {
1205 NFTA_GEN_UNSPEC,
1206 NFTA_GEN_ID,
1207 __NFTA_GEN_MAX
1208};
1209#define NFTA_GEN_MAX (__NFTA_GEN_MAX - 1)
1210
f6d0cbcf
FW
1211/*
1212 * enum nft_fib_attributes - nf_tables fib expression netlink attributes
1213 *
1214 * @NFTA_FIB_DREG: destination register (NLA_U32)
1215 * @NFTA_FIB_RESULT: desired result (NLA_U32)
1216 * @NFTA_FIB_FLAGS: flowi fields to initialize when querying the FIB (NLA_U32)
1217 *
1218 * The FIB expression performs a route lookup according
1219 * to the packet data.
1220 */
1221enum nft_fib_attributes {
1222 NFTA_FIB_UNSPEC,
1223 NFTA_FIB_DREG,
1224 NFTA_FIB_RESULT,
1225 NFTA_FIB_FLAGS,
1226 __NFTA_FIB_MAX
1227};
1228#define NFTA_FIB_MAX (__NFTA_FIB_MAX - 1)
1229
1230enum nft_fib_result {
1231 NFT_FIB_RESULT_UNSPEC,
1232 NFT_FIB_RESULT_OIF,
1233 NFT_FIB_RESULT_OIFNAME,
1234 NFT_FIB_RESULT_ADDRTYPE,
1235 __NFT_FIB_RESULT_MAX
1236};
1237#define NFT_FIB_RESULT_MAX (__NFT_FIB_RESULT_MAX - 1)
1238
1239enum nft_fib_flags {
1240 NFTA_FIB_F_SADDR = 1 << 0, /* look up src */
1241 NFTA_FIB_F_DADDR = 1 << 1, /* look up dst */
1242 NFTA_FIB_F_MARK = 1 << 2, /* use skb->mark */
1243 NFTA_FIB_F_IIF = 1 << 3, /* restrict to iif */
1244 NFTA_FIB_F_OIF = 1 << 4, /* restrict to oif */
1245};
1246
e5009240 1247#define NFT_OBJECT_UNSPEC 0
b1ce0ced 1248#define NFT_OBJECT_COUNTER 1
173705d9 1249#define NFT_OBJECT_QUOTA 2
8aeff920
PNA
1250#define __NFT_OBJECT_MAX 3
1251#define NFT_OBJECT_MAX (__NFT_OBJECT_MAX - 1)
e5009240
PNA
1252
1253/**
1254 * enum nft_object_attributes - nf_tables stateful object netlink attributes
1255 *
1256 * @NFTA_OBJ_TABLE: name of the table containing the expression (NLA_STRING)
1257 * @NFTA_OBJ_NAME: name of this expression type (NLA_STRING)
1258 * @NFTA_OBJ_TYPE: stateful object type (NLA_U32)
1259 * @NFTA_OBJ_DATA: stateful object data (NLA_NESTED)
1260 * @NFTA_OBJ_USE: number of references to this expression (NLA_U32)
1261 */
1262enum nft_object_attributes {
1263 NFTA_OBJ_UNSPEC,
1264 NFTA_OBJ_TABLE,
1265 NFTA_OBJ_NAME,
1266 NFTA_OBJ_TYPE,
1267 NFTA_OBJ_DATA,
1268 NFTA_OBJ_USE,
1269 __NFTA_OBJ_MAX
1270};
1271#define NFTA_OBJ_MAX (__NFTA_OBJ_MAX - 1)
1272
33d5a7b1
FW
1273/**
1274 * enum nft_trace_attributes - nf_tables trace netlink attributes
1275 *
1276 * @NFTA_TRACE_TABLE: name of the table (NLA_STRING)
1277 * @NFTA_TRACE_CHAIN: name of the chain (NLA_STRING)
1278 * @NFTA_TRACE_RULE_HANDLE: numeric handle of the rule (NLA_U64)
1279 * @NFTA_TRACE_TYPE: type of the event (NLA_U32: nft_trace_types)
1280 * @NFTA_TRACE_VERDICT: verdict returned by hook (NLA_NESTED: nft_verdicts)
1281 * @NFTA_TRACE_ID: pseudo-id, same for each skb traced (NLA_U32)
1282 * @NFTA_TRACE_LL_HEADER: linklayer header (NLA_BINARY)
1283 * @NFTA_TRACE_NETWORK_HEADER: network header (NLA_BINARY)
1284 * @NFTA_TRACE_TRANSPORT_HEADER: transport header (NLA_BINARY)
1285 * @NFTA_TRACE_IIF: indev ifindex (NLA_U32)
1286 * @NFTA_TRACE_IIFTYPE: netdev->type of indev (NLA_U16)
1287 * @NFTA_TRACE_OIF: outdev ifindex (NLA_U32)
1288 * @NFTA_TRACE_OIFTYPE: netdev->type of outdev (NLA_U16)
1289 * @NFTA_TRACE_MARK: nfmark (NLA_U32)
1290 * @NFTA_TRACE_NFPROTO: nf protocol processed (NLA_U32)
1291 * @NFTA_TRACE_POLICY: policy that decided fate of packet (NLA_U32)
1292 */
b43f9569 1293enum nft_trace_attributes {
33d5a7b1
FW
1294 NFTA_TRACE_UNSPEC,
1295 NFTA_TRACE_TABLE,
1296 NFTA_TRACE_CHAIN,
1297 NFTA_TRACE_RULE_HANDLE,
1298 NFTA_TRACE_TYPE,
1299 NFTA_TRACE_VERDICT,
1300 NFTA_TRACE_ID,
1301 NFTA_TRACE_LL_HEADER,
1302 NFTA_TRACE_NETWORK_HEADER,
1303 NFTA_TRACE_TRANSPORT_HEADER,
1304 NFTA_TRACE_IIF,
1305 NFTA_TRACE_IIFTYPE,
1306 NFTA_TRACE_OIF,
1307 NFTA_TRACE_OIFTYPE,
1308 NFTA_TRACE_MARK,
1309 NFTA_TRACE_NFPROTO,
1310 NFTA_TRACE_POLICY,
b46f6ded 1311 NFTA_TRACE_PAD,
33d5a7b1
FW
1312 __NFTA_TRACE_MAX
1313};
1314#define NFTA_TRACE_MAX (__NFTA_TRACE_MAX - 1)
1315
1316enum nft_trace_types {
1317 NFT_TRACETYPE_UNSPEC,
1318 NFT_TRACETYPE_POLICY,
1319 NFT_TRACETYPE_RETURN,
1320 NFT_TRACETYPE_RULE,
1321 __NFT_TRACETYPE_MAX
1322};
1323#define NFT_TRACETYPE_MAX (__NFT_TRACETYPE_MAX - 1)
91dbc6be
LGL
1324
1325/**
1326 * enum nft_ng_attributes - nf_tables number generator expression netlink attributes
1327 *
1328 * @NFTA_NG_DREG: destination register (NLA_U32)
0d9932b2 1329 * @NFTA_NG_MODULUS: maximum counter value (NLA_U32)
91dbc6be 1330 * @NFTA_NG_TYPE: operation type (NLA_U32)
2b03bf73 1331 * @NFTA_NG_OFFSET: offset to be added to the counter (NLA_U32)
91dbc6be
LGL
1332 */
1333enum nft_ng_attributes {
1334 NFTA_NG_UNSPEC,
1335 NFTA_NG_DREG,
0d9932b2 1336 NFTA_NG_MODULUS,
91dbc6be 1337 NFTA_NG_TYPE,
2b03bf73 1338 NFTA_NG_OFFSET,
91dbc6be
LGL
1339 __NFTA_NG_MAX
1340};
1341#define NFTA_NG_MAX (__NFTA_NG_MAX - 1)
1342
1343enum nft_ng_types {
1344 NFT_NG_INCREMENTAL,
1345 NFT_NG_RANDOM,
1346 __NFT_NG_MAX
1347};
1348#define NFT_NG_MAX (__NFT_NG_MAX - 1)
1349
96518518 1350#endif /* _LINUX_NF_TABLES_H */