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