1 #ifndef _LINUX_NF_TABLES_H
2 #define _LINUX_NF_TABLES_H
4 #define NFT_CHAIN_MAXNAMELEN 32
14 #define NFT_REG_MAX (__NFT_REG_MAX - 1)
17 * enum nft_verdicts - nf_tables internal verdicts
19 * @NFT_CONTINUE: continue evaluation of the current rule
20 * @NFT_BREAK: terminate evaluation of the current rule
21 * @NFT_JUMP: push the current chain on the jump stack and jump to a chain
22 * @NFT_GOTO: jump to a chain without pushing the current chain on the jump stack
23 * @NFT_RETURN: return to the topmost chain on the jump stack
25 * The nf_tables verdicts share their numeric space with the netfilter verdicts.
36 * enum nf_tables_msg_types - nf_tables netlink message types
38 * @NFT_MSG_NEWTABLE: create a new table (enum nft_table_attributes)
39 * @NFT_MSG_GETTABLE: get a table (enum nft_table_attributes)
40 * @NFT_MSG_DELTABLE: delete a table (enum nft_table_attributes)
41 * @NFT_MSG_NEWCHAIN: create a new chain (enum nft_chain_attributes)
42 * @NFT_MSG_GETCHAIN: get a chain (enum nft_chain_attributes)
43 * @NFT_MSG_DELCHAIN: delete a chain (enum nft_chain_attributes)
44 * @NFT_MSG_NEWRULE: create a new rule (enum nft_rule_attributes)
45 * @NFT_MSG_GETRULE: get a rule (enum nft_rule_attributes)
46 * @NFT_MSG_DELRULE: delete a rule (enum nft_rule_attributes)
47 * @NFT_MSG_NEWSET: create a new set (enum nft_set_attributes)
48 * @NFT_MSG_GETSET: get a set (enum nft_set_attributes)
49 * @NFT_MSG_DELSET: delete a set (enum nft_set_attributes)
50 * @NFT_MSG_NEWSETELEM: create a new set element (enum nft_set_elem_attributes)
51 * @NFT_MSG_GETSETELEM: get a set element (enum nft_set_elem_attributes)
52 * @NFT_MSG_DELSETELEM: delete a set element (enum nft_set_elem_attributes)
54 enum nf_tables_msg_types {
74 * enum nft_list_attributes - nf_tables generic list netlink attributes
76 * @NFTA_LIST_ELEM: list element (NLA_NESTED)
78 enum nft_list_attributes {
83 #define NFTA_LIST_MAX (__NFTA_LIST_MAX - 1)
86 * enum nft_hook_attributes - nf_tables netfilter hook netlink attributes
88 * @NFTA_HOOK_HOOKNUM: netfilter hook number (NLA_U32)
89 * @NFTA_HOOK_PRIORITY: netfilter hook priority (NLA_U32)
91 enum nft_hook_attributes {
97 #define NFTA_HOOK_MAX (__NFTA_HOOK_MAX - 1)
100 * enum nft_table_attributes - nf_tables table netlink attributes
102 * @NFTA_TABLE_NAME: name of the table (NLA_STRING)
104 enum nft_table_attributes {
109 #define NFTA_TABLE_MAX (__NFTA_TABLE_MAX - 1)
112 * enum nft_chain_attributes - nf_tables chain netlink attributes
114 * @NFTA_CHAIN_TABLE: name of the table containing the chain (NLA_STRING)
115 * @NFTA_CHAIN_HANDLE: numeric handle of the chain (NLA_U64)
116 * @NFTA_CHAIN_NAME: name of the chain (NLA_STRING)
117 * @NFTA_CHAIN_HOOK: hook specification for basechains (NLA_NESTED: nft_hook_attributes)
118 * @NFTA_CHAIN_TYPE: type name of the string (NLA_NUL_STRING)
120 enum nft_chain_attributes {
129 #define NFTA_CHAIN_MAX (__NFTA_CHAIN_MAX - 1)
132 * enum nft_rule_attributes - nf_tables rule netlink attributes
134 * @NFTA_RULE_TABLE: name of the table containing the rule (NLA_STRING)
135 * @NFTA_RULE_CHAIN: name of the chain containing the rule (NLA_STRING)
136 * @NFTA_RULE_HANDLE: numeric handle of the rule (NLA_U64)
137 * @NFTA_RULE_EXPRESSIONS: list of expressions (NLA_NESTED: nft_expr_attributes)
139 enum nft_rule_attributes {
144 NFTA_RULE_EXPRESSIONS,
147 #define NFTA_RULE_MAX (__NFTA_RULE_MAX - 1)
150 * enum nft_set_flags - nf_tables set flags
152 * @NFT_SET_ANONYMOUS: name allocation, automatic cleanup on unlink
153 * @NFT_SET_CONSTANT: set contents may not change while bound
154 * @NFT_SET_INTERVAL: set contains intervals
155 * @NFT_SET_MAP: set is used as a dictionary
158 NFT_SET_ANONYMOUS = 0x1,
159 NFT_SET_CONSTANT = 0x2,
160 NFT_SET_INTERVAL = 0x4,
165 * enum nft_set_attributes - nf_tables set netlink attributes
167 * @NFTA_SET_TABLE: table name (NLA_STRING)
168 * @NFTA_SET_NAME: set name (NLA_STRING)
169 * @NFTA_SET_FLAGS: bitmask of enum nft_set_flags (NLA_U32)
170 * @NFTA_SET_KEY_TYPE: key data type, informational purpose only (NLA_U32)
171 * @NFTA_SET_KEY_LEN: key data length (NLA_U32)
172 * @NFTA_SET_DATA_TYPE: mapping data type (NLA_U32)
173 * @NFTA_SET_DATA_LEN: mapping data length (NLA_U32)
175 enum nft_set_attributes {
186 #define NFTA_SET_MAX (__NFTA_SET_MAX - 1)
189 * enum nft_set_elem_flags - nf_tables set element flags
191 * @NFT_SET_ELEM_INTERVAL_END: element ends the previous interval
193 enum nft_set_elem_flags {
194 NFT_SET_ELEM_INTERVAL_END = 0x1,
198 * enum nft_set_elem_attributes - nf_tables set element netlink attributes
200 * @NFTA_SET_ELEM_KEY: key value (NLA_NESTED: nft_data)
201 * @NFTA_SET_ELEM_DATA: data value of mapping (NLA_NESTED: nft_data_attributes)
202 * @NFTA_SET_ELEM_FLAGS: bitmask of nft_set_elem_flags (NLA_U32)
204 enum nft_set_elem_attributes {
205 NFTA_SET_ELEM_UNSPEC,
211 #define NFTA_SET_ELEM_MAX (__NFTA_SET_ELEM_MAX - 1)
214 * enum nft_set_elem_list_attributes - nf_tables set element list netlink attributes
216 * @NFTA_SET_ELEM_LIST_TABLE: table of the set to be changed (NLA_STRING)
217 * @NFTA_SET_ELEM_LIST_SET: name of the set to be changed (NLA_STRING)
218 * @NFTA_SET_ELEM_LIST_ELEMENTS: list of set elements (NLA_NESTED: nft_set_elem_attributes)
220 enum nft_set_elem_list_attributes {
221 NFTA_SET_ELEM_LIST_UNSPEC,
222 NFTA_SET_ELEM_LIST_TABLE,
223 NFTA_SET_ELEM_LIST_SET,
224 NFTA_SET_ELEM_LIST_ELEMENTS,
225 __NFTA_SET_ELEM_LIST_MAX
227 #define NFTA_SET_ELEM_LIST_MAX (__NFTA_SET_ELEM_LIST_MAX - 1)
230 * enum nft_data_types - nf_tables data types
232 * @NFT_DATA_VALUE: generic data
233 * @NFT_DATA_VERDICT: netfilter verdict
235 * The type of data is usually determined by the kernel directly and is not
236 * explicitly specified by userspace. The only difference are sets, where
237 * userspace specifies the key and mapping data types.
239 * The values 0xffffff00-0xffffffff are reserved for internally used types.
240 * The remaining range can be freely used by userspace to encode types, all
241 * values are equivalent to NFT_DATA_VALUE.
243 enum nft_data_types {
245 NFT_DATA_VERDICT = 0xffffff00U,
248 #define NFT_DATA_RESERVED_MASK 0xffffff00U
251 * enum nft_data_attributes - nf_tables data netlink attributes
253 * @NFTA_DATA_VALUE: generic data (NLA_BINARY)
254 * @NFTA_DATA_VERDICT: nf_tables verdict (NLA_NESTED: nft_verdict_attributes)
256 enum nft_data_attributes {
262 #define NFTA_DATA_MAX (__NFTA_DATA_MAX - 1)
265 * enum nft_verdict_attributes - nf_tables verdict netlink attributes
267 * @NFTA_VERDICT_CODE: nf_tables verdict (NLA_U32: enum nft_verdicts)
268 * @NFTA_VERDICT_CHAIN: jump target chain name (NLA_STRING)
270 enum nft_verdict_attributes {
276 #define NFTA_VERDICT_MAX (__NFTA_VERDICT_MAX - 1)
279 * enum nft_expr_attributes - nf_tables expression netlink attributes
281 * @NFTA_EXPR_NAME: name of the expression type (NLA_STRING)
282 * @NFTA_EXPR_DATA: type specific data (NLA_NESTED)
284 enum nft_expr_attributes {
290 #define NFTA_EXPR_MAX (__NFTA_EXPR_MAX - 1)
293 * enum nft_immediate_attributes - nf_tables immediate expression netlink attributes
295 * @NFTA_IMMEDIATE_DREG: destination register to load data into (NLA_U32)
296 * @NFTA_IMMEDIATE_DATA: data to load (NLA_NESTED: nft_data_attributes)
298 enum nft_immediate_attributes {
299 NFTA_IMMEDIATE_UNSPEC,
304 #define NFTA_IMMEDIATE_MAX (__NFTA_IMMEDIATE_MAX - 1)
307 * enum nft_bitwise_attributes - nf_tables bitwise expression netlink attributes
309 * @NFTA_BITWISE_SREG: source register (NLA_U32: nft_registers)
310 * @NFTA_BITWISE_DREG: destination register (NLA_U32: nft_registers)
311 * @NFTA_BITWISE_LEN: length of operands (NLA_U32)
312 * @NFTA_BITWISE_MASK: mask value (NLA_NESTED: nft_data_attributes)
313 * @NFTA_BITWISE_XOR: xor value (NLA_NESTED: nft_data_attributes)
315 * The bitwise expression performs the following operation:
317 * dreg = (sreg & mask) ^ xor
319 * which allow to express all bitwise operations:
327 enum nft_bitwise_attributes {
336 #define NFTA_BITWISE_MAX (__NFTA_BITWISE_MAX - 1)
339 * enum nft_byteorder_ops - nf_tables byteorder operators
341 * @NFT_BYTEORDER_NTOH: network to host operator
342 * @NFT_BYTEORDER_HTON: host to network opertaor
344 enum nft_byteorder_ops {
350 * enum nft_byteorder_attributes - nf_tables byteorder expression netlink attributes
352 * @NFTA_BYTEORDER_SREG: source register (NLA_U32: nft_registers)
353 * @NFTA_BYTEORDER_DREG: destination register (NLA_U32: nft_registers)
354 * @NFTA_BYTEORDER_OP: operator (NLA_U32: enum nft_byteorder_ops)
355 * @NFTA_BYTEORDER_LEN: length of the data (NLA_U32)
356 * @NFTA_BYTEORDER_SIZE: data size in bytes (NLA_U32: 2 or 4)
358 enum nft_byteorder_attributes {
359 NFTA_BYTEORDER_UNSPEC,
367 #define NFTA_BYTEORDER_MAX (__NFTA_BYTEORDER_MAX - 1)
370 * enum nft_cmp_ops - nf_tables relational operator
373 * @NFT_CMP_NEQ: not equal
374 * @NFT_CMP_LT: less than
375 * @NFT_CMP_LTE: less than or equal to
376 * @NFT_CMP_GT: greater than
377 * @NFT_CMP_GTE: greater than or equal to
389 * enum nft_cmp_attributes - nf_tables cmp expression netlink attributes
391 * @NFTA_CMP_SREG: source register of data to compare (NLA_U32: nft_registers)
392 * @NFTA_CMP_OP: cmp operation (NLA_U32: nft_cmp_ops)
393 * @NFTA_CMP_DATA: data to compare against (NLA_NESTED: nft_data_attributes)
395 enum nft_cmp_attributes {
402 #define NFTA_CMP_MAX (__NFTA_CMP_MAX - 1)
405 * enum nft_lookup_attributes - nf_tables set lookup expression netlink attributes
407 * @NFTA_LOOKUP_SET: name of the set where to look for (NLA_STRING)
408 * @NFTA_LOOKUP_SREG: source register of the data to look for (NLA_U32: nft_registers)
409 * @NFTA_LOOKUP_DREG: destination register (NLA_U32: nft_registers)
411 enum nft_lookup_attributes {
418 #define NFTA_LOOKUP_MAX (__NFTA_LOOKUP_MAX - 1)
421 * enum nft_payload_bases - nf_tables payload expression offset bases
423 * @NFT_PAYLOAD_LL_HEADER: link layer header
424 * @NFT_PAYLOAD_NETWORK_HEADER: network header
425 * @NFT_PAYLOAD_TRANSPORT_HEADER: transport header
427 enum nft_payload_bases {
428 NFT_PAYLOAD_LL_HEADER,
429 NFT_PAYLOAD_NETWORK_HEADER,
430 NFT_PAYLOAD_TRANSPORT_HEADER,
434 * enum nft_payload_attributes - nf_tables payload expression netlink attributes
436 * @NFTA_PAYLOAD_DREG: destination register to load data into (NLA_U32: nft_registers)
437 * @NFTA_PAYLOAD_BASE: payload base (NLA_U32: nft_payload_bases)
438 * @NFTA_PAYLOAD_OFFSET: payload offset relative to base (NLA_U32)
439 * @NFTA_PAYLOAD_LEN: payload length (NLA_U32)
441 enum nft_payload_attributes {
449 #define NFTA_PAYLOAD_MAX (__NFTA_PAYLOAD_MAX - 1)
452 * enum nft_exthdr_attributes - nf_tables IPv6 extension header expression netlink attributes
454 * @NFTA_EXTHDR_DREG: destination register (NLA_U32: nft_registers)
455 * @NFTA_EXTHDR_TYPE: extension header type (NLA_U8)
456 * @NFTA_EXTHDR_OFFSET: extension header offset (NLA_U32)
457 * @NFTA_EXTHDR_LEN: extension header length (NLA_U32)
459 enum nft_exthdr_attributes {
467 #define NFTA_EXTHDR_MAX (__NFTA_EXTHDR_MAX - 1)
470 * enum nft_meta_keys - nf_tables meta expression keys
472 * @NFT_META_LEN: packet length (skb->len)
473 * @NFT_META_PROTOCOL: packet ethertype protocol (skb->protocol), invalid in OUTPUT
474 * @NFT_META_PRIORITY: packet priority (skb->priority)
475 * @NFT_META_MARK: packet mark (skb->mark)
476 * @NFT_META_IIF: packet input interface index (dev->ifindex)
477 * @NFT_META_OIF: packet output interface index (dev->ifindex)
478 * @NFT_META_IIFNAME: packet input interface name (dev->name)
479 * @NFT_META_OIFNAME: packet output interface name (dev->name)
480 * @NFT_META_IIFTYPE: packet input interface type (dev->type)
481 * @NFT_META_OIFTYPE: packet output interface type (dev->type)
482 * @NFT_META_SKUID: originating socket UID (fsuid)
483 * @NFT_META_SKGID: originating socket GID (fsgid)
484 * @NFT_META_NFTRACE: packet nftrace bit
485 * @NFT_META_RTCLASSID: realm value of packet's route (skb->dst->tclassid)
486 * @NFT_META_SECMARK: packet secmark (skb->secmark)
507 * enum nft_meta_attributes - nf_tables meta expression netlink attributes
509 * @NFTA_META_DREG: destination register (NLA_U32)
510 * @NFTA_META_KEY: meta data item to load (NLA_U32: nft_meta_keys)
512 enum nft_meta_attributes {
518 #define NFTA_META_MAX (__NFTA_META_MAX - 1)
521 * enum nft_ct_keys - nf_tables ct expression keys
523 * @NFT_CT_STATE: conntrack state (bitmask of enum ip_conntrack_info)
524 * @NFT_CT_DIRECTION: conntrack direction (enum ip_conntrack_dir)
525 * @NFT_CT_STATUS: conntrack status (bitmask of enum ip_conntrack_status)
526 * @NFT_CT_MARK: conntrack mark value
527 * @NFT_CT_SECMARK: conntrack secmark value
528 * @NFT_CT_EXPIRATION: relative conntrack expiration time in ms
529 * @NFT_CT_HELPER: connection tracking helper assigned to conntrack
530 * @NFT_CT_L3PROTOCOL: conntrack layer 3 protocol
531 * @NFT_CT_SRC: conntrack layer 3 protocol source (IPv4/IPv6 address)
532 * @NFT_CT_DST: conntrack layer 3 protocol destination (IPv4/IPv6 address)
533 * @NFT_CT_PROTOCOL: conntrack layer 4 protocol
534 * @NFT_CT_PROTO_SRC: conntrack layer 4 protocol source
535 * @NFT_CT_PROTO_DST: conntrack layer 4 protocol destination
554 * enum nft_ct_attributes - nf_tables ct expression netlink attributes
556 * @NFTA_CT_DREG: destination register (NLA_U32)
557 * @NFTA_CT_KEY: conntrack data item to load (NLA_U32: nft_ct_keys)
558 * @NFTA_CT_DIRECTION: direction in case of directional keys (NLA_U8)
560 enum nft_ct_attributes {
567 #define NFTA_CT_MAX (__NFTA_CT_MAX - 1)
570 * enum nft_limit_attributes - nf_tables limit expression netlink attributes
572 * @NFTA_LIMIT_RATE: refill rate (NLA_U64)
573 * @NFTA_LIMIT_UNIT: refill unit (NLA_U64)
575 enum nft_limit_attributes {
581 #define NFTA_LIMIT_MAX (__NFTA_LIMIT_MAX - 1)
584 * enum nft_counter_attributes - nf_tables counter expression netlink attributes
586 * @NFTA_COUNTER_BYTES: number of bytes (NLA_U64)
587 * @NFTA_COUNTER_PACKETS: number of packets (NLA_U64)
589 enum nft_counter_attributes {
592 NFTA_COUNTER_PACKETS,
595 #define NFTA_COUNTER_MAX (__NFTA_COUNTER_MAX - 1)
598 * enum nft_log_attributes - nf_tables log expression netlink attributes
600 * @NFTA_LOG_GROUP: netlink group to send messages to (NLA_U32)
601 * @NFTA_LOG_PREFIX: prefix to prepend to log messages (NLA_STRING)
602 * @NFTA_LOG_SNAPLEN: length of payload to include in netlink message (NLA_U32)
603 * @NFTA_LOG_QTHRESHOLD: queue threshold (NLA_U32)
605 enum nft_log_attributes {
613 #define NFTA_LOG_MAX (__NFTA_LOG_MAX - 1)
616 * enum nft_reject_types - nf_tables reject expression reject types
618 * @NFT_REJECT_ICMP_UNREACH: reject using ICMP unreachable
619 * @NFT_REJECT_TCP_RST: reject using TCP RST
621 enum nft_reject_types {
622 NFT_REJECT_ICMP_UNREACH,
627 * enum nft_reject_attributes - nf_tables reject expression netlink attributes
629 * @NFTA_REJECT_TYPE: packet type to use (NLA_U32: nft_reject_types)
630 * @NFTA_REJECT_ICMP_CODE: ICMP code to use (NLA_U8)
632 enum nft_reject_attributes {
635 NFTA_REJECT_ICMP_CODE,
638 #define NFTA_REJECT_MAX (__NFTA_REJECT_MAX - 1)
641 * enum nft_nat_types - nf_tables nat expression NAT types
643 * @NFT_NAT_SNAT: source NAT
644 * @NFT_NAT_DNAT: destination NAT
652 * enum nft_nat_attributes - nf_tables nat expression netlink attributes
654 * @NFTA_NAT_TYPE: NAT type (NLA_U32: nft_nat_types)
655 * @NFTA_NAT_ADDR_MIN: source register of address range start (NLA_U32: nft_registers)
656 * @NFTA_NAT_ADDR_MAX: source register of address range end (NLA_U32: nft_registers)
657 * @NFTA_NAT_PROTO_MIN: source register of proto range start (NLA_U32: nft_registers)
658 * @NFTA_NAT_PROTO_MAX: source register of proto range end (NLA_U32: nft_registers)
660 enum nft_nat_attributes {
669 #define NFTA_NAT_MAX (__NFTA_NAT_MAX - 1)
671 #endif /* _LINUX_NF_TABLES_H */