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 #define NFT_OSF_MAXGENRELEN 16 12 13 /** 14 * enum nft_registers - nf_tables registers 15 * 16 * nf_tables used to have five registers: a verdict register and four data 17 * registers of size 16. The data registers have been changed to 16 registers 18 * of size 4. For compatibility reasons, the NFT_REG_[1-4] registers still 19 * map to areas of size 16, the 4 byte registers are addressed using 20 * NFT_REG32_00 - NFT_REG32_15. 21 */ 22 enum nft_registers { 23 NFT_REG_VERDICT, 24 NFT_REG_1, 25 NFT_REG_2, 26 NFT_REG_3, 27 NFT_REG_4, 28 __NFT_REG_MAX, 29 30 NFT_REG32_00 = 8, 31 NFT_REG32_01, 32 NFT_REG32_02, 33 NFT_REG32_03, 34 NFT_REG32_04, 35 NFT_REG32_05, 36 NFT_REG32_06, 37 NFT_REG32_07, 38 NFT_REG32_08, 39 NFT_REG32_09, 40 NFT_REG32_10, 41 NFT_REG32_11, 42 NFT_REG32_12, 43 NFT_REG32_13, 44 NFT_REG32_14, 45 NFT_REG32_15, 46 }; 47 #define NFT_REG_MAX (__NFT_REG_MAX - 1) 48 49 #define NFT_REG_SIZE 16 50 #define NFT_REG32_SIZE 4 51 #define NFT_REG32_COUNT (NFT_REG32_15 - NFT_REG32_00 + 1) 52 53 /** 54 * enum nft_verdicts - nf_tables internal verdicts 55 * 56 * @NFT_CONTINUE: continue evaluation of the current rule 57 * @NFT_BREAK: terminate evaluation of the current rule 58 * @NFT_JUMP: push the current chain on the jump stack and jump to a chain 59 * @NFT_GOTO: jump to a chain without pushing the current chain on the jump stack 60 * @NFT_RETURN: return to the topmost chain on the jump stack 61 * 62 * The nf_tables verdicts share their numeric space with the netfilter verdicts. 63 */ 64 enum nft_verdicts { 65 NFT_CONTINUE = -1, 66 NFT_BREAK = -2, 67 NFT_JUMP = -3, 68 NFT_GOTO = -4, 69 NFT_RETURN = -5, 70 }; 71 72 /** 73 * enum nf_tables_msg_types - nf_tables netlink message types 74 * 75 * @NFT_MSG_NEWTABLE: create a new table (enum nft_table_attributes) 76 * @NFT_MSG_GETTABLE: get a table (enum nft_table_attributes) 77 * @NFT_MSG_DELTABLE: delete a table (enum nft_table_attributes) 78 * @NFT_MSG_NEWCHAIN: create a new chain (enum nft_chain_attributes) 79 * @NFT_MSG_GETCHAIN: get a chain (enum nft_chain_attributes) 80 * @NFT_MSG_DELCHAIN: delete a chain (enum nft_chain_attributes) 81 * @NFT_MSG_NEWRULE: create a new rule (enum nft_rule_attributes) 82 * @NFT_MSG_GETRULE: get a rule (enum nft_rule_attributes) 83 * @NFT_MSG_DELRULE: delete a rule (enum nft_rule_attributes) 84 * @NFT_MSG_NEWSET: create a new set (enum nft_set_attributes) 85 * @NFT_MSG_GETSET: get a set (enum nft_set_attributes) 86 * @NFT_MSG_DELSET: delete a set (enum nft_set_attributes) 87 * @NFT_MSG_NEWSETELEM: create a new set element (enum nft_set_elem_attributes) 88 * @NFT_MSG_GETSETELEM: get a set element (enum nft_set_elem_attributes) 89 * @NFT_MSG_DELSETELEM: delete a set element (enum nft_set_elem_attributes) 90 * @NFT_MSG_NEWGEN: announce a new generation, only for events (enum nft_gen_attributes) 91 * @NFT_MSG_GETGEN: get the rule-set generation (enum nft_gen_attributes) 92 * @NFT_MSG_TRACE: trace event (enum nft_trace_attributes) 93 * @NFT_MSG_NEWOBJ: create a stateful object (enum nft_obj_attributes) 94 * @NFT_MSG_GETOBJ: get a stateful object (enum nft_obj_attributes) 95 * @NFT_MSG_DELOBJ: delete a stateful object (enum nft_obj_attributes) 96 * @NFT_MSG_GETOBJ_RESET: get and reset a stateful object (enum nft_obj_attributes) 97 * @NFT_MSG_NEWFLOWTABLE: add new flow table (enum nft_flowtable_attributes) 98 * @NFT_MSG_GETFLOWTABLE: get flow table (enum nft_flowtable_attributes) 99 * @NFT_MSG_DELFLOWTABLE: delete flow table (enum nft_flowtable_attributes) 100 */ 101 enum nf_tables_msg_types { 102 NFT_MSG_NEWTABLE, 103 NFT_MSG_GETTABLE, 104 NFT_MSG_DELTABLE, 105 NFT_MSG_NEWCHAIN, 106 NFT_MSG_GETCHAIN, 107 NFT_MSG_DELCHAIN, 108 NFT_MSG_NEWRULE, 109 NFT_MSG_GETRULE, 110 NFT_MSG_DELRULE, 111 NFT_MSG_NEWSET, 112 NFT_MSG_GETSET, 113 NFT_MSG_DELSET, 114 NFT_MSG_NEWSETELEM, 115 NFT_MSG_GETSETELEM, 116 NFT_MSG_DELSETELEM, 117 NFT_MSG_NEWGEN, 118 NFT_MSG_GETGEN, 119 NFT_MSG_TRACE, 120 NFT_MSG_NEWOBJ, 121 NFT_MSG_GETOBJ, 122 NFT_MSG_DELOBJ, 123 NFT_MSG_GETOBJ_RESET, 124 NFT_MSG_NEWFLOWTABLE, 125 NFT_MSG_GETFLOWTABLE, 126 NFT_MSG_DELFLOWTABLE, 127 NFT_MSG_MAX, 128 }; 129 130 /** 131 * enum nft_list_attributes - nf_tables generic list netlink attributes 132 * 133 * @NFTA_LIST_ELEM: list element (NLA_NESTED) 134 */ 135 enum nft_list_attributes { 136 NFTA_LIST_UNSPEC, 137 NFTA_LIST_ELEM, 138 __NFTA_LIST_MAX 139 }; 140 #define NFTA_LIST_MAX (__NFTA_LIST_MAX - 1) 141 142 /** 143 * enum nft_hook_attributes - nf_tables netfilter hook netlink attributes 144 * 145 * @NFTA_HOOK_HOOKNUM: netfilter hook number (NLA_U32) 146 * @NFTA_HOOK_PRIORITY: netfilter hook priority (NLA_U32) 147 * @NFTA_HOOK_DEV: netdevice name (NLA_STRING) 148 * @NFTA_HOOK_DEVS: list of netdevices (NLA_NESTED) 149 */ 150 enum nft_hook_attributes { 151 NFTA_HOOK_UNSPEC, 152 NFTA_HOOK_HOOKNUM, 153 NFTA_HOOK_PRIORITY, 154 NFTA_HOOK_DEV, 155 NFTA_HOOK_DEVS, 156 __NFTA_HOOK_MAX 157 }; 158 #define NFTA_HOOK_MAX (__NFTA_HOOK_MAX - 1) 159 160 /** 161 * enum nft_table_flags - nf_tables table flags 162 * 163 * @NFT_TABLE_F_DORMANT: this table is not active 164 */ 165 enum nft_table_flags { 166 NFT_TABLE_F_DORMANT = 0x1, 167 }; 168 169 /** 170 * enum nft_table_attributes - nf_tables table netlink attributes 171 * 172 * @NFTA_TABLE_NAME: name of the table (NLA_STRING) 173 * @NFTA_TABLE_FLAGS: bitmask of enum nft_table_flags (NLA_U32) 174 * @NFTA_TABLE_USE: number of chains in this table (NLA_U32) 175 * @NFTA_TABLE_USERDATA: user data (NLA_BINARY) 176 */ 177 enum nft_table_attributes { 178 NFTA_TABLE_UNSPEC, 179 NFTA_TABLE_NAME, 180 NFTA_TABLE_FLAGS, 181 NFTA_TABLE_USE, 182 NFTA_TABLE_HANDLE, 183 NFTA_TABLE_PAD, 184 NFTA_TABLE_USERDATA, 185 __NFTA_TABLE_MAX 186 }; 187 #define NFTA_TABLE_MAX (__NFTA_TABLE_MAX - 1) 188 189 enum nft_chain_flags { 190 NFT_CHAIN_BASE = (1 << 0), 191 NFT_CHAIN_HW_OFFLOAD = (1 << 1), 192 NFT_CHAIN_BINDING = (1 << 2), 193 }; 194 #define NFT_CHAIN_FLAGS (NFT_CHAIN_BASE | \ 195 NFT_CHAIN_HW_OFFLOAD | \ 196 NFT_CHAIN_BINDING) 197 198 /** 199 * enum nft_chain_attributes - nf_tables chain netlink attributes 200 * 201 * @NFTA_CHAIN_TABLE: name of the table containing the chain (NLA_STRING) 202 * @NFTA_CHAIN_HANDLE: numeric handle of the chain (NLA_U64) 203 * @NFTA_CHAIN_NAME: name of the chain (NLA_STRING) 204 * @NFTA_CHAIN_HOOK: hook specification for basechains (NLA_NESTED: nft_hook_attributes) 205 * @NFTA_CHAIN_POLICY: numeric policy of the chain (NLA_U32) 206 * @NFTA_CHAIN_USE: number of references to this chain (NLA_U32) 207 * @NFTA_CHAIN_TYPE: type name of the string (NLA_NUL_STRING) 208 * @NFTA_CHAIN_COUNTERS: counter specification of the chain (NLA_NESTED: nft_counter_attributes) 209 * @NFTA_CHAIN_FLAGS: chain flags 210 * @NFTA_CHAIN_ID: uniquely identifies a chain in a transaction (NLA_U32) 211 * @NFTA_CHAIN_USERDATA: user data (NLA_BINARY) 212 */ 213 enum nft_chain_attributes { 214 NFTA_CHAIN_UNSPEC, 215 NFTA_CHAIN_TABLE, 216 NFTA_CHAIN_HANDLE, 217 NFTA_CHAIN_NAME, 218 NFTA_CHAIN_HOOK, 219 NFTA_CHAIN_POLICY, 220 NFTA_CHAIN_USE, 221 NFTA_CHAIN_TYPE, 222 NFTA_CHAIN_COUNTERS, 223 NFTA_CHAIN_PAD, 224 NFTA_CHAIN_FLAGS, 225 NFTA_CHAIN_ID, 226 NFTA_CHAIN_USERDATA, 227 __NFTA_CHAIN_MAX 228 }; 229 #define NFTA_CHAIN_MAX (__NFTA_CHAIN_MAX - 1) 230 231 /** 232 * enum nft_rule_attributes - nf_tables rule netlink attributes 233 * 234 * @NFTA_RULE_TABLE: name of the table containing the rule (NLA_STRING) 235 * @NFTA_RULE_CHAIN: name of the chain containing the rule (NLA_STRING) 236 * @NFTA_RULE_HANDLE: numeric handle of the rule (NLA_U64) 237 * @NFTA_RULE_EXPRESSIONS: list of expressions (NLA_NESTED: nft_expr_attributes) 238 * @NFTA_RULE_COMPAT: compatibility specifications of the rule (NLA_NESTED: nft_rule_compat_attributes) 239 * @NFTA_RULE_POSITION: numeric handle of the previous rule (NLA_U64) 240 * @NFTA_RULE_USERDATA: user data (NLA_BINARY, NFT_USERDATA_MAXLEN) 241 * @NFTA_RULE_ID: uniquely identifies a rule in a transaction (NLA_U32) 242 * @NFTA_RULE_POSITION_ID: transaction unique identifier of the previous rule (NLA_U32) 243 */ 244 enum nft_rule_attributes { 245 NFTA_RULE_UNSPEC, 246 NFTA_RULE_TABLE, 247 NFTA_RULE_CHAIN, 248 NFTA_RULE_HANDLE, 249 NFTA_RULE_EXPRESSIONS, 250 NFTA_RULE_COMPAT, 251 NFTA_RULE_POSITION, 252 NFTA_RULE_USERDATA, 253 NFTA_RULE_PAD, 254 NFTA_RULE_ID, 255 NFTA_RULE_POSITION_ID, 256 NFTA_RULE_CHAIN_ID, 257 __NFTA_RULE_MAX 258 }; 259 #define NFTA_RULE_MAX (__NFTA_RULE_MAX - 1) 260 261 /** 262 * enum nft_rule_compat_flags - nf_tables rule compat flags 263 * 264 * @NFT_RULE_COMPAT_F_INV: invert the check result 265 */ 266 enum nft_rule_compat_flags { 267 NFT_RULE_COMPAT_F_INV = (1 << 1), 268 NFT_RULE_COMPAT_F_MASK = NFT_RULE_COMPAT_F_INV, 269 }; 270 271 /** 272 * enum nft_rule_compat_attributes - nf_tables rule compat attributes 273 * 274 * @NFTA_RULE_COMPAT_PROTO: numeric value of handled protocol (NLA_U32) 275 * @NFTA_RULE_COMPAT_FLAGS: bitmask of enum nft_rule_compat_flags (NLA_U32) 276 */ 277 enum nft_rule_compat_attributes { 278 NFTA_RULE_COMPAT_UNSPEC, 279 NFTA_RULE_COMPAT_PROTO, 280 NFTA_RULE_COMPAT_FLAGS, 281 __NFTA_RULE_COMPAT_MAX 282 }; 283 #define NFTA_RULE_COMPAT_MAX (__NFTA_RULE_COMPAT_MAX - 1) 284 285 /** 286 * enum nft_set_flags - nf_tables set flags 287 * 288 * @NFT_SET_ANONYMOUS: name allocation, automatic cleanup on unlink 289 * @NFT_SET_CONSTANT: set contents may not change while bound 290 * @NFT_SET_INTERVAL: set contains intervals 291 * @NFT_SET_MAP: set is used as a dictionary 292 * @NFT_SET_TIMEOUT: set uses timeouts 293 * @NFT_SET_EVAL: set can be updated from the evaluation path 294 * @NFT_SET_OBJECT: set contains stateful objects 295 * @NFT_SET_CONCAT: set contains a concatenation 296 */ 297 enum nft_set_flags { 298 NFT_SET_ANONYMOUS = 0x1, 299 NFT_SET_CONSTANT = 0x2, 300 NFT_SET_INTERVAL = 0x4, 301 NFT_SET_MAP = 0x8, 302 NFT_SET_TIMEOUT = 0x10, 303 NFT_SET_EVAL = 0x20, 304 NFT_SET_OBJECT = 0x40, 305 NFT_SET_CONCAT = 0x80, 306 }; 307 308 /** 309 * enum nft_set_policies - set selection policy 310 * 311 * @NFT_SET_POL_PERFORMANCE: prefer high performance over low memory use 312 * @NFT_SET_POL_MEMORY: prefer low memory use over high performance 313 */ 314 enum nft_set_policies { 315 NFT_SET_POL_PERFORMANCE, 316 NFT_SET_POL_MEMORY, 317 }; 318 319 /** 320 * enum nft_set_desc_attributes - set element description 321 * 322 * @NFTA_SET_DESC_SIZE: number of elements in set (NLA_U32) 323 * @NFTA_SET_DESC_CONCAT: description of field concatenation (NLA_NESTED) 324 */ 325 enum nft_set_desc_attributes { 326 NFTA_SET_DESC_UNSPEC, 327 NFTA_SET_DESC_SIZE, 328 NFTA_SET_DESC_CONCAT, 329 __NFTA_SET_DESC_MAX 330 }; 331 #define NFTA_SET_DESC_MAX (__NFTA_SET_DESC_MAX - 1) 332 333 /** 334 * enum nft_set_field_attributes - attributes of concatenated fields 335 * 336 * @NFTA_SET_FIELD_LEN: length of single field, in bits (NLA_U32) 337 */ 338 enum nft_set_field_attributes { 339 NFTA_SET_FIELD_UNSPEC, 340 NFTA_SET_FIELD_LEN, 341 __NFTA_SET_FIELD_MAX 342 }; 343 #define NFTA_SET_FIELD_MAX (__NFTA_SET_FIELD_MAX - 1) 344 345 /** 346 * enum nft_set_attributes - nf_tables set netlink attributes 347 * 348 * @NFTA_SET_TABLE: table name (NLA_STRING) 349 * @NFTA_SET_NAME: set name (NLA_STRING) 350 * @NFTA_SET_FLAGS: bitmask of enum nft_set_flags (NLA_U32) 351 * @NFTA_SET_KEY_TYPE: key data type, informational purpose only (NLA_U32) 352 * @NFTA_SET_KEY_LEN: key data length (NLA_U32) 353 * @NFTA_SET_DATA_TYPE: mapping data type (NLA_U32) 354 * @NFTA_SET_DATA_LEN: mapping data length (NLA_U32) 355 * @NFTA_SET_POLICY: selection policy (NLA_U32) 356 * @NFTA_SET_DESC: set description (NLA_NESTED) 357 * @NFTA_SET_ID: uniquely identifies a set in a transaction (NLA_U32) 358 * @NFTA_SET_TIMEOUT: default timeout value (NLA_U64) 359 * @NFTA_SET_GC_INTERVAL: garbage collection interval (NLA_U32) 360 * @NFTA_SET_USERDATA: user data (NLA_BINARY) 361 * @NFTA_SET_OBJ_TYPE: stateful object type (NLA_U32: NFT_OBJECT_*) 362 * @NFTA_SET_HANDLE: set handle (NLA_U64) 363 * @NFTA_SET_EXPR: set expression (NLA_NESTED: nft_expr_attributes) 364 */ 365 enum nft_set_attributes { 366 NFTA_SET_UNSPEC, 367 NFTA_SET_TABLE, 368 NFTA_SET_NAME, 369 NFTA_SET_FLAGS, 370 NFTA_SET_KEY_TYPE, 371 NFTA_SET_KEY_LEN, 372 NFTA_SET_DATA_TYPE, 373 NFTA_SET_DATA_LEN, 374 NFTA_SET_POLICY, 375 NFTA_SET_DESC, 376 NFTA_SET_ID, 377 NFTA_SET_TIMEOUT, 378 NFTA_SET_GC_INTERVAL, 379 NFTA_SET_USERDATA, 380 NFTA_SET_PAD, 381 NFTA_SET_OBJ_TYPE, 382 NFTA_SET_HANDLE, 383 NFTA_SET_EXPR, 384 __NFTA_SET_MAX 385 }; 386 #define NFTA_SET_MAX (__NFTA_SET_MAX - 1) 387 388 /** 389 * enum nft_set_elem_flags - nf_tables set element flags 390 * 391 * @NFT_SET_ELEM_INTERVAL_END: element ends the previous interval 392 */ 393 enum nft_set_elem_flags { 394 NFT_SET_ELEM_INTERVAL_END = 0x1, 395 }; 396 397 /** 398 * enum nft_set_elem_attributes - nf_tables set element netlink attributes 399 * 400 * @NFTA_SET_ELEM_KEY: key value (NLA_NESTED: nft_data) 401 * @NFTA_SET_ELEM_DATA: data value of mapping (NLA_NESTED: nft_data_attributes) 402 * @NFTA_SET_ELEM_FLAGS: bitmask of nft_set_elem_flags (NLA_U32) 403 * @NFTA_SET_ELEM_TIMEOUT: timeout value (NLA_U64) 404 * @NFTA_SET_ELEM_EXPIRATION: expiration time (NLA_U64) 405 * @NFTA_SET_ELEM_USERDATA: user data (NLA_BINARY) 406 * @NFTA_SET_ELEM_EXPR: expression (NLA_NESTED: nft_expr_attributes) 407 * @NFTA_SET_ELEM_OBJREF: stateful object reference (NLA_STRING) 408 * @NFTA_SET_ELEM_KEY_END: closing key value (NLA_NESTED: nft_data) 409 */ 410 enum nft_set_elem_attributes { 411 NFTA_SET_ELEM_UNSPEC, 412 NFTA_SET_ELEM_KEY, 413 NFTA_SET_ELEM_DATA, 414 NFTA_SET_ELEM_FLAGS, 415 NFTA_SET_ELEM_TIMEOUT, 416 NFTA_SET_ELEM_EXPIRATION, 417 NFTA_SET_ELEM_USERDATA, 418 NFTA_SET_ELEM_EXPR, 419 NFTA_SET_ELEM_PAD, 420 NFTA_SET_ELEM_OBJREF, 421 NFTA_SET_ELEM_KEY_END, 422 __NFTA_SET_ELEM_MAX 423 }; 424 #define NFTA_SET_ELEM_MAX (__NFTA_SET_ELEM_MAX - 1) 425 426 /** 427 * enum nft_set_elem_list_attributes - nf_tables set element list netlink attributes 428 * 429 * @NFTA_SET_ELEM_LIST_TABLE: table of the set to be changed (NLA_STRING) 430 * @NFTA_SET_ELEM_LIST_SET: name of the set to be changed (NLA_STRING) 431 * @NFTA_SET_ELEM_LIST_ELEMENTS: list of set elements (NLA_NESTED: nft_set_elem_attributes) 432 * @NFTA_SET_ELEM_LIST_SET_ID: uniquely identifies a set in a transaction (NLA_U32) 433 */ 434 enum nft_set_elem_list_attributes { 435 NFTA_SET_ELEM_LIST_UNSPEC, 436 NFTA_SET_ELEM_LIST_TABLE, 437 NFTA_SET_ELEM_LIST_SET, 438 NFTA_SET_ELEM_LIST_ELEMENTS, 439 NFTA_SET_ELEM_LIST_SET_ID, 440 __NFTA_SET_ELEM_LIST_MAX 441 }; 442 #define NFTA_SET_ELEM_LIST_MAX (__NFTA_SET_ELEM_LIST_MAX - 1) 443 444 /** 445 * enum nft_data_types - nf_tables data types 446 * 447 * @NFT_DATA_VALUE: generic data 448 * @NFT_DATA_VERDICT: netfilter verdict 449 * 450 * The type of data is usually determined by the kernel directly and is not 451 * explicitly specified by userspace. The only difference are sets, where 452 * userspace specifies the key and mapping data types. 453 * 454 * The values 0xffffff00-0xffffffff are reserved for internally used types. 455 * The remaining range can be freely used by userspace to encode types, all 456 * values are equivalent to NFT_DATA_VALUE. 457 */ 458 enum nft_data_types { 459 NFT_DATA_VALUE, 460 NFT_DATA_VERDICT = 0xffffff00U, 461 }; 462 463 #define NFT_DATA_RESERVED_MASK 0xffffff00U 464 465 /** 466 * enum nft_data_attributes - nf_tables data netlink attributes 467 * 468 * @NFTA_DATA_VALUE: generic data (NLA_BINARY) 469 * @NFTA_DATA_VERDICT: nf_tables verdict (NLA_NESTED: nft_verdict_attributes) 470 */ 471 enum nft_data_attributes { 472 NFTA_DATA_UNSPEC, 473 NFTA_DATA_VALUE, 474 NFTA_DATA_VERDICT, 475 __NFTA_DATA_MAX 476 }; 477 #define NFTA_DATA_MAX (__NFTA_DATA_MAX - 1) 478 479 /* Maximum length of a value */ 480 #define NFT_DATA_VALUE_MAXLEN 64 481 482 /** 483 * enum nft_verdict_attributes - nf_tables verdict netlink attributes 484 * 485 * @NFTA_VERDICT_CODE: nf_tables verdict (NLA_U32: enum nft_verdicts) 486 * @NFTA_VERDICT_CHAIN: jump target chain name (NLA_STRING) 487 * @NFTA_VERDICT_CHAIN_ID: jump target chain ID (NLA_U32) 488 */ 489 enum nft_verdict_attributes { 490 NFTA_VERDICT_UNSPEC, 491 NFTA_VERDICT_CODE, 492 NFTA_VERDICT_CHAIN, 493 NFTA_VERDICT_CHAIN_ID, 494 __NFTA_VERDICT_MAX 495 }; 496 #define NFTA_VERDICT_MAX (__NFTA_VERDICT_MAX - 1) 497 498 /** 499 * enum nft_expr_attributes - nf_tables expression netlink attributes 500 * 501 * @NFTA_EXPR_NAME: name of the expression type (NLA_STRING) 502 * @NFTA_EXPR_DATA: type specific data (NLA_NESTED) 503 */ 504 enum nft_expr_attributes { 505 NFTA_EXPR_UNSPEC, 506 NFTA_EXPR_NAME, 507 NFTA_EXPR_DATA, 508 __NFTA_EXPR_MAX 509 }; 510 #define NFTA_EXPR_MAX (__NFTA_EXPR_MAX - 1) 511 512 /** 513 * enum nft_immediate_attributes - nf_tables immediate expression netlink attributes 514 * 515 * @NFTA_IMMEDIATE_DREG: destination register to load data into (NLA_U32) 516 * @NFTA_IMMEDIATE_DATA: data to load (NLA_NESTED: nft_data_attributes) 517 */ 518 enum nft_immediate_attributes { 519 NFTA_IMMEDIATE_UNSPEC, 520 NFTA_IMMEDIATE_DREG, 521 NFTA_IMMEDIATE_DATA, 522 __NFTA_IMMEDIATE_MAX 523 }; 524 #define NFTA_IMMEDIATE_MAX (__NFTA_IMMEDIATE_MAX - 1) 525 526 /** 527 * enum nft_bitwise_ops - nf_tables bitwise operations 528 * 529 * @NFT_BITWISE_BOOL: mask-and-xor operation used to implement NOT, AND, OR and 530 * XOR boolean operations 531 * @NFT_BITWISE_LSHIFT: left-shift operation 532 * @NFT_BITWISE_RSHIFT: right-shift operation 533 */ 534 enum nft_bitwise_ops { 535 NFT_BITWISE_BOOL, 536 NFT_BITWISE_LSHIFT, 537 NFT_BITWISE_RSHIFT, 538 }; 539 540 /** 541 * enum nft_bitwise_attributes - nf_tables bitwise expression netlink attributes 542 * 543 * @NFTA_BITWISE_SREG: source register (NLA_U32: nft_registers) 544 * @NFTA_BITWISE_DREG: destination register (NLA_U32: nft_registers) 545 * @NFTA_BITWISE_LEN: length of operands (NLA_U32) 546 * @NFTA_BITWISE_MASK: mask value (NLA_NESTED: nft_data_attributes) 547 * @NFTA_BITWISE_XOR: xor value (NLA_NESTED: nft_data_attributes) 548 * @NFTA_BITWISE_OP: type of operation (NLA_U32: nft_bitwise_ops) 549 * @NFTA_BITWISE_DATA: argument for non-boolean operations 550 * (NLA_NESTED: nft_data_attributes) 551 * 552 * The bitwise expression supports boolean and shift operations. It implements 553 * the boolean operations by performing the following operation: 554 * 555 * dreg = (sreg & mask) ^ xor 556 * 557 * with these mask and xor values: 558 * 559 * mask xor 560 * NOT: 1 1 561 * OR: ~x x 562 * XOR: 1 x 563 * AND: x 0 564 */ 565 enum nft_bitwise_attributes { 566 NFTA_BITWISE_UNSPEC, 567 NFTA_BITWISE_SREG, 568 NFTA_BITWISE_DREG, 569 NFTA_BITWISE_LEN, 570 NFTA_BITWISE_MASK, 571 NFTA_BITWISE_XOR, 572 NFTA_BITWISE_OP, 573 NFTA_BITWISE_DATA, 574 __NFTA_BITWISE_MAX 575 }; 576 #define NFTA_BITWISE_MAX (__NFTA_BITWISE_MAX - 1) 577 578 /** 579 * enum nft_byteorder_ops - nf_tables byteorder operators 580 * 581 * @NFT_BYTEORDER_NTOH: network to host operator 582 * @NFT_BYTEORDER_HTON: host to network operator 583 */ 584 enum nft_byteorder_ops { 585 NFT_BYTEORDER_NTOH, 586 NFT_BYTEORDER_HTON, 587 }; 588 589 /** 590 * enum nft_byteorder_attributes - nf_tables byteorder expression netlink attributes 591 * 592 * @NFTA_BYTEORDER_SREG: source register (NLA_U32: nft_registers) 593 * @NFTA_BYTEORDER_DREG: destination register (NLA_U32: nft_registers) 594 * @NFTA_BYTEORDER_OP: operator (NLA_U32: enum nft_byteorder_ops) 595 * @NFTA_BYTEORDER_LEN: length of the data (NLA_U32) 596 * @NFTA_BYTEORDER_SIZE: data size in bytes (NLA_U32: 2 or 4) 597 */ 598 enum nft_byteorder_attributes { 599 NFTA_BYTEORDER_UNSPEC, 600 NFTA_BYTEORDER_SREG, 601 NFTA_BYTEORDER_DREG, 602 NFTA_BYTEORDER_OP, 603 NFTA_BYTEORDER_LEN, 604 NFTA_BYTEORDER_SIZE, 605 __NFTA_BYTEORDER_MAX 606 }; 607 #define NFTA_BYTEORDER_MAX (__NFTA_BYTEORDER_MAX - 1) 608 609 /** 610 * enum nft_cmp_ops - nf_tables relational operator 611 * 612 * @NFT_CMP_EQ: equal 613 * @NFT_CMP_NEQ: not equal 614 * @NFT_CMP_LT: less than 615 * @NFT_CMP_LTE: less than or equal to 616 * @NFT_CMP_GT: greater than 617 * @NFT_CMP_GTE: greater than or equal to 618 */ 619 enum nft_cmp_ops { 620 NFT_CMP_EQ, 621 NFT_CMP_NEQ, 622 NFT_CMP_LT, 623 NFT_CMP_LTE, 624 NFT_CMP_GT, 625 NFT_CMP_GTE, 626 }; 627 628 /** 629 * enum nft_cmp_attributes - nf_tables cmp expression netlink attributes 630 * 631 * @NFTA_CMP_SREG: source register of data to compare (NLA_U32: nft_registers) 632 * @NFTA_CMP_OP: cmp operation (NLA_U32: nft_cmp_ops) 633 * @NFTA_CMP_DATA: data to compare against (NLA_NESTED: nft_data_attributes) 634 */ 635 enum nft_cmp_attributes { 636 NFTA_CMP_UNSPEC, 637 NFTA_CMP_SREG, 638 NFTA_CMP_OP, 639 NFTA_CMP_DATA, 640 __NFTA_CMP_MAX 641 }; 642 #define NFTA_CMP_MAX (__NFTA_CMP_MAX - 1) 643 644 /** 645 * enum nft_range_ops - nf_tables range operator 646 * 647 * @NFT_RANGE_EQ: equal 648 * @NFT_RANGE_NEQ: not equal 649 */ 650 enum nft_range_ops { 651 NFT_RANGE_EQ, 652 NFT_RANGE_NEQ, 653 }; 654 655 /** 656 * enum nft_range_attributes - nf_tables range expression netlink attributes 657 * 658 * @NFTA_RANGE_SREG: source register of data to compare (NLA_U32: nft_registers) 659 * @NFTA_RANGE_OP: cmp operation (NLA_U32: nft_cmp_ops) 660 * @NFTA_RANGE_FROM_DATA: data range from (NLA_NESTED: nft_data_attributes) 661 * @NFTA_RANGE_TO_DATA: data range to (NLA_NESTED: nft_data_attributes) 662 */ 663 enum nft_range_attributes { 664 NFTA_RANGE_UNSPEC, 665 NFTA_RANGE_SREG, 666 NFTA_RANGE_OP, 667 NFTA_RANGE_FROM_DATA, 668 NFTA_RANGE_TO_DATA, 669 __NFTA_RANGE_MAX 670 }; 671 #define NFTA_RANGE_MAX (__NFTA_RANGE_MAX - 1) 672 673 enum nft_lookup_flags { 674 NFT_LOOKUP_F_INV = (1 << 0), 675 }; 676 677 /** 678 * enum nft_lookup_attributes - nf_tables set lookup expression netlink attributes 679 * 680 * @NFTA_LOOKUP_SET: name of the set where to look for (NLA_STRING) 681 * @NFTA_LOOKUP_SREG: source register of the data to look for (NLA_U32: nft_registers) 682 * @NFTA_LOOKUP_DREG: destination register (NLA_U32: nft_registers) 683 * @NFTA_LOOKUP_SET_ID: uniquely identifies a set in a transaction (NLA_U32) 684 * @NFTA_LOOKUP_FLAGS: flags (NLA_U32: enum nft_lookup_flags) 685 */ 686 enum nft_lookup_attributes { 687 NFTA_LOOKUP_UNSPEC, 688 NFTA_LOOKUP_SET, 689 NFTA_LOOKUP_SREG, 690 NFTA_LOOKUP_DREG, 691 NFTA_LOOKUP_SET_ID, 692 NFTA_LOOKUP_FLAGS, 693 __NFTA_LOOKUP_MAX 694 }; 695 #define NFTA_LOOKUP_MAX (__NFTA_LOOKUP_MAX - 1) 696 697 enum nft_dynset_ops { 698 NFT_DYNSET_OP_ADD, 699 NFT_DYNSET_OP_UPDATE, 700 NFT_DYNSET_OP_DELETE, 701 }; 702 703 enum nft_dynset_flags { 704 NFT_DYNSET_F_INV = (1 << 0), 705 }; 706 707 /** 708 * enum nft_dynset_attributes - dynset expression attributes 709 * 710 * @NFTA_DYNSET_SET_NAME: name of set the to add data to (NLA_STRING) 711 * @NFTA_DYNSET_SET_ID: uniquely identifier of the set in the transaction (NLA_U32) 712 * @NFTA_DYNSET_OP: operation (NLA_U32) 713 * @NFTA_DYNSET_SREG_KEY: source register of the key (NLA_U32) 714 * @NFTA_DYNSET_SREG_DATA: source register of the data (NLA_U32) 715 * @NFTA_DYNSET_TIMEOUT: timeout value for the new element (NLA_U64) 716 * @NFTA_DYNSET_EXPR: expression (NLA_NESTED: nft_expr_attributes) 717 * @NFTA_DYNSET_FLAGS: flags (NLA_U32) 718 */ 719 enum nft_dynset_attributes { 720 NFTA_DYNSET_UNSPEC, 721 NFTA_DYNSET_SET_NAME, 722 NFTA_DYNSET_SET_ID, 723 NFTA_DYNSET_OP, 724 NFTA_DYNSET_SREG_KEY, 725 NFTA_DYNSET_SREG_DATA, 726 NFTA_DYNSET_TIMEOUT, 727 NFTA_DYNSET_EXPR, 728 NFTA_DYNSET_PAD, 729 NFTA_DYNSET_FLAGS, 730 __NFTA_DYNSET_MAX, 731 }; 732 #define NFTA_DYNSET_MAX (__NFTA_DYNSET_MAX - 1) 733 734 /** 735 * enum nft_payload_bases - nf_tables payload expression offset bases 736 * 737 * @NFT_PAYLOAD_LL_HEADER: link layer header 738 * @NFT_PAYLOAD_NETWORK_HEADER: network header 739 * @NFT_PAYLOAD_TRANSPORT_HEADER: transport header 740 */ 741 enum nft_payload_bases { 742 NFT_PAYLOAD_LL_HEADER, 743 NFT_PAYLOAD_NETWORK_HEADER, 744 NFT_PAYLOAD_TRANSPORT_HEADER, 745 }; 746 747 /** 748 * enum nft_payload_csum_types - nf_tables payload expression checksum types 749 * 750 * @NFT_PAYLOAD_CSUM_NONE: no checksumming 751 * @NFT_PAYLOAD_CSUM_INET: internet checksum (RFC 791) 752 * @NFT_PAYLOAD_CSUM_SCTP: CRC-32c, for use in SCTP header (RFC 3309) 753 */ 754 enum nft_payload_csum_types { 755 NFT_PAYLOAD_CSUM_NONE, 756 NFT_PAYLOAD_CSUM_INET, 757 NFT_PAYLOAD_CSUM_SCTP, 758 }; 759 760 enum nft_payload_csum_flags { 761 NFT_PAYLOAD_L4CSUM_PSEUDOHDR = (1 << 0), 762 }; 763 764 /** 765 * enum nft_payload_attributes - nf_tables payload expression netlink attributes 766 * 767 * @NFTA_PAYLOAD_DREG: destination register to load data into (NLA_U32: nft_registers) 768 * @NFTA_PAYLOAD_BASE: payload base (NLA_U32: nft_payload_bases) 769 * @NFTA_PAYLOAD_OFFSET: payload offset relative to base (NLA_U32) 770 * @NFTA_PAYLOAD_LEN: payload length (NLA_U32) 771 * @NFTA_PAYLOAD_SREG: source register to load data from (NLA_U32: nft_registers) 772 * @NFTA_PAYLOAD_CSUM_TYPE: checksum type (NLA_U32) 773 * @NFTA_PAYLOAD_CSUM_OFFSET: checksum offset relative to base (NLA_U32) 774 * @NFTA_PAYLOAD_CSUM_FLAGS: checksum flags (NLA_U32) 775 */ 776 enum nft_payload_attributes { 777 NFTA_PAYLOAD_UNSPEC, 778 NFTA_PAYLOAD_DREG, 779 NFTA_PAYLOAD_BASE, 780 NFTA_PAYLOAD_OFFSET, 781 NFTA_PAYLOAD_LEN, 782 NFTA_PAYLOAD_SREG, 783 NFTA_PAYLOAD_CSUM_TYPE, 784 NFTA_PAYLOAD_CSUM_OFFSET, 785 NFTA_PAYLOAD_CSUM_FLAGS, 786 __NFTA_PAYLOAD_MAX 787 }; 788 #define NFTA_PAYLOAD_MAX (__NFTA_PAYLOAD_MAX - 1) 789 790 enum nft_exthdr_flags { 791 NFT_EXTHDR_F_PRESENT = (1 << 0), 792 }; 793 794 /** 795 * enum nft_exthdr_op - nf_tables match options 796 * 797 * @NFT_EXTHDR_OP_IPV6: match against ipv6 extension headers 798 * @NFT_EXTHDR_OP_TCP: match against tcp options 799 * @NFT_EXTHDR_OP_IPV4: match against ipv4 options 800 */ 801 enum nft_exthdr_op { 802 NFT_EXTHDR_OP_IPV6, 803 NFT_EXTHDR_OP_TCPOPT, 804 NFT_EXTHDR_OP_IPV4, 805 __NFT_EXTHDR_OP_MAX 806 }; 807 #define NFT_EXTHDR_OP_MAX (__NFT_EXTHDR_OP_MAX - 1) 808 809 /** 810 * enum nft_exthdr_attributes - nf_tables extension header expression netlink attributes 811 * 812 * @NFTA_EXTHDR_DREG: destination register (NLA_U32: nft_registers) 813 * @NFTA_EXTHDR_TYPE: extension header type (NLA_U8) 814 * @NFTA_EXTHDR_OFFSET: extension header offset (NLA_U32) 815 * @NFTA_EXTHDR_LEN: extension header length (NLA_U32) 816 * @NFTA_EXTHDR_FLAGS: extension header flags (NLA_U32) 817 * @NFTA_EXTHDR_OP: option match type (NLA_U32) 818 * @NFTA_EXTHDR_SREG: option match type (NLA_U32) 819 */ 820 enum nft_exthdr_attributes { 821 NFTA_EXTHDR_UNSPEC, 822 NFTA_EXTHDR_DREG, 823 NFTA_EXTHDR_TYPE, 824 NFTA_EXTHDR_OFFSET, 825 NFTA_EXTHDR_LEN, 826 NFTA_EXTHDR_FLAGS, 827 NFTA_EXTHDR_OP, 828 NFTA_EXTHDR_SREG, 829 __NFTA_EXTHDR_MAX 830 }; 831 #define NFTA_EXTHDR_MAX (__NFTA_EXTHDR_MAX - 1) 832 833 /** 834 * enum nft_meta_keys - nf_tables meta expression keys 835 * 836 * @NFT_META_LEN: packet length (skb->len) 837 * @NFT_META_PROTOCOL: packet ethertype protocol (skb->protocol), invalid in OUTPUT 838 * @NFT_META_PRIORITY: packet priority (skb->priority) 839 * @NFT_META_MARK: packet mark (skb->mark) 840 * @NFT_META_IIF: packet input interface index (dev->ifindex) 841 * @NFT_META_OIF: packet output interface index (dev->ifindex) 842 * @NFT_META_IIFNAME: packet input interface name (dev->name) 843 * @NFT_META_OIFNAME: packet output interface name (dev->name) 844 * @NFT_META_IIFTYPE: packet input interface type (dev->type) 845 * @NFT_META_OIFTYPE: packet output interface type (dev->type) 846 * @NFT_META_SKUID: originating socket UID (fsuid) 847 * @NFT_META_SKGID: originating socket GID (fsgid) 848 * @NFT_META_NFTRACE: packet nftrace bit 849 * @NFT_META_RTCLASSID: realm value of packet's route (skb->dst->tclassid) 850 * @NFT_META_SECMARK: packet secmark (skb->secmark) 851 * @NFT_META_NFPROTO: netfilter protocol 852 * @NFT_META_L4PROTO: layer 4 protocol number 853 * @NFT_META_BRI_IIFNAME: packet input bridge interface name 854 * @NFT_META_BRI_OIFNAME: packet output bridge interface name 855 * @NFT_META_PKTTYPE: packet type (skb->pkt_type), special handling for loopback 856 * @NFT_META_CPU: cpu id through smp_processor_id() 857 * @NFT_META_IIFGROUP: packet input interface group 858 * @NFT_META_OIFGROUP: packet output interface group 859 * @NFT_META_CGROUP: socket control group (skb->sk->sk_classid) 860 * @NFT_META_PRANDOM: a 32bit pseudo-random number 861 * @NFT_META_SECPATH: boolean, secpath_exists (!!skb->sp) 862 * @NFT_META_IIFKIND: packet input interface kind name (dev->rtnl_link_ops->kind) 863 * @NFT_META_OIFKIND: packet output interface kind name (dev->rtnl_link_ops->kind) 864 * @NFT_META_BRI_IIFPVID: packet input bridge port pvid 865 * @NFT_META_BRI_IIFVPROTO: packet input bridge vlan proto 866 * @NFT_META_TIME_NS: time since epoch (in nanoseconds) 867 * @NFT_META_TIME_DAY: day of week (from 0 = Sunday to 6 = Saturday) 868 * @NFT_META_TIME_HOUR: hour of day (in seconds) 869 * @NFT_META_SDIF: slave device interface index 870 * @NFT_META_SDIFNAME: slave device interface name 871 */ 872 enum nft_meta_keys { 873 NFT_META_LEN, 874 NFT_META_PROTOCOL, 875 NFT_META_PRIORITY, 876 NFT_META_MARK, 877 NFT_META_IIF, 878 NFT_META_OIF, 879 NFT_META_IIFNAME, 880 NFT_META_OIFNAME, 881 NFT_META_IIFTYPE, 882 NFT_META_OIFTYPE, 883 NFT_META_SKUID, 884 NFT_META_SKGID, 885 NFT_META_NFTRACE, 886 NFT_META_RTCLASSID, 887 NFT_META_SECMARK, 888 NFT_META_NFPROTO, 889 NFT_META_L4PROTO, 890 NFT_META_BRI_IIFNAME, 891 NFT_META_BRI_OIFNAME, 892 NFT_META_PKTTYPE, 893 NFT_META_CPU, 894 NFT_META_IIFGROUP, 895 NFT_META_OIFGROUP, 896 NFT_META_CGROUP, 897 NFT_META_PRANDOM, 898 NFT_META_SECPATH, 899 NFT_META_IIFKIND, 900 NFT_META_OIFKIND, 901 NFT_META_BRI_IIFPVID, 902 NFT_META_BRI_IIFVPROTO, 903 NFT_META_TIME_NS, 904 NFT_META_TIME_DAY, 905 NFT_META_TIME_HOUR, 906 NFT_META_SDIF, 907 NFT_META_SDIFNAME, 908 }; 909 910 /** 911 * enum nft_rt_keys - nf_tables routing expression keys 912 * 913 * @NFT_RT_CLASSID: realm value of packet's route (skb->dst->tclassid) 914 * @NFT_RT_NEXTHOP4: routing nexthop for IPv4 915 * @NFT_RT_NEXTHOP6: routing nexthop for IPv6 916 * @NFT_RT_TCPMSS: fetch current path tcp mss 917 * @NFT_RT_XFRM: boolean, skb->dst->xfrm != NULL 918 */ 919 enum nft_rt_keys { 920 NFT_RT_CLASSID, 921 NFT_RT_NEXTHOP4, 922 NFT_RT_NEXTHOP6, 923 NFT_RT_TCPMSS, 924 NFT_RT_XFRM, 925 __NFT_RT_MAX 926 }; 927 #define NFT_RT_MAX (__NFT_RT_MAX - 1) 928 929 /** 930 * enum nft_hash_types - nf_tables hash expression types 931 * 932 * @NFT_HASH_JENKINS: Jenkins Hash 933 * @NFT_HASH_SYM: Symmetric Hash 934 */ 935 enum nft_hash_types { 936 NFT_HASH_JENKINS, 937 NFT_HASH_SYM, 938 }; 939 940 /** 941 * enum nft_hash_attributes - nf_tables hash expression netlink attributes 942 * 943 * @NFTA_HASH_SREG: source register (NLA_U32) 944 * @NFTA_HASH_DREG: destination register (NLA_U32) 945 * @NFTA_HASH_LEN: source data length (NLA_U32) 946 * @NFTA_HASH_MODULUS: modulus value (NLA_U32) 947 * @NFTA_HASH_SEED: seed value (NLA_U32) 948 * @NFTA_HASH_OFFSET: add this offset value to hash result (NLA_U32) 949 * @NFTA_HASH_TYPE: hash operation (NLA_U32: nft_hash_types) 950 * @NFTA_HASH_SET_NAME: name of the map to lookup (NLA_STRING) 951 * @NFTA_HASH_SET_ID: id of the map (NLA_U32) 952 */ 953 enum nft_hash_attributes { 954 NFTA_HASH_UNSPEC, 955 NFTA_HASH_SREG, 956 NFTA_HASH_DREG, 957 NFTA_HASH_LEN, 958 NFTA_HASH_MODULUS, 959 NFTA_HASH_SEED, 960 NFTA_HASH_OFFSET, 961 NFTA_HASH_TYPE, 962 NFTA_HASH_SET_NAME, /* deprecated */ 963 NFTA_HASH_SET_ID, /* deprecated */ 964 __NFTA_HASH_MAX, 965 }; 966 #define NFTA_HASH_MAX (__NFTA_HASH_MAX - 1) 967 968 /** 969 * enum nft_meta_attributes - nf_tables meta expression netlink attributes 970 * 971 * @NFTA_META_DREG: destination register (NLA_U32) 972 * @NFTA_META_KEY: meta data item to load (NLA_U32: nft_meta_keys) 973 * @NFTA_META_SREG: source register (NLA_U32) 974 */ 975 enum nft_meta_attributes { 976 NFTA_META_UNSPEC, 977 NFTA_META_DREG, 978 NFTA_META_KEY, 979 NFTA_META_SREG, 980 __NFTA_META_MAX 981 }; 982 #define NFTA_META_MAX (__NFTA_META_MAX - 1) 983 984 /** 985 * enum nft_rt_attributes - nf_tables routing expression netlink attributes 986 * 987 * @NFTA_RT_DREG: destination register (NLA_U32) 988 * @NFTA_RT_KEY: routing data item to load (NLA_U32: nft_rt_keys) 989 */ 990 enum nft_rt_attributes { 991 NFTA_RT_UNSPEC, 992 NFTA_RT_DREG, 993 NFTA_RT_KEY, 994 __NFTA_RT_MAX 995 }; 996 #define NFTA_RT_MAX (__NFTA_RT_MAX - 1) 997 998 /** 999 * enum nft_socket_attributes - nf_tables socket expression netlink attributes 1000 * 1001 * @NFTA_SOCKET_KEY: socket key to match 1002 * @NFTA_SOCKET_DREG: destination register 1003 */ 1004 enum nft_socket_attributes { 1005 NFTA_SOCKET_UNSPEC, 1006 NFTA_SOCKET_KEY, 1007 NFTA_SOCKET_DREG, 1008 __NFTA_SOCKET_MAX 1009 }; 1010 #define NFTA_SOCKET_MAX (__NFTA_SOCKET_MAX - 1) 1011 1012 /* 1013 * enum nft_socket_keys - nf_tables socket expression keys 1014 * 1015 * @NFT_SOCKET_TRANSPARENT: Value of the IP(V6)_TRANSPARENT socket option 1016 * @NFT_SOCKET_MARK: Value of the socket mark 1017 * @NFT_SOCKET_WILDCARD: Whether the socket is zero-bound (e.g. 0.0.0.0 or ::0) 1018 */ 1019 enum nft_socket_keys { 1020 NFT_SOCKET_TRANSPARENT, 1021 NFT_SOCKET_MARK, 1022 NFT_SOCKET_WILDCARD, 1023 __NFT_SOCKET_MAX 1024 }; 1025 #define NFT_SOCKET_MAX (__NFT_SOCKET_MAX - 1) 1026 1027 /** 1028 * enum nft_ct_keys - nf_tables ct expression keys 1029 * 1030 * @NFT_CT_STATE: conntrack state (bitmask of enum ip_conntrack_info) 1031 * @NFT_CT_DIRECTION: conntrack direction (enum ip_conntrack_dir) 1032 * @NFT_CT_STATUS: conntrack status (bitmask of enum ip_conntrack_status) 1033 * @NFT_CT_MARK: conntrack mark value 1034 * @NFT_CT_SECMARK: conntrack secmark value 1035 * @NFT_CT_EXPIRATION: relative conntrack expiration time in ms 1036 * @NFT_CT_HELPER: connection tracking helper assigned to conntrack 1037 * @NFT_CT_L3PROTOCOL: conntrack layer 3 protocol 1038 * @NFT_CT_SRC: conntrack layer 3 protocol source (IPv4/IPv6 address, deprecated) 1039 * @NFT_CT_DST: conntrack layer 3 protocol destination (IPv4/IPv6 address, deprecated) 1040 * @NFT_CT_PROTOCOL: conntrack layer 4 protocol 1041 * @NFT_CT_PROTO_SRC: conntrack layer 4 protocol source 1042 * @NFT_CT_PROTO_DST: conntrack layer 4 protocol destination 1043 * @NFT_CT_LABELS: conntrack labels 1044 * @NFT_CT_PKTS: conntrack packets 1045 * @NFT_CT_BYTES: conntrack bytes 1046 * @NFT_CT_AVGPKT: conntrack average bytes per packet 1047 * @NFT_CT_ZONE: conntrack zone 1048 * @NFT_CT_EVENTMASK: ctnetlink events to be generated for this conntrack 1049 * @NFT_CT_SRC_IP: conntrack layer 3 protocol source (IPv4 address) 1050 * @NFT_CT_DST_IP: conntrack layer 3 protocol destination (IPv4 address) 1051 * @NFT_CT_SRC_IP6: conntrack layer 3 protocol source (IPv6 address) 1052 * @NFT_CT_DST_IP6: conntrack layer 3 protocol destination (IPv6 address) 1053 * @NFT_CT_ID: conntrack id 1054 */ 1055 enum nft_ct_keys { 1056 NFT_CT_STATE, 1057 NFT_CT_DIRECTION, 1058 NFT_CT_STATUS, 1059 NFT_CT_MARK, 1060 NFT_CT_SECMARK, 1061 NFT_CT_EXPIRATION, 1062 NFT_CT_HELPER, 1063 NFT_CT_L3PROTOCOL, 1064 NFT_CT_SRC, 1065 NFT_CT_DST, 1066 NFT_CT_PROTOCOL, 1067 NFT_CT_PROTO_SRC, 1068 NFT_CT_PROTO_DST, 1069 NFT_CT_LABELS, 1070 NFT_CT_PKTS, 1071 NFT_CT_BYTES, 1072 NFT_CT_AVGPKT, 1073 NFT_CT_ZONE, 1074 NFT_CT_EVENTMASK, 1075 NFT_CT_SRC_IP, 1076 NFT_CT_DST_IP, 1077 NFT_CT_SRC_IP6, 1078 NFT_CT_DST_IP6, 1079 NFT_CT_ID, 1080 __NFT_CT_MAX 1081 }; 1082 #define NFT_CT_MAX (__NFT_CT_MAX - 1) 1083 1084 /** 1085 * enum nft_ct_attributes - nf_tables ct expression netlink attributes 1086 * 1087 * @NFTA_CT_DREG: destination register (NLA_U32) 1088 * @NFTA_CT_KEY: conntrack data item to load (NLA_U32: nft_ct_keys) 1089 * @NFTA_CT_DIRECTION: direction in case of directional keys (NLA_U8) 1090 * @NFTA_CT_SREG: source register (NLA_U32) 1091 */ 1092 enum nft_ct_attributes { 1093 NFTA_CT_UNSPEC, 1094 NFTA_CT_DREG, 1095 NFTA_CT_KEY, 1096 NFTA_CT_DIRECTION, 1097 NFTA_CT_SREG, 1098 __NFTA_CT_MAX 1099 }; 1100 #define NFTA_CT_MAX (__NFTA_CT_MAX - 1) 1101 1102 /** 1103 * enum nft_flow_attributes - ct offload expression attributes 1104 * @NFTA_FLOW_TABLE_NAME: flow table name (NLA_STRING) 1105 */ 1106 enum nft_offload_attributes { 1107 NFTA_FLOW_UNSPEC, 1108 NFTA_FLOW_TABLE_NAME, 1109 __NFTA_FLOW_MAX, 1110 }; 1111 #define NFTA_FLOW_MAX (__NFTA_FLOW_MAX - 1) 1112 1113 enum nft_limit_type { 1114 NFT_LIMIT_PKTS, 1115 NFT_LIMIT_PKT_BYTES 1116 }; 1117 1118 enum nft_limit_flags { 1119 NFT_LIMIT_F_INV = (1 << 0), 1120 }; 1121 1122 /** 1123 * enum nft_limit_attributes - nf_tables limit expression netlink attributes 1124 * 1125 * @NFTA_LIMIT_RATE: refill rate (NLA_U64) 1126 * @NFTA_LIMIT_UNIT: refill unit (NLA_U64) 1127 * @NFTA_LIMIT_BURST: burst (NLA_U32) 1128 * @NFTA_LIMIT_TYPE: type of limit (NLA_U32: enum nft_limit_type) 1129 * @NFTA_LIMIT_FLAGS: flags (NLA_U32: enum nft_limit_flags) 1130 */ 1131 enum nft_limit_attributes { 1132 NFTA_LIMIT_UNSPEC, 1133 NFTA_LIMIT_RATE, 1134 NFTA_LIMIT_UNIT, 1135 NFTA_LIMIT_BURST, 1136 NFTA_LIMIT_TYPE, 1137 NFTA_LIMIT_FLAGS, 1138 NFTA_LIMIT_PAD, 1139 __NFTA_LIMIT_MAX 1140 }; 1141 #define NFTA_LIMIT_MAX (__NFTA_LIMIT_MAX - 1) 1142 1143 enum nft_connlimit_flags { 1144 NFT_CONNLIMIT_F_INV = (1 << 0), 1145 }; 1146 1147 /** 1148 * enum nft_connlimit_attributes - nf_tables connlimit expression netlink attributes 1149 * 1150 * @NFTA_CONNLIMIT_COUNT: number of connections (NLA_U32) 1151 * @NFTA_CONNLIMIT_FLAGS: flags (NLA_U32: enum nft_connlimit_flags) 1152 */ 1153 enum nft_connlimit_attributes { 1154 NFTA_CONNLIMIT_UNSPEC, 1155 NFTA_CONNLIMIT_COUNT, 1156 NFTA_CONNLIMIT_FLAGS, 1157 __NFTA_CONNLIMIT_MAX 1158 }; 1159 #define NFTA_CONNLIMIT_MAX (__NFTA_CONNLIMIT_MAX - 1) 1160 1161 /** 1162 * enum nft_counter_attributes - nf_tables counter expression netlink attributes 1163 * 1164 * @NFTA_COUNTER_BYTES: number of bytes (NLA_U64) 1165 * @NFTA_COUNTER_PACKETS: number of packets (NLA_U64) 1166 */ 1167 enum nft_counter_attributes { 1168 NFTA_COUNTER_UNSPEC, 1169 NFTA_COUNTER_BYTES, 1170 NFTA_COUNTER_PACKETS, 1171 NFTA_COUNTER_PAD, 1172 __NFTA_COUNTER_MAX 1173 }; 1174 #define NFTA_COUNTER_MAX (__NFTA_COUNTER_MAX - 1) 1175 1176 /** 1177 * enum nft_log_attributes - nf_tables log expression netlink attributes 1178 * 1179 * @NFTA_LOG_GROUP: netlink group to send messages to (NLA_U32) 1180 * @NFTA_LOG_PREFIX: prefix to prepend to log messages (NLA_STRING) 1181 * @NFTA_LOG_SNAPLEN: length of payload to include in netlink message (NLA_U32) 1182 * @NFTA_LOG_QTHRESHOLD: queue threshold (NLA_U32) 1183 * @NFTA_LOG_LEVEL: log level (NLA_U32) 1184 * @NFTA_LOG_FLAGS: logging flags (NLA_U32) 1185 */ 1186 enum nft_log_attributes { 1187 NFTA_LOG_UNSPEC, 1188 NFTA_LOG_GROUP, 1189 NFTA_LOG_PREFIX, 1190 NFTA_LOG_SNAPLEN, 1191 NFTA_LOG_QTHRESHOLD, 1192 NFTA_LOG_LEVEL, 1193 NFTA_LOG_FLAGS, 1194 __NFTA_LOG_MAX 1195 }; 1196 #define NFTA_LOG_MAX (__NFTA_LOG_MAX - 1) 1197 1198 /** 1199 * enum nft_log_level - nf_tables log levels 1200 * 1201 * @NFT_LOGLEVEL_EMERG: system is unusable 1202 * @NFT_LOGLEVEL_ALERT: action must be taken immediately 1203 * @NFT_LOGLEVEL_CRIT: critical conditions 1204 * @NFT_LOGLEVEL_ERR: error conditions 1205 * @NFT_LOGLEVEL_WARNING: warning conditions 1206 * @NFT_LOGLEVEL_NOTICE: normal but significant condition 1207 * @NFT_LOGLEVEL_INFO: informational 1208 * @NFT_LOGLEVEL_DEBUG: debug-level messages 1209 * @NFT_LOGLEVEL_AUDIT: enabling audit logging 1210 */ 1211 enum nft_log_level { 1212 NFT_LOGLEVEL_EMERG, 1213 NFT_LOGLEVEL_ALERT, 1214 NFT_LOGLEVEL_CRIT, 1215 NFT_LOGLEVEL_ERR, 1216 NFT_LOGLEVEL_WARNING, 1217 NFT_LOGLEVEL_NOTICE, 1218 NFT_LOGLEVEL_INFO, 1219 NFT_LOGLEVEL_DEBUG, 1220 NFT_LOGLEVEL_AUDIT, 1221 __NFT_LOGLEVEL_MAX 1222 }; 1223 #define NFT_LOGLEVEL_MAX (__NFT_LOGLEVEL_MAX - 1) 1224 1225 /** 1226 * enum nft_queue_attributes - nf_tables queue expression netlink attributes 1227 * 1228 * @NFTA_QUEUE_NUM: netlink queue to send messages to (NLA_U16) 1229 * @NFTA_QUEUE_TOTAL: number of queues to load balance packets on (NLA_U16) 1230 * @NFTA_QUEUE_FLAGS: various flags (NLA_U16) 1231 * @NFTA_QUEUE_SREG_QNUM: source register of queue number (NLA_U32: nft_registers) 1232 */ 1233 enum nft_queue_attributes { 1234 NFTA_QUEUE_UNSPEC, 1235 NFTA_QUEUE_NUM, 1236 NFTA_QUEUE_TOTAL, 1237 NFTA_QUEUE_FLAGS, 1238 NFTA_QUEUE_SREG_QNUM, 1239 __NFTA_QUEUE_MAX 1240 }; 1241 #define NFTA_QUEUE_MAX (__NFTA_QUEUE_MAX - 1) 1242 1243 #define NFT_QUEUE_FLAG_BYPASS 0x01 /* for compatibility with v2 */ 1244 #define NFT_QUEUE_FLAG_CPU_FANOUT 0x02 /* use current CPU (no hashing) */ 1245 #define NFT_QUEUE_FLAG_MASK 0x03 1246 1247 enum nft_quota_flags { 1248 NFT_QUOTA_F_INV = (1 << 0), 1249 NFT_QUOTA_F_DEPLETED = (1 << 1), 1250 }; 1251 1252 /** 1253 * enum nft_quota_attributes - nf_tables quota expression netlink attributes 1254 * 1255 * @NFTA_QUOTA_BYTES: quota in bytes (NLA_U16) 1256 * @NFTA_QUOTA_FLAGS: flags (NLA_U32) 1257 * @NFTA_QUOTA_CONSUMED: quota already consumed in bytes (NLA_U64) 1258 */ 1259 enum nft_quota_attributes { 1260 NFTA_QUOTA_UNSPEC, 1261 NFTA_QUOTA_BYTES, 1262 NFTA_QUOTA_FLAGS, 1263 NFTA_QUOTA_PAD, 1264 NFTA_QUOTA_CONSUMED, 1265 __NFTA_QUOTA_MAX 1266 }; 1267 #define NFTA_QUOTA_MAX (__NFTA_QUOTA_MAX - 1) 1268 1269 /** 1270 * enum nft_secmark_attributes - nf_tables secmark object netlink attributes 1271 * 1272 * @NFTA_SECMARK_CTX: security context (NLA_STRING) 1273 */ 1274 enum nft_secmark_attributes { 1275 NFTA_SECMARK_UNSPEC, 1276 NFTA_SECMARK_CTX, 1277 __NFTA_SECMARK_MAX, 1278 }; 1279 #define NFTA_SECMARK_MAX (__NFTA_SECMARK_MAX - 1) 1280 1281 /* Max security context length */ 1282 #define NFT_SECMARK_CTX_MAXLEN 256 1283 1284 /** 1285 * enum nft_reject_types - nf_tables reject expression reject types 1286 * 1287 * @NFT_REJECT_ICMP_UNREACH: reject using ICMP unreachable 1288 * @NFT_REJECT_TCP_RST: reject using TCP RST 1289 * @NFT_REJECT_ICMPX_UNREACH: abstracted ICMP unreachable for bridge and inet 1290 */ 1291 enum nft_reject_types { 1292 NFT_REJECT_ICMP_UNREACH, 1293 NFT_REJECT_TCP_RST, 1294 NFT_REJECT_ICMPX_UNREACH, 1295 }; 1296 1297 /** 1298 * enum nft_reject_code - Generic reject codes for IPv4/IPv6 1299 * 1300 * @NFT_REJECT_ICMPX_NO_ROUTE: no route to host / network unreachable 1301 * @NFT_REJECT_ICMPX_PORT_UNREACH: port unreachable 1302 * @NFT_REJECT_ICMPX_HOST_UNREACH: host unreachable 1303 * @NFT_REJECT_ICMPX_ADMIN_PROHIBITED: administratively prohibited 1304 * 1305 * These codes are mapped to real ICMP and ICMPv6 codes. 1306 */ 1307 enum nft_reject_inet_code { 1308 NFT_REJECT_ICMPX_NO_ROUTE = 0, 1309 NFT_REJECT_ICMPX_PORT_UNREACH, 1310 NFT_REJECT_ICMPX_HOST_UNREACH, 1311 NFT_REJECT_ICMPX_ADMIN_PROHIBITED, 1312 __NFT_REJECT_ICMPX_MAX 1313 }; 1314 #define NFT_REJECT_ICMPX_MAX (__NFT_REJECT_ICMPX_MAX - 1) 1315 1316 /** 1317 * enum nft_reject_attributes - nf_tables reject expression netlink attributes 1318 * 1319 * @NFTA_REJECT_TYPE: packet type to use (NLA_U32: nft_reject_types) 1320 * @NFTA_REJECT_ICMP_CODE: ICMP code to use (NLA_U8) 1321 */ 1322 enum nft_reject_attributes { 1323 NFTA_REJECT_UNSPEC, 1324 NFTA_REJECT_TYPE, 1325 NFTA_REJECT_ICMP_CODE, 1326 __NFTA_REJECT_MAX 1327 }; 1328 #define NFTA_REJECT_MAX (__NFTA_REJECT_MAX - 1) 1329 1330 /** 1331 * enum nft_nat_types - nf_tables nat expression NAT types 1332 * 1333 * @NFT_NAT_SNAT: source NAT 1334 * @NFT_NAT_DNAT: destination NAT 1335 */ 1336 enum nft_nat_types { 1337 NFT_NAT_SNAT, 1338 NFT_NAT_DNAT, 1339 }; 1340 1341 /** 1342 * enum nft_nat_attributes - nf_tables nat expression netlink attributes 1343 * 1344 * @NFTA_NAT_TYPE: NAT type (NLA_U32: nft_nat_types) 1345 * @NFTA_NAT_FAMILY: NAT family (NLA_U32) 1346 * @NFTA_NAT_REG_ADDR_MIN: source register of address range start (NLA_U32: nft_registers) 1347 * @NFTA_NAT_REG_ADDR_MAX: source register of address range end (NLA_U32: nft_registers) 1348 * @NFTA_NAT_REG_PROTO_MIN: source register of proto range start (NLA_U32: nft_registers) 1349 * @NFTA_NAT_REG_PROTO_MAX: source register of proto range end (NLA_U32: nft_registers) 1350 * @NFTA_NAT_FLAGS: NAT flags (see NF_NAT_RANGE_* in linux/netfilter/nf_nat.h) (NLA_U32) 1351 */ 1352 enum nft_nat_attributes { 1353 NFTA_NAT_UNSPEC, 1354 NFTA_NAT_TYPE, 1355 NFTA_NAT_FAMILY, 1356 NFTA_NAT_REG_ADDR_MIN, 1357 NFTA_NAT_REG_ADDR_MAX, 1358 NFTA_NAT_REG_PROTO_MIN, 1359 NFTA_NAT_REG_PROTO_MAX, 1360 NFTA_NAT_FLAGS, 1361 __NFTA_NAT_MAX 1362 }; 1363 #define NFTA_NAT_MAX (__NFTA_NAT_MAX - 1) 1364 1365 /** 1366 * enum nft_tproxy_attributes - nf_tables tproxy expression netlink attributes 1367 * 1368 * NFTA_TPROXY_FAMILY: Target address family (NLA_U32: nft_registers) 1369 * NFTA_TPROXY_REG_ADDR: Target address register (NLA_U32: nft_registers) 1370 * NFTA_TPROXY_REG_PORT: Target port register (NLA_U32: nft_registers) 1371 */ 1372 enum nft_tproxy_attributes { 1373 NFTA_TPROXY_UNSPEC, 1374 NFTA_TPROXY_FAMILY, 1375 NFTA_TPROXY_REG_ADDR, 1376 NFTA_TPROXY_REG_PORT, 1377 __NFTA_TPROXY_MAX 1378 }; 1379 #define NFTA_TPROXY_MAX (__NFTA_TPROXY_MAX - 1) 1380 1381 /** 1382 * enum nft_masq_attributes - nf_tables masquerade expression attributes 1383 * 1384 * @NFTA_MASQ_FLAGS: NAT flags (see NF_NAT_RANGE_* in linux/netfilter/nf_nat.h) (NLA_U32) 1385 * @NFTA_MASQ_REG_PROTO_MIN: source register of proto range start (NLA_U32: nft_registers) 1386 * @NFTA_MASQ_REG_PROTO_MAX: source register of proto range end (NLA_U32: nft_registers) 1387 */ 1388 enum nft_masq_attributes { 1389 NFTA_MASQ_UNSPEC, 1390 NFTA_MASQ_FLAGS, 1391 NFTA_MASQ_REG_PROTO_MIN, 1392 NFTA_MASQ_REG_PROTO_MAX, 1393 __NFTA_MASQ_MAX 1394 }; 1395 #define NFTA_MASQ_MAX (__NFTA_MASQ_MAX - 1) 1396 1397 /** 1398 * enum nft_redir_attributes - nf_tables redirect expression netlink attributes 1399 * 1400 * @NFTA_REDIR_REG_PROTO_MIN: source register of proto range start (NLA_U32: nft_registers) 1401 * @NFTA_REDIR_REG_PROTO_MAX: source register of proto range end (NLA_U32: nft_registers) 1402 * @NFTA_REDIR_FLAGS: NAT flags (see NF_NAT_RANGE_* in linux/netfilter/nf_nat.h) (NLA_U32) 1403 */ 1404 enum nft_redir_attributes { 1405 NFTA_REDIR_UNSPEC, 1406 NFTA_REDIR_REG_PROTO_MIN, 1407 NFTA_REDIR_REG_PROTO_MAX, 1408 NFTA_REDIR_FLAGS, 1409 __NFTA_REDIR_MAX 1410 }; 1411 #define NFTA_REDIR_MAX (__NFTA_REDIR_MAX - 1) 1412 1413 /** 1414 * enum nft_dup_attributes - nf_tables dup expression netlink attributes 1415 * 1416 * @NFTA_DUP_SREG_ADDR: source register of address (NLA_U32: nft_registers) 1417 * @NFTA_DUP_SREG_DEV: source register of output interface (NLA_U32: nft_register) 1418 */ 1419 enum nft_dup_attributes { 1420 NFTA_DUP_UNSPEC, 1421 NFTA_DUP_SREG_ADDR, 1422 NFTA_DUP_SREG_DEV, 1423 __NFTA_DUP_MAX 1424 }; 1425 #define NFTA_DUP_MAX (__NFTA_DUP_MAX - 1) 1426 1427 /** 1428 * enum nft_fwd_attributes - nf_tables fwd expression netlink attributes 1429 * 1430 * @NFTA_FWD_SREG_DEV: source register of output interface (NLA_U32: nft_register) 1431 * @NFTA_FWD_SREG_ADDR: source register of destination address (NLA_U32: nft_register) 1432 * @NFTA_FWD_NFPROTO: layer 3 family of source register address (NLA_U32: enum nfproto) 1433 */ 1434 enum nft_fwd_attributes { 1435 NFTA_FWD_UNSPEC, 1436 NFTA_FWD_SREG_DEV, 1437 NFTA_FWD_SREG_ADDR, 1438 NFTA_FWD_NFPROTO, 1439 __NFTA_FWD_MAX 1440 }; 1441 #define NFTA_FWD_MAX (__NFTA_FWD_MAX - 1) 1442 1443 /** 1444 * enum nft_objref_attributes - nf_tables stateful object expression netlink attributes 1445 * 1446 * @NFTA_OBJREF_IMM_TYPE: object type for immediate reference (NLA_U32: nft_register) 1447 * @NFTA_OBJREF_IMM_NAME: object name for immediate reference (NLA_STRING) 1448 * @NFTA_OBJREF_SET_SREG: source register of the data to look for (NLA_U32: nft_registers) 1449 * @NFTA_OBJREF_SET_NAME: name of the set where to look for (NLA_STRING) 1450 * @NFTA_OBJREF_SET_ID: id of the set where to look for in this transaction (NLA_U32) 1451 */ 1452 enum nft_objref_attributes { 1453 NFTA_OBJREF_UNSPEC, 1454 NFTA_OBJREF_IMM_TYPE, 1455 NFTA_OBJREF_IMM_NAME, 1456 NFTA_OBJREF_SET_SREG, 1457 NFTA_OBJREF_SET_NAME, 1458 NFTA_OBJREF_SET_ID, 1459 __NFTA_OBJREF_MAX 1460 }; 1461 #define NFTA_OBJREF_MAX (__NFTA_OBJREF_MAX - 1) 1462 1463 /** 1464 * enum nft_gen_attributes - nf_tables ruleset generation attributes 1465 * 1466 * @NFTA_GEN_ID: Ruleset generation ID (NLA_U32) 1467 */ 1468 enum nft_gen_attributes { 1469 NFTA_GEN_UNSPEC, 1470 NFTA_GEN_ID, 1471 NFTA_GEN_PROC_PID, 1472 NFTA_GEN_PROC_NAME, 1473 __NFTA_GEN_MAX 1474 }; 1475 #define NFTA_GEN_MAX (__NFTA_GEN_MAX - 1) 1476 1477 /* 1478 * enum nft_fib_attributes - nf_tables fib expression netlink attributes 1479 * 1480 * @NFTA_FIB_DREG: destination register (NLA_U32) 1481 * @NFTA_FIB_RESULT: desired result (NLA_U32) 1482 * @NFTA_FIB_FLAGS: flowi fields to initialize when querying the FIB (NLA_U32) 1483 * 1484 * The FIB expression performs a route lookup according 1485 * to the packet data. 1486 */ 1487 enum nft_fib_attributes { 1488 NFTA_FIB_UNSPEC, 1489 NFTA_FIB_DREG, 1490 NFTA_FIB_RESULT, 1491 NFTA_FIB_FLAGS, 1492 __NFTA_FIB_MAX 1493 }; 1494 #define NFTA_FIB_MAX (__NFTA_FIB_MAX - 1) 1495 1496 enum nft_fib_result { 1497 NFT_FIB_RESULT_UNSPEC, 1498 NFT_FIB_RESULT_OIF, 1499 NFT_FIB_RESULT_OIFNAME, 1500 NFT_FIB_RESULT_ADDRTYPE, 1501 __NFT_FIB_RESULT_MAX 1502 }; 1503 #define NFT_FIB_RESULT_MAX (__NFT_FIB_RESULT_MAX - 1) 1504 1505 enum nft_fib_flags { 1506 NFTA_FIB_F_SADDR = 1 << 0, /* look up src */ 1507 NFTA_FIB_F_DADDR = 1 << 1, /* look up dst */ 1508 NFTA_FIB_F_MARK = 1 << 2, /* use skb->mark */ 1509 NFTA_FIB_F_IIF = 1 << 3, /* restrict to iif */ 1510 NFTA_FIB_F_OIF = 1 << 4, /* restrict to oif */ 1511 NFTA_FIB_F_PRESENT = 1 << 5, /* check existence only */ 1512 }; 1513 1514 enum nft_ct_helper_attributes { 1515 NFTA_CT_HELPER_UNSPEC, 1516 NFTA_CT_HELPER_NAME, 1517 NFTA_CT_HELPER_L3PROTO, 1518 NFTA_CT_HELPER_L4PROTO, 1519 __NFTA_CT_HELPER_MAX, 1520 }; 1521 #define NFTA_CT_HELPER_MAX (__NFTA_CT_HELPER_MAX - 1) 1522 1523 enum nft_ct_timeout_timeout_attributes { 1524 NFTA_CT_TIMEOUT_UNSPEC, 1525 NFTA_CT_TIMEOUT_L3PROTO, 1526 NFTA_CT_TIMEOUT_L4PROTO, 1527 NFTA_CT_TIMEOUT_DATA, 1528 __NFTA_CT_TIMEOUT_MAX, 1529 }; 1530 #define NFTA_CT_TIMEOUT_MAX (__NFTA_CT_TIMEOUT_MAX - 1) 1531 1532 enum nft_ct_expectation_attributes { 1533 NFTA_CT_EXPECT_UNSPEC, 1534 NFTA_CT_EXPECT_L3PROTO, 1535 NFTA_CT_EXPECT_L4PROTO, 1536 NFTA_CT_EXPECT_DPORT, 1537 NFTA_CT_EXPECT_TIMEOUT, 1538 NFTA_CT_EXPECT_SIZE, 1539 __NFTA_CT_EXPECT_MAX, 1540 }; 1541 #define NFTA_CT_EXPECT_MAX (__NFTA_CT_EXPECT_MAX - 1) 1542 1543 #define NFT_OBJECT_UNSPEC 0 1544 #define NFT_OBJECT_COUNTER 1 1545 #define NFT_OBJECT_QUOTA 2 1546 #define NFT_OBJECT_CT_HELPER 3 1547 #define NFT_OBJECT_LIMIT 4 1548 #define NFT_OBJECT_CONNLIMIT 5 1549 #define NFT_OBJECT_TUNNEL 6 1550 #define NFT_OBJECT_CT_TIMEOUT 7 1551 #define NFT_OBJECT_SECMARK 8 1552 #define NFT_OBJECT_CT_EXPECT 9 1553 #define NFT_OBJECT_SYNPROXY 10 1554 #define __NFT_OBJECT_MAX 11 1555 #define NFT_OBJECT_MAX (__NFT_OBJECT_MAX - 1) 1556 1557 /** 1558 * enum nft_object_attributes - nf_tables stateful object netlink attributes 1559 * 1560 * @NFTA_OBJ_TABLE: name of the table containing the expression (NLA_STRING) 1561 * @NFTA_OBJ_NAME: name of this expression type (NLA_STRING) 1562 * @NFTA_OBJ_TYPE: stateful object type (NLA_U32) 1563 * @NFTA_OBJ_DATA: stateful object data (NLA_NESTED) 1564 * @NFTA_OBJ_USE: number of references to this expression (NLA_U32) 1565 * @NFTA_OBJ_HANDLE: object handle (NLA_U64) 1566 * @NFTA_OBJ_USERDATA: user data (NLA_BINARY) 1567 */ 1568 enum nft_object_attributes { 1569 NFTA_OBJ_UNSPEC, 1570 NFTA_OBJ_TABLE, 1571 NFTA_OBJ_NAME, 1572 NFTA_OBJ_TYPE, 1573 NFTA_OBJ_DATA, 1574 NFTA_OBJ_USE, 1575 NFTA_OBJ_HANDLE, 1576 NFTA_OBJ_PAD, 1577 NFTA_OBJ_USERDATA, 1578 __NFTA_OBJ_MAX 1579 }; 1580 #define NFTA_OBJ_MAX (__NFTA_OBJ_MAX - 1) 1581 1582 /** 1583 * enum nft_flowtable_flags - nf_tables flowtable flags 1584 * 1585 * @NFT_FLOWTABLE_HW_OFFLOAD: flowtable hardware offload is enabled 1586 * @NFT_FLOWTABLE_COUNTER: enable flow counters 1587 */ 1588 enum nft_flowtable_flags { 1589 NFT_FLOWTABLE_HW_OFFLOAD = 0x1, 1590 NFT_FLOWTABLE_COUNTER = 0x2, 1591 NFT_FLOWTABLE_MASK = (NFT_FLOWTABLE_HW_OFFLOAD | 1592 NFT_FLOWTABLE_COUNTER) 1593 }; 1594 1595 /** 1596 * enum nft_flowtable_attributes - nf_tables flow table netlink attributes 1597 * 1598 * @NFTA_FLOWTABLE_TABLE: name of the table containing the expression (NLA_STRING) 1599 * @NFTA_FLOWTABLE_NAME: name of this flow table (NLA_STRING) 1600 * @NFTA_FLOWTABLE_HOOK: netfilter hook configuration(NLA_U32) 1601 * @NFTA_FLOWTABLE_USE: number of references to this flow table (NLA_U32) 1602 * @NFTA_FLOWTABLE_HANDLE: object handle (NLA_U64) 1603 * @NFTA_FLOWTABLE_FLAGS: flags (NLA_U32) 1604 */ 1605 enum nft_flowtable_attributes { 1606 NFTA_FLOWTABLE_UNSPEC, 1607 NFTA_FLOWTABLE_TABLE, 1608 NFTA_FLOWTABLE_NAME, 1609 NFTA_FLOWTABLE_HOOK, 1610 NFTA_FLOWTABLE_USE, 1611 NFTA_FLOWTABLE_HANDLE, 1612 NFTA_FLOWTABLE_PAD, 1613 NFTA_FLOWTABLE_FLAGS, 1614 __NFTA_FLOWTABLE_MAX 1615 }; 1616 #define NFTA_FLOWTABLE_MAX (__NFTA_FLOWTABLE_MAX - 1) 1617 1618 /** 1619 * enum nft_flowtable_hook_attributes - nf_tables flow table hook netlink attributes 1620 * 1621 * @NFTA_FLOWTABLE_HOOK_NUM: netfilter hook number (NLA_U32) 1622 * @NFTA_FLOWTABLE_HOOK_PRIORITY: netfilter hook priority (NLA_U32) 1623 * @NFTA_FLOWTABLE_HOOK_DEVS: input devices this flow table is bound to (NLA_NESTED) 1624 */ 1625 enum nft_flowtable_hook_attributes { 1626 NFTA_FLOWTABLE_HOOK_UNSPEC, 1627 NFTA_FLOWTABLE_HOOK_NUM, 1628 NFTA_FLOWTABLE_HOOK_PRIORITY, 1629 NFTA_FLOWTABLE_HOOK_DEVS, 1630 __NFTA_FLOWTABLE_HOOK_MAX 1631 }; 1632 #define NFTA_FLOWTABLE_HOOK_MAX (__NFTA_FLOWTABLE_HOOK_MAX - 1) 1633 1634 /** 1635 * enum nft_osf_attributes - nftables osf expression netlink attributes 1636 * 1637 * @NFTA_OSF_DREG: destination register (NLA_U32: nft_registers) 1638 * @NFTA_OSF_TTL: Value of the TTL osf option (NLA_U8) 1639 * @NFTA_OSF_FLAGS: flags (NLA_U32) 1640 */ 1641 enum nft_osf_attributes { 1642 NFTA_OSF_UNSPEC, 1643 NFTA_OSF_DREG, 1644 NFTA_OSF_TTL, 1645 NFTA_OSF_FLAGS, 1646 __NFTA_OSF_MAX, 1647 }; 1648 #define NFTA_OSF_MAX (__NFTA_OSF_MAX - 1) 1649 1650 enum nft_osf_flags { 1651 NFT_OSF_F_VERSION = (1 << 0), 1652 }; 1653 1654 /** 1655 * enum nft_synproxy_attributes - nf_tables synproxy expression netlink attributes 1656 * 1657 * @NFTA_SYNPROXY_MSS: mss value sent to the backend (NLA_U16) 1658 * @NFTA_SYNPROXY_WSCALE: wscale value sent to the backend (NLA_U8) 1659 * @NFTA_SYNPROXY_FLAGS: flags (NLA_U32) 1660 */ 1661 enum nft_synproxy_attributes { 1662 NFTA_SYNPROXY_UNSPEC, 1663 NFTA_SYNPROXY_MSS, 1664 NFTA_SYNPROXY_WSCALE, 1665 NFTA_SYNPROXY_FLAGS, 1666 __NFTA_SYNPROXY_MAX, 1667 }; 1668 #define NFTA_SYNPROXY_MAX (__NFTA_SYNPROXY_MAX - 1) 1669 1670 /** 1671 * enum nft_device_attributes - nf_tables device netlink attributes 1672 * 1673 * @NFTA_DEVICE_NAME: name of this device (NLA_STRING) 1674 */ 1675 enum nft_devices_attributes { 1676 NFTA_DEVICE_UNSPEC, 1677 NFTA_DEVICE_NAME, 1678 __NFTA_DEVICE_MAX 1679 }; 1680 #define NFTA_DEVICE_MAX (__NFTA_DEVICE_MAX - 1) 1681 1682 /* 1683 * enum nft_xfrm_attributes - nf_tables xfrm expr netlink attributes 1684 * 1685 * @NFTA_XFRM_DREG: destination register (NLA_U32) 1686 * @NFTA_XFRM_KEY: enum nft_xfrm_keys (NLA_U32) 1687 * @NFTA_XFRM_DIR: direction (NLA_U8) 1688 * @NFTA_XFRM_SPNUM: index in secpath array (NLA_U32) 1689 */ 1690 enum nft_xfrm_attributes { 1691 NFTA_XFRM_UNSPEC, 1692 NFTA_XFRM_DREG, 1693 NFTA_XFRM_KEY, 1694 NFTA_XFRM_DIR, 1695 NFTA_XFRM_SPNUM, 1696 __NFTA_XFRM_MAX 1697 }; 1698 #define NFTA_XFRM_MAX (__NFTA_XFRM_MAX - 1) 1699 1700 enum nft_xfrm_keys { 1701 NFT_XFRM_KEY_UNSPEC, 1702 NFT_XFRM_KEY_DADDR_IP4, 1703 NFT_XFRM_KEY_DADDR_IP6, 1704 NFT_XFRM_KEY_SADDR_IP4, 1705 NFT_XFRM_KEY_SADDR_IP6, 1706 NFT_XFRM_KEY_REQID, 1707 NFT_XFRM_KEY_SPI, 1708 __NFT_XFRM_KEY_MAX, 1709 }; 1710 #define NFT_XFRM_KEY_MAX (__NFT_XFRM_KEY_MAX - 1) 1711 1712 /** 1713 * enum nft_trace_attributes - nf_tables trace netlink attributes 1714 * 1715 * @NFTA_TRACE_TABLE: name of the table (NLA_STRING) 1716 * @NFTA_TRACE_CHAIN: name of the chain (NLA_STRING) 1717 * @NFTA_TRACE_RULE_HANDLE: numeric handle of the rule (NLA_U64) 1718 * @NFTA_TRACE_TYPE: type of the event (NLA_U32: nft_trace_types) 1719 * @NFTA_TRACE_VERDICT: verdict returned by hook (NLA_NESTED: nft_verdicts) 1720 * @NFTA_TRACE_ID: pseudo-id, same for each skb traced (NLA_U32) 1721 * @NFTA_TRACE_LL_HEADER: linklayer header (NLA_BINARY) 1722 * @NFTA_TRACE_NETWORK_HEADER: network header (NLA_BINARY) 1723 * @NFTA_TRACE_TRANSPORT_HEADER: transport header (NLA_BINARY) 1724 * @NFTA_TRACE_IIF: indev ifindex (NLA_U32) 1725 * @NFTA_TRACE_IIFTYPE: netdev->type of indev (NLA_U16) 1726 * @NFTA_TRACE_OIF: outdev ifindex (NLA_U32) 1727 * @NFTA_TRACE_OIFTYPE: netdev->type of outdev (NLA_U16) 1728 * @NFTA_TRACE_MARK: nfmark (NLA_U32) 1729 * @NFTA_TRACE_NFPROTO: nf protocol processed (NLA_U32) 1730 * @NFTA_TRACE_POLICY: policy that decided fate of packet (NLA_U32) 1731 */ 1732 enum nft_trace_attributes { 1733 NFTA_TRACE_UNSPEC, 1734 NFTA_TRACE_TABLE, 1735 NFTA_TRACE_CHAIN, 1736 NFTA_TRACE_RULE_HANDLE, 1737 NFTA_TRACE_TYPE, 1738 NFTA_TRACE_VERDICT, 1739 NFTA_TRACE_ID, 1740 NFTA_TRACE_LL_HEADER, 1741 NFTA_TRACE_NETWORK_HEADER, 1742 NFTA_TRACE_TRANSPORT_HEADER, 1743 NFTA_TRACE_IIF, 1744 NFTA_TRACE_IIFTYPE, 1745 NFTA_TRACE_OIF, 1746 NFTA_TRACE_OIFTYPE, 1747 NFTA_TRACE_MARK, 1748 NFTA_TRACE_NFPROTO, 1749 NFTA_TRACE_POLICY, 1750 NFTA_TRACE_PAD, 1751 __NFTA_TRACE_MAX 1752 }; 1753 #define NFTA_TRACE_MAX (__NFTA_TRACE_MAX - 1) 1754 1755 enum nft_trace_types { 1756 NFT_TRACETYPE_UNSPEC, 1757 NFT_TRACETYPE_POLICY, 1758 NFT_TRACETYPE_RETURN, 1759 NFT_TRACETYPE_RULE, 1760 __NFT_TRACETYPE_MAX 1761 }; 1762 #define NFT_TRACETYPE_MAX (__NFT_TRACETYPE_MAX - 1) 1763 1764 /** 1765 * enum nft_ng_attributes - nf_tables number generator expression netlink attributes 1766 * 1767 * @NFTA_NG_DREG: destination register (NLA_U32) 1768 * @NFTA_NG_MODULUS: maximum counter value (NLA_U32) 1769 * @NFTA_NG_TYPE: operation type (NLA_U32) 1770 * @NFTA_NG_OFFSET: offset to be added to the counter (NLA_U32) 1771 * @NFTA_NG_SET_NAME: name of the map to lookup (NLA_STRING) 1772 * @NFTA_NG_SET_ID: id of the map (NLA_U32) 1773 */ 1774 enum nft_ng_attributes { 1775 NFTA_NG_UNSPEC, 1776 NFTA_NG_DREG, 1777 NFTA_NG_MODULUS, 1778 NFTA_NG_TYPE, 1779 NFTA_NG_OFFSET, 1780 NFTA_NG_SET_NAME, /* deprecated */ 1781 NFTA_NG_SET_ID, /* deprecated */ 1782 __NFTA_NG_MAX 1783 }; 1784 #define NFTA_NG_MAX (__NFTA_NG_MAX - 1) 1785 1786 enum nft_ng_types { 1787 NFT_NG_INCREMENTAL, 1788 NFT_NG_RANDOM, 1789 __NFT_NG_MAX 1790 }; 1791 #define NFT_NG_MAX (__NFT_NG_MAX - 1) 1792 1793 enum nft_tunnel_key_ip_attributes { 1794 NFTA_TUNNEL_KEY_IP_UNSPEC, 1795 NFTA_TUNNEL_KEY_IP_SRC, 1796 NFTA_TUNNEL_KEY_IP_DST, 1797 __NFTA_TUNNEL_KEY_IP_MAX 1798 }; 1799 #define NFTA_TUNNEL_KEY_IP_MAX (__NFTA_TUNNEL_KEY_IP_MAX - 1) 1800 1801 enum nft_tunnel_ip6_attributes { 1802 NFTA_TUNNEL_KEY_IP6_UNSPEC, 1803 NFTA_TUNNEL_KEY_IP6_SRC, 1804 NFTA_TUNNEL_KEY_IP6_DST, 1805 NFTA_TUNNEL_KEY_IP6_FLOWLABEL, 1806 __NFTA_TUNNEL_KEY_IP6_MAX 1807 }; 1808 #define NFTA_TUNNEL_KEY_IP6_MAX (__NFTA_TUNNEL_KEY_IP6_MAX - 1) 1809 1810 enum nft_tunnel_opts_attributes { 1811 NFTA_TUNNEL_KEY_OPTS_UNSPEC, 1812 NFTA_TUNNEL_KEY_OPTS_VXLAN, 1813 NFTA_TUNNEL_KEY_OPTS_ERSPAN, 1814 NFTA_TUNNEL_KEY_OPTS_GENEVE, 1815 __NFTA_TUNNEL_KEY_OPTS_MAX 1816 }; 1817 #define NFTA_TUNNEL_KEY_OPTS_MAX (__NFTA_TUNNEL_KEY_OPTS_MAX - 1) 1818 1819 enum nft_tunnel_opts_vxlan_attributes { 1820 NFTA_TUNNEL_KEY_VXLAN_UNSPEC, 1821 NFTA_TUNNEL_KEY_VXLAN_GBP, 1822 __NFTA_TUNNEL_KEY_VXLAN_MAX 1823 }; 1824 #define NFTA_TUNNEL_KEY_VXLAN_MAX (__NFTA_TUNNEL_KEY_VXLAN_MAX - 1) 1825 1826 enum nft_tunnel_opts_erspan_attributes { 1827 NFTA_TUNNEL_KEY_ERSPAN_UNSPEC, 1828 NFTA_TUNNEL_KEY_ERSPAN_VERSION, 1829 NFTA_TUNNEL_KEY_ERSPAN_V1_INDEX, 1830 NFTA_TUNNEL_KEY_ERSPAN_V2_HWID, 1831 NFTA_TUNNEL_KEY_ERSPAN_V2_DIR, 1832 __NFTA_TUNNEL_KEY_ERSPAN_MAX 1833 }; 1834 #define NFTA_TUNNEL_KEY_ERSPAN_MAX (__NFTA_TUNNEL_KEY_ERSPAN_MAX - 1) 1835 1836 enum nft_tunnel_opts_geneve_attributes { 1837 NFTA_TUNNEL_KEY_GENEVE_UNSPEC, 1838 NFTA_TUNNEL_KEY_GENEVE_CLASS, 1839 NFTA_TUNNEL_KEY_GENEVE_TYPE, 1840 NFTA_TUNNEL_KEY_GENEVE_DATA, 1841 __NFTA_TUNNEL_KEY_GENEVE_MAX 1842 }; 1843 #define NFTA_TUNNEL_KEY_GENEVE_MAX (__NFTA_TUNNEL_KEY_GENEVE_MAX - 1) 1844 1845 enum nft_tunnel_flags { 1846 NFT_TUNNEL_F_ZERO_CSUM_TX = (1 << 0), 1847 NFT_TUNNEL_F_DONT_FRAGMENT = (1 << 1), 1848 NFT_TUNNEL_F_SEQ_NUMBER = (1 << 2), 1849 }; 1850 #define NFT_TUNNEL_F_MASK (NFT_TUNNEL_F_ZERO_CSUM_TX | \ 1851 NFT_TUNNEL_F_DONT_FRAGMENT | \ 1852 NFT_TUNNEL_F_SEQ_NUMBER) 1853 1854 enum nft_tunnel_key_attributes { 1855 NFTA_TUNNEL_KEY_UNSPEC, 1856 NFTA_TUNNEL_KEY_ID, 1857 NFTA_TUNNEL_KEY_IP, 1858 NFTA_TUNNEL_KEY_IP6, 1859 NFTA_TUNNEL_KEY_FLAGS, 1860 NFTA_TUNNEL_KEY_TOS, 1861 NFTA_TUNNEL_KEY_TTL, 1862 NFTA_TUNNEL_KEY_SPORT, 1863 NFTA_TUNNEL_KEY_DPORT, 1864 NFTA_TUNNEL_KEY_OPTS, 1865 __NFTA_TUNNEL_KEY_MAX 1866 }; 1867 #define NFTA_TUNNEL_KEY_MAX (__NFTA_TUNNEL_KEY_MAX - 1) 1868 1869 enum nft_tunnel_keys { 1870 NFT_TUNNEL_PATH, 1871 NFT_TUNNEL_ID, 1872 __NFT_TUNNEL_MAX 1873 }; 1874 #define NFT_TUNNEL_MAX (__NFT_TUNNEL_MAX - 1) 1875 1876 enum nft_tunnel_mode { 1877 NFT_TUNNEL_MODE_NONE, 1878 NFT_TUNNEL_MODE_RX, 1879 NFT_TUNNEL_MODE_TX, 1880 __NFT_TUNNEL_MODE_MAX 1881 }; 1882 #define NFT_TUNNEL_MODE_MAX (__NFT_TUNNEL_MODE_MAX - 1) 1883 1884 enum nft_tunnel_attributes { 1885 NFTA_TUNNEL_UNSPEC, 1886 NFTA_TUNNEL_KEY, 1887 NFTA_TUNNEL_DREG, 1888 NFTA_TUNNEL_MODE, 1889 __NFTA_TUNNEL_MAX 1890 }; 1891 #define NFTA_TUNNEL_MAX (__NFTA_TUNNEL_MAX - 1) 1892 1893 #endif /* _LINUX_NF_TABLES_H */ 1894