Family nftables netlink specification¶
Summary¶
Netfilter nftables configuration over netlink.
Operations¶
batch-begin¶
Start a batch of operations
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
genid]
- reply
- attributes:
[
genid]
batch-end¶
Finish a batch of operations
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
genid]
newtable¶
Create a new table.
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
name,flags,userdata]
gettable¶
Get / dump tables.
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
name]
- reply
- attributes:
[
name,use,handle,flags,owner,userdata]
- dump:
- reply
- attributes:
[
name,use,handle,flags,owner,userdata]
deltable¶
Delete an existing table.
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
name,handle]
destroytable¶
Delete an existing table with destroy semantics (ignoring ENOENT errors).
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
name,handle]
newchain¶
Create a new chain.
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
table,handle,policy,flags,hook,name,counters,userdata,type]
getchain¶
Get / dump chains.
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
table,name]
- reply
- attributes:
[
table,name,handle,hook,policy,type,flags,counters,id,use,userdata]
- dump:
- reply
- attributes:
[
table,name,handle,hook,policy,type,flags,counters,id,use,userdata]
delchain¶
Delete an existing chain.
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
table,handle,name,hook]
destroychain¶
Delete an existing chain with destroy semantics (ignoring ENOENT errors).
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
table,handle,name,hook]
newrule¶
Create a new rule.
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
table,chain,chain-id,handle,position,position-id,expressions,userdata,compat]
getrule¶
Get / dump rules.
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
table,chain,handle]
- reply
- attributes:
[
table,chain,handle,position,expressions,userdata]
- dump:
- request
- attributes:
[
table,chain]
- reply
- attributes:
[
table,chain,handle,position,expressions,userdata]
getrule-reset¶
Get / dump rules and reset stateful expressions.
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
table,chain,handle]
- reply
- attributes:
[
table,chain,handle,position,expressions,userdata]
- dump:
- request
- attributes:
[
table,chain,handle]
- reply
- attributes:
[
table,chain,handle,position,expressions,userdata]
delrule¶
Delete an existing rule.
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
table,chain,handle,id]
destroyrule¶
Delete an existing rule with destroy semantics (ignoring ENOENT errors).
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
table,chain,handle,id]
newset¶
Create a new set.
getset¶
Get / dump sets.
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
table,name]
- reply
- attributes:
[
table,name,handle,flags,key-len,key-type,data-type,data-len,obj-type,gc-interval,policy,userdata,desc,expr,expressions]
- dump:
- request
- attributes:
[
table]
- reply
- attributes:
[
table,name,handle,flags,key-len,key-type,data-type,data-len,obj-type,gc-interval,policy,userdata,desc,expr,expressions]
delset¶
Delete an existing set.
destroyset¶
Delete an existing set with destroy semantics (ignoring ENOENT errors).
newsetelem¶
Create a new set element.
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
table,set,set-id,elements]
getsetelem¶
Get / dump set elements.
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
table,set,elements]
- reply
- attributes:
[
elements]
- dump:
- request
- attributes:
[
table,set]
- reply
- attributes:
[
table,set,elements]
getsetelem-reset¶
Get / dump set elements and reset stateful expressions.
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
elements]
- reply
- attributes:
[
table,set,elements]
- dump:
- request
- attributes:
[
table,set]
- reply
- attributes:
[
table,set,elements]
delsetelem¶
Delete an existing set element.
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
table,set,elements]
destroysetelem¶
Delete an existing set element with destroy semantics.
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
table,set,elements]
getgen¶
Get / dump rule-set generation.
newobj¶
Create a new stateful object.
getobj¶
Get / dump stateful objects.
delobj¶
Delete an existing stateful object.
destroyobj¶
Delete an existing stateful object with destroy semantics.
newflowtable¶
Create a new flow table.
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
table,name,hook,flags]
getflowtable¶
Get / dump flow tables.
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
name,table]
- reply
- attributes:
[
table,name,handle,use,flags,hook]
- dump:
- reply
- attributes:
[
table,name,handle,use,flags,hook]
delflowtable¶
Delete an existing flow table.
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
table,name,handle,hook]
destroyflowtable¶
Delete an existing flow table with destroy semantics.
- attribute-set:
- fixed-header:
- do:
- request
- attributes:
[
table,name,handle,hook]
Multicast groups¶
mgmt
Definitions¶
nfgenmsg¶
- type:
struct
- members:
- nfgen-family (
u8): - version (
u8): - res-id (
u16):
- nfgen-family (
meta-keys¶
- type:
enum
- entries:
lenprotocolprioritymarkiifoifiifnameoifnameiftypeoiftypeskuidskgidnftracertclassidsecmarknfprotol4-protobri-iifnamebri-oifnamepkttypecpuiifgroupoifgroupcgroupprandomsecpathiifkindoifkindbri-iifpvidbri-iifvprototime-nstime-daytime-hoursdifsdifnamebri-broute
bitwise-ops¶
- type:
enum
- entries:
- mask-xor:
mask-and-xor operation used to implement NOT, AND, OR and XOR boolean operations
- lshift:
- rshift:
- and:
- or:
- xor:
cmp-ops¶
- type:
enum
- entries:
eqneqltltegtgte
object-type¶
- type:
enum
- entries:
unspeccounterquotact-helperlimitconnlimittunnelct-timeoutsecmarkct-expectsynproxy
nat-range-flags¶
- type:
flags
- entries:
map-ipsproto-specifiedproto-randompersistentproto-random-fullyproto-offsetnetmap
table-flags¶
- type:
flags
- entries:
dormantownerpersist
chain-flags¶
- type:
flags
- entries:
basehw-offloadbinding
set-flags¶
- type:
flags
- entries:
anonymousconstantintervalmaptimeoutevalobjectconcatexpr
set-elem-flags¶
- type:
flags
- entries:
interval-endcatchall
lookup-flags¶
- type:
flags
- entries:
invert
ct-keys¶
- type:
enum
- entries:
statedirectionstatusmarksecmarkexpirationhelperl3protocolsrcdstprotocolproto-srcproto-dstlabelspktsbytesavgpktzoneeventmasksrc-ipdst-ipsrc-ip6dst-ip6ct-id
ct-direction¶
- type:
enum
- entries:
originalreply
quota-flags¶
- type:
flags
- entries:
invertdepleted
verdict-code¶
- type:
enum
- entries:
- continue:
- break:
- jump:
- goto:
- return:
- drop:
- accept:
- stolen:
- queue:
- repeat:
fib-result¶
- type:
enum
- entries:
oifoifnameaddrtype
fib-flags¶
- type:
flags
- entries:
saddrdaddrmarkiifoifpresent
reject-types¶
- type:
enum
- entries:
icmp-unreachtcp-rsticmpx-unreach
reject-inet-code¶
- doc:
These codes are mapped to real ICMP and ICMPv6 codes.
- type:
enum
- entries:
icmpx-no-routeicmpx-port-unreachicmpx-host-unreachicmpx-admin-prohibited
payload-base¶
- type:
enum
- entries:
link-layer-headernetwork-headertransport-headerinner-headertun-header
range-ops¶
- doc:
Range operator
- type:
enum
- entries:
eqneq
registers¶
- doc:
nf_tables registers. nf_tables used to have five registers: a verdict register and four data registers of size 16. The data registers have been changed to 16 registers of size 4. For compatibility reasons, the NFT_REG_[1-4] registers still map to areas of size 16, the 4 byte registers are addressed using NFT_REG32_00 - NFT_REG32_15.
- type:
enum
- entries:
- reg-verdict:
- reg-1:
- reg-2:
- reg-3:
- reg-4:
- reg32-00:
- reg32-01:
- reg32-02:
- reg32-03:
- reg32-04:
- reg32-05:
- reg32-06:
- reg32-07:
- reg32-08:
- reg32-09:
- reg32-10:
- reg32-11:
- reg32-12:
- reg32-13:
- reg32-14:
- reg32-15:
numgen-types¶
- type:
enum
- entries:
incrementalrandom
log-level¶
- doc:
nf_tables log levels
- type:
enum
- entries:
- emerg:
system is unusable
- alert:
action must be taken immediately
- crit:
critical conditions
- err:
error conditions
- warning:
warning conditions
- notice:
normal but significant condition
- info:
informational
- debug:
debug-level messages
- audit:
enabling audit logging
log-flags¶
- doc:
nf_tables log flags
- header:
linux/netfilter/nf_log.h
- type:
flags
- entries:
- tcpseq:
Log TCP sequence numbers
- tcpopt:
Log TCP options
- ipopt:
Log IP options
- uid:
Log UID owning local socket
- nflog:
Unsupported, don’t reuse
- macdecode:
Decode MAC header
Attribute sets¶
log-attrs¶
log expression netlink attributes
group (u16)¶
- doc:
netlink group to send messages to
- byte-order:
big-endian
prefix (string)¶
- doc:
prefix to prepend to log messages
snaplen (u32)¶
- doc:
length of payload to include in netlink message
- byte-order:
big-endian
qthreshold (u16)¶
- doc:
queue threshold
- byte-order:
big-endian
level (u32)¶
- doc:
log level
- enum:
- byte-order:
big-endian
flags (u32)¶
- doc:
logging flags
- enum:
- byte-order:
big-endian
numgen-attrs¶
nf_tables number generator expression netlink attributes
dreg (u32)¶
- doc:
destination register
- enum:
modulus (u32)¶
- doc:
maximum counter value
- byte-order:
big-endian
type (u32)¶
- doc:
operation type
- byte-order:
big-endian
- enum:
offset (u32)¶
- doc:
offset to be added to the counter
- byte-order:
big-endian
range-attrs¶
sreg (u32)¶
- doc:
source register of data to compare
- byte-order:
big-endian
- enum:
op (u32)¶
- doc:
cmp operation
- byte-order:
big-endian
- enum:
from-data (nest)¶
- doc:
data range from
- nested-attributes:
to-data (nest)¶
- doc:
data range to
- nested-attributes:
batch-attrs¶
genid (u32)¶
- doc:
generation ID for this changeset
- byte-order:
big-endian
table-attrs¶
name (string)¶
- doc:
name of the table
flags (u32)¶
- byte-order:
big-endian
- doc:
bitmask of flags
- enum:
- enum-as-flags:
True
use (u32)¶
- byte-order:
big-endian
- doc:
number of chains in this table
handle (u64)¶
- byte-order:
big-endian
- doc:
numeric handle of the table
pad (pad)¶
userdata (binary)¶
- doc:
user data
owner (u32)¶
- byte-order:
big-endian
- doc:
owner of this table through netlink portID
chain-attrs¶
table (string)¶
- doc:
name of the table containing the chain
handle (u64)¶
- byte-order:
big-endian
- doc:
numeric handle of the chain
name (string)¶
- doc:
name of the chain
hook (nest)¶
- nested-attributes:
- doc:
hook specification for basechains
policy (u32)¶
- byte-order:
big-endian
- doc:
numeric policy of the chain
use (u32)¶
- byte-order:
big-endian
- doc:
number of references to this chain
type (string)¶
- doc:
type name of the chain
counters (nest)¶
- nested-attributes:
- doc:
counter specification of the chain
flags (u32)¶
- byte-order:
big-endian
- doc:
chain flags
- enum:
- enum-as-flags:
True
id (u32)¶
- byte-order:
big-endian
- doc:
uniquely identifies a chain in a transaction
userdata (binary)¶
- doc:
user data
counter-attrs¶
bytes (u64)¶
- byte-order:
big-endian
packets (u64)¶
- byte-order:
big-endian
pad (pad)¶
nft-hook-attrs¶
num (u32)¶
- byte-order:
big-endian
priority (s32)¶
- byte-order:
big-endian
dev (string)¶
- doc:
net device name
devs (nest)¶
- nested-attributes:
- doc:
list of net devices
hook-dev-attrs¶
name (string)¶
- multi-attr:
True
nft-counter-attrs¶
bytes (u64)¶
- byte-order:
big-endian
packets (u64)¶
- byte-order:
big-endian
rule-attrs¶
table (string)¶
- doc:
name of the table containing the rule
chain (string)¶
- doc:
name of the chain containing the rule
handle (u64)¶
- byte-order:
big-endian
- doc:
numeric handle of the rule
expressions (nest)¶
- nested-attributes:
- doc:
list of expressions
compat (nest)¶
- nested-attributes:
- doc:
compatibility specifications of the rule
position (u64)¶
- byte-order:
big-endian
- doc:
numeric handle of the previous rule
userdata (binary)¶
- doc:
user data
id (u32)¶
- doc:
uniquely identifies a rule in a transaction
position-id (u32)¶
- doc:
transaction unique identifier of the previous rule
chain-id (u32)¶
- doc:
add the rule to chain by ID, alternative to chain name
expr-list-attrs¶
elem (nest)¶
- nested-attributes:
- multi-attr:
True
expr-attrs¶
name (string)¶
- doc:
name of the expression type
data (sub-message)¶
- sub-message:
- selector:
name
- doc:
type specific data
rule-compat-attrs¶
proto (u32)¶
- byte-order:
big-endian
- doc:
numeric value of the handled protocol
flags (u32)¶
- byte-order:
big-endian
- doc:
bitmask of flags
set-attrs¶
table (string)¶
- doc:
table name
name (string)¶
- doc:
set name
flags (u32)¶
- enum:
- byte-order:
big-endian
- doc:
bitmask of
enum nft_set_flags
key-type (u32)¶
- byte-order:
big-endian
- doc:
key data type, informational purpose only
key-len (u32)¶
- byte-order:
big-endian
- doc:
key data length
data-type (u32)¶
- byte-order:
big-endian
- doc:
mapping data type
data-len (u32)¶
- byte-order:
big-endian
- doc:
mapping data length
policy (u32)¶
- byte-order:
big-endian
- doc:
selection policy
desc (nest)¶
- nested-attributes:
- doc:
set description
id (u32)¶
- doc:
uniquely identifies a set in a transaction
timeout (u64)¶
- doc:
default timeout value
gc-interval (u32)¶
- doc:
garbage collection interval
userdata (binary)¶
- doc:
user data
pad (pad)¶
obj-type (u32)¶
- byte-order:
big-endian
- doc:
stateful object type
handle (u64)¶
- byte-order:
big-endian
- doc:
set handle
expr (nest)¶
- nested-attributes:
- doc:
set expression
- multi-attr:
True
expressions (nest)¶
- nested-attributes:
- doc:
list of expressions
type (string)¶
- doc:
set backend type
count (u32)¶
- byte-order:
big-endian
- doc:
number of set elements
set-desc-attrs¶
size (u32)¶
- byte-order:
big-endian
- doc:
number of elements in set
concat (nest)¶
- nested-attributes:
- doc:
description of field concatenation
- multi-attr:
True
set-desc-concat-attrs¶
elem (nest)¶
- nested-attributes:
set-field-attrs¶
len (u32)¶
- byte-order:
big-endian
set-list-attrs¶
elem (nest)¶
- nested-attributes:
- multi-attr:
True
setelem-attrs¶
key (nest)¶
- nested-attributes:
- doc:
key value
data (nest)¶
- nested-attributes:
- doc:
data value of mapping
flags (binary)¶
- doc:
bitmask of nft_set_elem_flags
timeout (u64)¶
- doc:
timeout value
expiration (u64)¶
- doc:
expiration time
userdata (binary)¶
- doc:
user data
expr (nest)¶
- nested-attributes:
- doc:
expression
objref (string)¶
- doc:
stateful object reference
key-end (nest)¶
- nested-attributes:
- doc:
closing key value
expressions (nest)¶
- nested-attributes:
- doc:
list of expressions
setelem-list-elem-attrs¶
elem (nest)¶
- nested-attributes:
- multi-attr:
True
setelem-list-attrs¶
table (string)¶
set (string)¶
elements (nest)¶
- nested-attributes:
set-id (u32)¶
gen-attrs¶
id (u32)¶
- byte-order:
big-endian
- doc:
ruleset generation id
proc-pid (u32)¶
- byte-order:
big-endian
proc-name (string)¶
obj-attrs¶
table (string)¶
- doc:
name of the table containing the expression
name (string)¶
- doc:
name of this expression type
type (u32)¶
- enum:
- byte-order:
big-endian
- doc:
stateful object type
data (sub-message)¶
- sub-message:
- selector:
type
- doc:
stateful object data
use (u32)¶
- byte-order:
big-endian
- doc:
number of references to this expression
handle (u64)¶
- byte-order:
big-endian
- doc:
object handle
pad (pad)¶
userdata (binary)¶
- doc:
user data
quota-attrs¶
bytes (u64)¶
- byte-order:
big-endian
flags (u32)¶
- byte-order:
big-endian
- enum:
pad (pad)¶
consumed (u64)¶
- byte-order:
big-endian
flowtable-attrs¶
table (string)¶
name (string)¶
hook (nest)¶
- nested-attributes:
use (u32)¶
- byte-order:
big-endian
handle (u64)¶
- byte-order:
big-endian
pad (pad)¶
flags (u32)¶
- byte-order:
big-endian
flowtable-hook-attrs¶
num (u32)¶
- byte-order:
big-endian
priority (u32)¶
- byte-order:
big-endian
devs (nest)¶
- nested-attributes:
expr-bitwise-attrs¶
The bitwise expression supports boolean and shift operations. It implements the boolean operations by performing the following operation:
dreg = (sreg & mask) ^ xor
with these mask and xor values:
op mask xor
---- ---- ---
NOT: 1 1
OR: ~x x
XOR: 1 x
AND: x 0
sreg (u32)¶
- byte-order:
big-endian
dreg (u32)¶
- byte-order:
big-endian
len (u32)¶
- byte-order:
big-endian
mask (nest)¶
- nested-attributes:
xor (nest)¶
- nested-attributes:
op (u32)¶
- byte-order:
big-endian
- enum:
data (nest)¶
- nested-attributes:
expr-cmp-attrs¶
sreg (u32)¶
- byte-order:
big-endian
op (u32)¶
- byte-order:
big-endian
- enum:
data (nest)¶
- nested-attributes:
data-attrs¶
value (binary)¶
verdict (nest)¶
- nested-attributes:
verdict-attrs¶
code (u32)¶
- doc:
nf_tables verdict
- byte-order:
big-endian
- enum:
chain (string)¶
- doc:
jump target chain name
chain-id (u32)¶
- doc:
jump target chain ID
- byte-order:
big-endian
expr-counter-attrs¶
bytes (u64)¶
- byte-order:
big-endian
- doc:
Number of bytes
packets (u64)¶
- byte-order:
big-endian
- doc:
Number of packets
pad (pad)¶
expr-fib-attrs¶
dreg (u32)¶
- byte-order:
big-endian
result (u32)¶
- byte-order:
big-endian
- enum:
flags (u32)¶
- byte-order:
big-endian
- enum:
expr-ct-attrs¶
dreg (u32)¶
- byte-order:
big-endian
key (u32)¶
- byte-order:
big-endian
- enum:
direction (u8)¶
- enum:
sreg (u32)¶
- byte-order:
big-endian
expr-flow-offload-attrs¶
name (string)¶
- doc:
Flow offload table name
expr-immediate-attrs¶
dreg (u32)¶
- byte-order:
big-endian
data (nest)¶
- nested-attributes:
expr-lookup-attrs¶
set (string)¶
- doc:
Name of set to use
set-id (u32)¶
- byte-order:
big-endian
- doc:
ID of set to use
sreg (u32)¶
- byte-order:
big-endian
dreg (u32)¶
- byte-order:
big-endian
flags (u32)¶
- byte-order:
big-endian
- enum:
expr-masq-attrs¶
flags (u32)¶
- byte-order:
big-endian
- enum:
- enum-as-flags:
True
reg-proto-min (u32)¶
- byte-order:
big-endian
- enum:
reg-proto-max (u32)¶
- byte-order:
big-endian
- enum:
expr-meta-attrs¶
dreg (u32)¶
- byte-order:
big-endian
key (u32)¶
- byte-order:
big-endian
- enum:
sreg (u32)¶
- byte-order:
big-endian
expr-nat-attrs¶
type (u32)¶
- byte-order:
big-endian
family (u32)¶
- byte-order:
big-endian
reg-addr-min (u32)¶
- byte-order:
big-endian
reg-addr-max (u32)¶
- byte-order:
big-endian
reg-proto-min (u32)¶
- byte-order:
big-endian
reg-proto-max (u32)¶
- byte-order:
big-endian
flags (u32)¶
- byte-order:
big-endian
- enum:
- enum-as-flags:
True
expr-payload-attrs¶
nf_tables payload expression netlink attributes
dreg (u32)¶
- doc:
destination register to load data into
- byte-order:
big-endian
- enum:
base (u32)¶
- doc:
payload base
- enum:
- byte-order:
big-endian
offset (u32)¶
- doc:
payload offset relative to base
- byte-order:
big-endian
len (u32)¶
- doc:
payload length
- byte-order:
big-endian
sreg (u32)¶
- doc:
source register to load data from
- byte-order:
big-endian
- enum:
csum-type (u32)¶
- doc:
checksum type
- byte-order:
big-endian
csum-offset (u32)¶
- doc:
checksum offset relative to base
- byte-order:
big-endian
csum-flags (u32)¶
- doc:
checksum flags
- byte-order:
big-endian
expr-reject-attrs¶
type (u32)¶
- byte-order:
big-endian
- enum:
icmp-code (u8)¶
expr-target-attrs¶
name (string)¶
rev (u32)¶
- byte-order:
big-endian
info (binary)¶
expr-tproxy-attrs¶
family (u32)¶
- byte-order:
big-endian
reg-addr (u32)¶
- byte-order:
big-endian
reg-port (u32)¶
- byte-order:
big-endian
expr-objref-attrs¶
imm-type (u32)¶
- byte-order:
big-endian
imm-name (string)¶
- doc:
object name
set-sreg (u32)¶
- byte-order:
big-endian
set-name (string)¶
- doc:
name of object map
set-id (u32)¶
- byte-order:
big-endian
- doc:
id of object map
compat-target-attrs¶
name (string)¶
rev (u32)¶
- byte-order:
big-endian
info (binary)¶
compat-match-attrs¶
name (string)¶
rev (u32)¶
- byte-order:
big-endian
info (binary)¶
compat-attrs¶
name (string)¶
rev (u32)¶
- byte-order:
big-endian
type (u32)¶
- byte-order:
big-endian
Sub-messages¶
expr-ops¶
- bitwise
- attribute-set:
- cmp
- attribute-set:
- counter
- attribute-set:
- ct
- attribute-set:
- fib
- attribute-set:
- flow_offload
- attribute-set:
- immediate
- attribute-set:
- log
- attribute-set:
- lookup
- attribute-set:
- match
- attribute-set:
- meta
- attribute-set:
- nat
- attribute-set:
- numgen
- attribute-set:
- objref
- attribute-set:
- payload
- attribute-set:
- quota
- attribute-set:
- range
- attribute-set:
- reject
- attribute-set:
- target
- attribute-set:
- tproxy
- attribute-set:
obj-data¶
- counter
- attribute-set:
- quota
- attribute-set: