summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/Makefile.am30
-rw-r--r--doc/Makefile.in652
-rw-r--r--doc/data-types.txt537
-rw-r--r--doc/libnftables-json.52422
-rw-r--r--doc/libnftables-json.adoc1416
-rw-r--r--doc/libnftables.3393
-rw-r--r--doc/libnftables.adoc319
-rw-r--r--doc/nft.89717
-rw-r--r--doc/nft.txt1009
-rw-r--r--doc/payload-expression.txt973
-rw-r--r--doc/primary-expression.txt488
-rw-r--r--doc/stateful-objects.txt243
-rw-r--r--doc/statements.txt875
13 files changed, 19074 insertions, 0 deletions
diff --git a/doc/Makefile.am b/doc/Makefile.am
new file mode 100644
index 0000000..b43cb08
--- /dev/null
+++ b/doc/Makefile.am
@@ -0,0 +1,30 @@
+if BUILD_MAN
+dist_man_MANS = nft.8 libnftables-json.5 libnftables.3
+
+A2X_OPTS_MANPAGE = -L --doctype manpage --format manpage -D ${builddir}
+
+ASCIIDOC_MAIN = nft.txt
+ASCIIDOC_INCLUDES = \
+ data-types.txt \
+ payload-expression.txt \
+ primary-expression.txt \
+ stateful-objects.txt \
+ statements.txt
+ASCIIDOCS = ${ASCIIDOC_MAIN} ${ASCIIDOC_INCLUDES}
+
+EXTRA_DIST = ${ASCIIDOCS} libnftables-json.adoc libnftables.adoc
+
+CLEANFILES = \
+ *~
+
+nft.8: ${ASCIIDOCS}
+ ${AM_V_GEN}${A2X} ${A2X_OPTS_MANPAGE} $<
+
+.adoc.3:
+ ${AM_V_GEN}${A2X} ${A2X_OPTS_MANPAGE} $<
+
+.adoc.5:
+ ${AM_V_GEN}${A2X} ${A2X_OPTS_MANPAGE} $<
+
+MAINTAINERCLEANFILES = ${dist_man_MANS}
+endif
diff --git a/doc/Makefile.in b/doc/Makefile.in
new file mode 100644
index 0000000..edffa60
--- /dev/null
+++ b/doc/Makefile.in
@@ -0,0 +1,652 @@
+# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = doc
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/gcc4_visibility.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+SOURCES =
+DIST_SOURCES =
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+man3dir = $(mandir)/man3
+am__installdirs = "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(man5dir)" \
+ "$(DESTDIR)$(man8dir)"
+man5dir = $(mandir)/man5
+man8dir = $(mandir)/man8
+NROFF = nroff
+MANS = $(dist_man_MANS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.in
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+A2X = @A2X@
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GCC_FVISIBILITY_HIDDEN = @GCC_FVISIBILITY_HIDDEN@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBMNL_CFLAGS = @LIBMNL_CFLAGS@
+LIBMNL_LIBS = @LIBMNL_LIBS@
+LIBNFTNL_CFLAGS = @LIBNFTNL_CFLAGS@
+LIBNFTNL_LIBS = @LIBNFTNL_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XTABLES_CFLAGS = @XTABLES_CFLAGS@
+XTABLES_LIBS = @XTABLES_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+runstatedir = @runstatedir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+@BUILD_MAN_TRUE@dist_man_MANS = nft.8 libnftables-json.5 libnftables.3
+@BUILD_MAN_TRUE@A2X_OPTS_MANPAGE = -L --doctype manpage --format manpage -D ${builddir}
+@BUILD_MAN_TRUE@ASCIIDOC_MAIN = nft.txt
+@BUILD_MAN_TRUE@ASCIIDOC_INCLUDES = \
+@BUILD_MAN_TRUE@ data-types.txt \
+@BUILD_MAN_TRUE@ payload-expression.txt \
+@BUILD_MAN_TRUE@ primary-expression.txt \
+@BUILD_MAN_TRUE@ stateful-objects.txt \
+@BUILD_MAN_TRUE@ statements.txt
+
+@BUILD_MAN_TRUE@ASCIIDOCS = ${ASCIIDOC_MAIN} ${ASCIIDOC_INCLUDES}
+@BUILD_MAN_TRUE@EXTRA_DIST = ${ASCIIDOCS} libnftables-json.adoc libnftables.adoc
+@BUILD_MAN_TRUE@CLEANFILES = \
+@BUILD_MAN_TRUE@ *~
+
+@BUILD_MAN_TRUE@MAINTAINERCLEANFILES = ${dist_man_MANS}
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .3 .5 .adoc
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign doc/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign doc/Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-man3: $(dist_man_MANS)
+ @$(NORMAL_INSTALL)
+ @list1=''; \
+ list2='$(dist_man_MANS)'; \
+ test -n "$(man3dir)" \
+ && test -n "`echo $$list1$$list2`" \
+ || exit 0; \
+ echo " $(MKDIR_P) '$(DESTDIR)$(man3dir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(man3dir)" || exit 1; \
+ { for i in $$list1; do echo "$$i"; done; \
+ if test -n "$$list2"; then \
+ for i in $$list2; do echo "$$i"; done \
+ | sed -n '/\.3[a-z]*$$/p'; \
+ fi; \
+ } | while read p; do \
+ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; echo "$$p"; \
+ done | \
+ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \
+ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
+ sed 'N;N;s,\n, ,g' | { \
+ list=; while read file base inst; do \
+ if test "$$base" = "$$inst"; then list="$$list $$file"; else \
+ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man3dir)/$$inst'"; \
+ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man3dir)/$$inst" || exit $$?; \
+ fi; \
+ done; \
+ for i in $$list; do echo "$$i"; done | $(am__base_list) | \
+ while read files; do \
+ test -z "$$files" || { \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man3dir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(man3dir)" || exit $$?; }; \
+ done; }
+
+uninstall-man3:
+ @$(NORMAL_UNINSTALL)
+ @list=''; test -n "$(man3dir)" || exit 0; \
+ files=`{ for i in $$list; do echo "$$i"; done; \
+ l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+ sed -n '/\.3[a-z]*$$/p'; \
+ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \
+ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
+ dir='$(DESTDIR)$(man3dir)'; $(am__uninstall_files_from_dir)
+install-man5: $(dist_man_MANS)
+ @$(NORMAL_INSTALL)
+ @list1=''; \
+ list2='$(dist_man_MANS)'; \
+ test -n "$(man5dir)" \
+ && test -n "`echo $$list1$$list2`" \
+ || exit 0; \
+ echo " $(MKDIR_P) '$(DESTDIR)$(man5dir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(man5dir)" || exit 1; \
+ { for i in $$list1; do echo "$$i"; done; \
+ if test -n "$$list2"; then \
+ for i in $$list2; do echo "$$i"; done \
+ | sed -n '/\.5[a-z]*$$/p'; \
+ fi; \
+ } | while read p; do \
+ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; echo "$$p"; \
+ done | \
+ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \
+ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
+ sed 'N;N;s,\n, ,g' | { \
+ list=; while read file base inst; do \
+ if test "$$base" = "$$inst"; then list="$$list $$file"; else \
+ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man5dir)/$$inst'"; \
+ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man5dir)/$$inst" || exit $$?; \
+ fi; \
+ done; \
+ for i in $$list; do echo "$$i"; done | $(am__base_list) | \
+ while read files; do \
+ test -z "$$files" || { \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man5dir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(man5dir)" || exit $$?; }; \
+ done; }
+
+uninstall-man5:
+ @$(NORMAL_UNINSTALL)
+ @list=''; test -n "$(man5dir)" || exit 0; \
+ files=`{ for i in $$list; do echo "$$i"; done; \
+ l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+ sed -n '/\.5[a-z]*$$/p'; \
+ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \
+ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
+ dir='$(DESTDIR)$(man5dir)'; $(am__uninstall_files_from_dir)
+install-man8: $(dist_man_MANS)
+ @$(NORMAL_INSTALL)
+ @list1=''; \
+ list2='$(dist_man_MANS)'; \
+ test -n "$(man8dir)" \
+ && test -n "`echo $$list1$$list2`" \
+ || exit 0; \
+ echo " $(MKDIR_P) '$(DESTDIR)$(man8dir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(man8dir)" || exit 1; \
+ { for i in $$list1; do echo "$$i"; done; \
+ if test -n "$$list2"; then \
+ for i in $$list2; do echo "$$i"; done \
+ | sed -n '/\.8[a-z]*$$/p'; \
+ fi; \
+ } | while read p; do \
+ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; echo "$$p"; \
+ done | \
+ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \
+ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
+ sed 'N;N;s,\n, ,g' | { \
+ list=; while read file base inst; do \
+ if test "$$base" = "$$inst"; then list="$$list $$file"; else \
+ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man8dir)/$$inst'"; \
+ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man8dir)/$$inst" || exit $$?; \
+ fi; \
+ done; \
+ for i in $$list; do echo "$$i"; done | $(am__base_list) | \
+ while read files; do \
+ test -z "$$files" || { \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man8dir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(man8dir)" || exit $$?; }; \
+ done; }
+
+uninstall-man8:
+ @$(NORMAL_UNINSTALL)
+ @list=''; test -n "$(man8dir)" || exit 0; \
+ files=`{ for i in $$list; do echo "$$i"; done; \
+ l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+ sed -n '/\.8[a-z]*$$/p'; \
+ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \
+ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
+ dir='$(DESTDIR)$(man8dir)'; $(am__uninstall_files_from_dir)
+tags TAGS:
+
+ctags CTAGS:
+
+cscope cscopelist:
+
+
+distdir: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(MANS)
+installdirs:
+ for dir in "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(man5dir)" "$(DESTDIR)$(man8dir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+ -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-man
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man: install-man3 install-man5 install-man8
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-man
+
+uninstall-man: uninstall-man3 uninstall-man5 uninstall-man8
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+ cscopelist-am ctags-am distclean distclean-generic \
+ distclean-libtool distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-man3 install-man5 install-man8 install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \
+ uninstall-am uninstall-man uninstall-man3 uninstall-man5 \
+ uninstall-man8
+
+.PRECIOUS: Makefile
+
+
+@BUILD_MAN_TRUE@nft.8: ${ASCIIDOCS}
+@BUILD_MAN_TRUE@ ${AM_V_GEN}${A2X} ${A2X_OPTS_MANPAGE} $<
+
+@BUILD_MAN_TRUE@.adoc.3:
+@BUILD_MAN_TRUE@ ${AM_V_GEN}${A2X} ${A2X_OPTS_MANPAGE} $<
+
+@BUILD_MAN_TRUE@.adoc.5:
+@BUILD_MAN_TRUE@ ${AM_V_GEN}${A2X} ${A2X_OPTS_MANPAGE} $<
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/doc/data-types.txt b/doc/data-types.txt
new file mode 100644
index 0000000..961fc62
--- /dev/null
+++ b/doc/data-types.txt
@@ -0,0 +1,537 @@
+INTEGER TYPE
+~~~~~~~~~~~
+[options="header"]
+|==================
+|Name | Keyword | Size | Base type
+|Integer |
+integer |
+variable |
+-
+|===================
+
+The integer type is used for numeric values. It may be specified as a decimal,
+hexadecimal or octal number. The integer type does not have a fixed size, its
+size is determined by the expression for which it is used.
+
+BITMASK TYPE
+~~~~~~~~~~~~
+[options="header"]
+|==================
+|Name | Keyword | Size | Base type
+|Bitmask |
+bitmask |
+variable |
+integer
+|===================
+
+The bitmask type (*bitmask*) is used for bitmasks.
+
+STRING TYPE
+~~~~~~~~~~~~
+[options="header"]
+|==================
+|Name | Keyword | Size | Base type
+|String |
+string |
+variable |
+-
+|===================
+
+The string type is used for character strings. A string begins with an
+alphabetic character (a-zA-Z) followed by zero or more alphanumeric characters
+or the characters /, -, _ and .. In addition, anything enclosed in double
+quotes (") is recognized as a string.
+
+.String specification
+----------------------
+# Interface name
+filter input iifname eth0
+
+# Weird interface name
+filter input iifname "(eth0)"
+----------------------------
+
+LINK LAYER ADDRESS TYPE
+~~~~~~~~~~~~~~~~~~~~~~~
+[options="header"]
+|==================
+|Name | Keyword | Size | Base type
+|Link layer address |
+lladdr|
+variable |
+integer
+|===================
+
+The link layer address type is used for link layer addresses. Link layer
+addresses are specified as a variable amount of groups of two hexadecimal digits
+separated using colons (:).
+
+.Link layer address specification
+----------------------
+# Ethernet destination MAC address
+filter input ether daddr 20:c9:d0:43:12:d9
+----------------------------
+
+IPV4 ADDRESS TYPE
+~~~~~~~~~~~~~~~~~
+[options="header"]
+|==================
+|Name | Keyword | Size | Base type
+|IPV4 address|
+ipv4_addr|
+32 bit|
+integer
+|===================
+
+The IPv4 address type is used for IPv4 addresses. Addresses are specified in
+either dotted decimal, dotted hexadecimal, dotted octal, decimal, hexadecimal,
+octal notation or as a host name. A host name will be resolved using the
+standard system resolver.
+
+.IPv4 address specification
+----------------------
+# dotted decimal notation
+filter output ip daddr 127.0.0.1
+
+# host name
+filter output ip daddr localhost
+----------------------------
+
+IPV6 ADDRESS TYPE
+~~~~~~~~~~~~~~~~~
+[options="header"]
+|==================
+|Name | Keyword | Size | Base type
+|IPv6 address|
+ipv6_addr|
+128 bit|
+integer
+|===================
+
+The IPv6 address type is used for IPv6 addresses. Addresses are specified as a
+host name or as hexadecimal halfwords separated by colons. Addresses might be
+enclosed in square brackets ("[]") to differentiate them from port numbers.
+
+.IPv6 address specification
+----------------------
+# abbreviated loopback address
+filter output ip6 daddr ::1
+----------------------------
+
+.IPv6 address specification with bracket notation
+----------------------
+# without [] the port number (22) would be parsed as part of the
+# ipv6 address
+ip6 nat prerouting tcp dport 2222 dnat to [1ce::d0]:22
+----------------------------
+
+BOOLEAN TYPE
+~~~~~~~~~~~~
+[options="header"]
+|==================
+|Name | Keyword | Size | Base type
+|Boolean |
+boolean |
+1 bit |
+integer
+|===================
+
+The boolean type is a syntactical helper type in userspace. Its use is in the
+right-hand side of a (typically implicit) relational expression to change the
+expression on the left-hand side into a boolean check (usually for existence). +
+
+.The following keywords will automatically resolve into a boolean type with given value
+
+[options="header"]
+|==================
+|Keyword | Value
+|exists |
+1 |
+missing |
+0
+|===================
+
+.expressions support a boolean comparison
+[options="header"]
+|======================================
+|Expression | Behaviour
+|fib |
+Check route existence.
+|exthdr|
+Check IPv6 extension header existence.
+|tcp option |
+Check TCP option header existence.
+|===================
+
+.Boolean specification
+----------------------
+# match if route exists
+filter input fib daddr . iif oif exists
+
+# match only non-fragmented packets in IPv6 traffic
+filter input exthdr frag missing
+
+# match if TCP timestamp option is present
+filter input tcp option timestamp exists
+------------------------------------------
+
+ICMP TYPE TYPE
+~~~~~~~~~~~~~~
+[options="header"]
+|==================
+|Name | Keyword | Size | Base type
+|ICMP Type |
+icmp_type |
+8 bit |
+integer
+|===================
+The ICMP Type type is used to conveniently specify the ICMP header's type field.
+
+.Keywords may be used when specifying the ICMP type
+[options="header"]
+|==================
+|Keyword | Value
+|echo-reply |
+0
+|destination-unreachable |
+3
+|source-quench|
+4
+|redirect|
+5
+|echo-request|
+8
+|router-advertisement|
+9
+|router-solicitation|
+10
+|time-exceeded|
+11
+|parameter-problem|
+12
+|timestamp-request|
+13
+|timestamp-reply|
+14
+|info-request|
+15
+|info-reply|
+16
+|address-mask-request|
+17
+|address-mask-reply|
+18
+|===================
+
+.ICMP Type specification
+------------------------
+# match ping packets
+filter output icmp type { echo-request, echo-reply }
+------------------------
+
+ICMP CODE TYPE
+~~~~~~~~~~~~~~
+[options="header"]
+|==================
+|Name | Keyword | Size | Base type
+|ICMP Code |
+icmp_code |
+8 bit |
+integer
+|===================
+
+The ICMP Code type is used to conveniently specify the ICMP header's code field.
+
+.Keywords may be used when specifying the ICMP code
+[options="header"]
+|==================
+|Keyword | Value
+|net-unreachable |
+0
+|host-unreachable |
+1
+|prot-unreachable|
+2
+|port-unreachable|
+3
+|frag-needed|
+4
+|net-prohibited|
+9
+|host-prohibited|
+10
+|admin-prohibited|
+13
+|===================
+
+ICMPV6 TYPE TYPE
+~~~~~~~~~~~~~~~~
+[options="header"]
+|==================
+|Name | Keyword | Size | Base type
+|ICMPv6 Type |
+icmpx_code |
+8 bit |
+integer
+|===================
+
+The ICMPv6 Type type is used to conveniently specify the ICMPv6 header's type field.
+
+.keywords may be used when specifying the ICMPv6 type:
+[options="header"]
+|==================
+|Keyword | Value
+|destination-unreachable |
+1
+|packet-too-big|
+2
+|time-exceeded|
+3
+|parameter-problem|
+4
+|echo-request|
+128
+|echo-reply|
+129
+|mld-listener-query|
+130
+|mld-listener-report|
+131
+|mld-listener-done |
+132
+|mld-listener-reduction|
+132
+|nd-router-solicit |
+133
+|nd-router-advert|
+134
+|nd-neighbor-solicit|
+135
+|nd-neighbor-advert|
+136
+|nd-redirect|
+137
+|router-renumbering|
+138
+|ind-neighbor-solicit|
+141
+|ind-neighbor-advert|
+142
+|mld2-listener-report|
+143
+|===================
+
+.ICMPv6 Type specification
+--------------------------
+# match ICMPv6 ping packets
+filter output icmpv6 type { echo-request, echo-reply }
+--------------------------
+
+ICMPV6 CODE TYPE
+~~~~~~~~~~~~~~~~
+[options="header"]
+|==================
+|Name | Keyword | Size | Base type
+|ICMPv6 Code |
+icmpv6_code |
+8 bit |
+integer
+|===================
+
+The ICMPv6 Code type is used to conveniently specify the ICMPv6 header's code field.
+
+.keywords may be used when specifying the ICMPv6 code
+[options="header"]
+|==================
+|Keyword |Value
+|no-route|
+0
+|admin-prohibited|
+1
+|addr-unreachable|
+3
+|port-unreachable|
+4
+|policy-fail|
+5
+|reject-route|
+6
+|==================
+
+ICMPVX CODE TYPE
+~~~~~~~~~~~~~~~~
+[options="header"]
+|==================
+|Name | Keyword | Size | Base type
+|ICMPvX Code |
+icmpv6_type |
+8 bit |
+integer
+|===================
+
+The ICMPvX Code type abstraction is a set of values which overlap between ICMP
+and ICMPv6 Code types to be used from the inet family.
+
+.keywords may be used when specifying the ICMPvX code
+[options="header"]
+|==================
+|Keyword |Value
+|no-route|
+0
+|port-unreachable|
+1
+|host-unreachable|
+2
+|admin-prohibited|
+3
+|=================
+
+CONNTRACK TYPES
+~~~~~~~~~~~~~~~
+
+.overview of types used in ct expression and statement
+[options="header"]
+|==================
+|Name | Keyword |Size |Base type
+|conntrack state|
+ct_state|
+4 byte|
+bitmask
+|conntrack direction|
+ct_dir |
+8 bit|
+integer
+|conntrack status|
+ct_status|
+4 byte|
+bitmask
+|conntrack event bits|
+ct_event |
+4 byte |
+bitmask
+|conntrack label|
+ct_label |
+128 bit|
+bitmask
+|=================
+
+For each of the types above, keywords are available for convenience:
+
+.conntrack state (ct_state)
+[options="header"]
+|==================
+|Keyword| Value
+|invalid|
+1
+|established|
+2
+|related|
+4
+|new|
+8
+|untracked|
+64
+|================
+
+.conntrack direction (ct_dir)
+[options="header"]
+|==================
+|Keyword| Value
+|original|
+0
+|reply|
+1
+|================
+
+.conntrack status (ct_status)
+[options="header"]
+|==================
+|Keyword| Value
+|expected|
+1
+|seen-reply|
+2
+|assured|
+4
+|confirmed|
+8
+|snat|
+16
+|dnat|
+32
+|dying|
+512
+|================
+
+.conntrack event bits (ct_event)
+[options="header"]
+|==================
+|Keyword| Value
+|new|
+1
+|related|
+2
+|destroy|
+4
+|reply|
+8
+|assured|
+16
+|protoinfo|
+32
+|helper|
+64
+|mark|
+128
+|seqadj|
+256
+|secmark|
+512
+|label|
+1024
+|==================
+
+Possible keywords for conntrack label type (ct_label) are read at runtime from /etc/connlabel.conf.
+
+DCCP PKTTYPE TYPE
+~~~~~~~~~~~~~~~~
+[options="header"]
+|==================
+|Name | Keyword | Size | Base type
+|DCCP packet type |
+dccp_pkttype |
+4 bit |
+integer
+|===================
+
+The DCCP packet type abstracts the different legal values of the respective
+four bit field in the DCCP header, as stated by RFC4340. Note that possible
+values 10-15 are considered reserved and therefore not allowed to be used. In
+iptables' *dccp* match, these values are aliased 'INVALID'. With nftables, one
+may simply match on the numeric value range, i.e. *10-15*.
+
+.keywords may be used when specifying the DCCP packet type
+[options="header"]
+|==================
+|Keyword |Value
+|request|
+0
+|response|
+1
+|data|
+2
+|ack|
+3
+|dataack|
+4
+|closereq|
+5
+|close|
+6
+|reset|
+7
+|sync|
+8
+|syncack|
+9
+|=================
diff --git a/doc/libnftables-json.5 b/doc/libnftables-json.5
new file mode 100644
index 0000000..4d4e3e2
--- /dev/null
+++ b/doc/libnftables-json.5
@@ -0,0 +1,2422 @@
+'\" t
+.\" Title: libnftables-json
+.\" Author: Phil Sutter <phil@nwl.cc>
+.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
+.\" Date: 10/11/2023
+.\" Manual: \ \&
+.\" Source: \ \&
+.\" Language: English
+.\"
+.TH "LIBNFTABLES\-JSON" "5" "10/11/2023" "\ \&" "\ \&"
+.\" -----------------------------------------------------------------
+.\" * Define some portability stuff
+.\" -----------------------------------------------------------------
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.\" http://bugs.debian.org/507673
+.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.\" -----------------------------------------------------------------
+.\" * MAIN CONTENT STARTS HERE *
+.\" -----------------------------------------------------------------
+.SH "NAME"
+libnftables-json \- Supported JSON schema by libnftables
+.SH "SYNOPSIS"
+.sp
+\fB{ "nftables": [\fR \fIOBJECTS\fR \fB] }\fR
+.sp
+\fIOBJECTS\fR := \fILIST_OBJECTS\fR | \fICMD_OBJECTS\fR
+.sp
+\fILIST_OBJECTS\fR := \fILIST_OBJECT\fR [ \fB,\fR \fILIST_OBJECTS\fR ]
+.sp
+\fICMD_OBJECTS\fR := \fICMD_OBJECT\fR [ \fB,\fR \fICMD_OBJECTS\fR ]
+.sp
+\fICMD_OBJECT\fR := \fB{\fR \fICMD\fR\fB:\fR \fILIST_OBJECT\fR \fB}\fR | \fIMETAINFO_OBJECT\fR
+.sp
+\fICMD\fR := \fB"add"\fR | \fB"replace"\fR | \fB"create"\fR | \fB"insert"\fR | \fB"delete"\fR | \fB"list"\fR | \fB"reset"\fR | \fB"flush"\fR | \fB"rename"\fR
+.sp
+\fILIST_OBJECT\fR := \fITABLE\fR | \fICHAIN\fR | \fIRULE\fR | \fISET\fR | \fIMAP\fR | \fIELEMENT\fR | \fIFLOWTABLE\fR | \fICOUNTER\fR | \fIQUOTA\fR | \fICT_HELPER\fR | \fILIMIT\fR | \fIMETAINFO_OBJECT\fR | \fICT_TIMEOUT\fR | \fICT_EXPECTATION\fR
+.SH "DESCRIPTION"
+.sp
+libnftables supports JSON formatted input and output\&. This is implemented as an alternative frontend to the standard CLI syntax parser, therefore basic behaviour is identical and, for (almost) any operation available in standard syntax, there should be an equivalent one in JSON\&.
+.sp
+JSON input may be provided in a single string as parameter to \fBnft_run_cmd_from_buffer()\fR or in a file identified by the \fIfilename\fR parameter of the \fBnft_run_cmd_from_filename()\fR function\&.
+.sp
+JSON output has to be enabled via the \fBnft_ctx_output_set_json()\fR function, turning library standard output into JSON format\&. Error output remains unaffected\&.
+.SH "GLOBAL STRUCTURE"
+.sp
+In general, any JSON input or output is enclosed in an object with a single property named \fInftables\fR\&. Its value is an array containing commands (for input) or ruleset elements (for output)\&.
+.sp
+A command is an object with a single property whose name identifies the command\&. Its value is a ruleset element \- basically identical to output elements, apart from certain properties which may be interpreted differently or are required when output generally omits them\&.
+.SH "METAINFO OBJECT"
+.sp
+In output, the first object in an \fBnftables\fR array is a special one containing library information\&. Its content is as follows:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "metainfo": {
+ "version":\fR \fISTRING\fR\fB,
+ "release_name":\fR \fISTRING\fR\fB,
+ "json_schema_version":\fR \fINUMBER\fR
+\fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The values of \fBversion\fR and \fBrelease_name\fR properties are equal to the package version and release name as printed by \fBnft \-v\fR\&. The value of the \fBjson_schema_version\fR property is an integer indicating the schema version\&.
+.sp
+If supplied in library input, the parser will verify the \fBjson_schema_version\fR value to not exceed the internally hardcoded one (to make sure the given schema is fully understood)\&. In future, a lower number than the internal one may activate compatibility mode to parse outdated and incompatible JSON input\&.
+.SH "COMMAND OBJECTS"
+.sp
+The structure accepts an arbitrary amount of commands which are interpreted in order of appearance\&. For instance, the following standard syntax input:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+flush ruleset
+add table inet mytable
+add chain inet mytable mychain
+add rule inet mytable mychain tcp dport 22 accept
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+translates into JSON as such:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+{ "nftables": [
+ { "flush": { "ruleset": null }},
+ { "add": { "table": {
+ "family": "inet",
+ "name": "mytable"
+ }}},
+ { "add": { "chain": {
+ "family": "inet",
+ "table": "mytable",
+ "name": "mychain"
+ }}},
+ { "add": { "rule": {
+ "family": "inet",
+ "table": "mytable",
+ "chain": "mychain",
+ "expr": [
+ { "match": {
+ "op": "==",
+ "left": { "payload": {
+ "protocol": "tcp",
+ "field": "dport"
+ }},
+ "right": 22
+ }},
+ { "accept": null }
+ ]
+ }}}
+]}
+.fi
+.if n \{\
+.RE
+.\}
+.SS "ADD"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "add":\fR \fIADD_OBJECT\fR \fB}\fR
+
+\fIADD_OBJECT\fR := \fITABLE\fR | \fICHAIN\fR | \fIRULE\fR | \fISET\fR | \fIMAP\fR | \fIELEMENT\fR |
+ \fIFLOWTABLE\fR | \fICOUNTER\fR | \fIQUOTA\fR | \fICT_HELPER\fR | \fILIMIT\fR |
+ \fICT_TIMEOUT\fR | \fICT_EXPECTATION\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Add a new ruleset element to the kernel\&.
+.SS "REPLACE"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "replace":\fR \fIRULE\fR \fB}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Replace a rule\&. In \fIRULE\fR, the \fBhandle\fR property is mandatory and identifies the rule to be replaced\&.
+.SS "CREATE"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "create":\fR \fIADD_OBJECT\fR \fB}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Identical to \fBadd\fR command, but returns an error if the object already exists\&.
+.SS "INSERT"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "insert":\fR \fIRULE\fR \fB}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This command is identical to \fBadd\fR for rules, but instead of appending the rule to the chain by default, it inserts at first position\&. If a \fBhandle\fR or \fBindex\fR property is given, the rule is inserted before the rule identified by those properties\&.
+.SS "DELETE"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "delete":\fR \fIADD_OBJECT\fR \fB}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Delete an object from the ruleset\&. Only the minimal number of properties required to uniquely identify an object is generally needed in \fIADD_OBJECT\fR\&. For most ruleset elements, this is \fBfamily\fR and \fBtable\fR plus either \fBhandle\fR or \fBname\fR (except rules since they don\(cqt have a name)\&.
+.SS "LIST"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "list":\fR \fILIST_OBJECT\fR \fB}\fR
+
+\fILIST_OBJECT\fR := \fITABLE\fR | \fITABLES\fR | \fICHAIN\fR | \fICHAINS\fR | \fISET\fR | \fISETS\fR |
+ \fIMAP\fR | \fIMAPS | COUNTER\fR | \fICOUNTERS\fR | \fIQUOTA\fR | \fIQUOTAS\fR |
+ \fICT_HELPER\fR | \fICT_HELPERS\fR | \fILIMIT\fR | \fILIMITS\fR | \fIRULESET\fR |
+ \fIMETER\fR | \fIMETERS\fR | \fIFLOWTABLE\fR | \fIFLOWTABLES\fR |
+ \fICT_TIMEOUT\fR | \fICT_EXPECTATION\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+List ruleset elements\&. The plural forms are used to list all objects of that kind, optionally filtered by \fBfamily\fR and for some, also \fBtable\fR\&.
+.SS "RESET"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "reset":\fR \fIRESET_OBJECT\fR \fB}\fR
+
+\fIRESET_OBJECT\fR := \fICOUNTER\fR | \fICOUNTERS\fR | \fIQUOTA\fR | \fIQUOTAS\fR | \fIRULE\fR | \fIRULES\fR | \fISET\fR | \fIMAP\fR | \fIELEMENT\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Reset state in suitable objects, i\&.e\&. zero their internal counter\&.
+.SS "FLUSH"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "flush":\fR \fIFLUSH_OBJECT\fR \fB}\fR
+
+\fIFLUSH_OBJECT\fR := \fITABLE\fR | \fICHAIN\fR | \fISET\fR | \fIMAP\fR | \fIMETER\fR | \fIRULESET\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Empty contents in given object, e\&.g\&. remove all chains from given \fBtable\fR or remove all elements from given \fBset\fR\&.
+.SS "RENAME"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "rename":\fR \fICHAIN\fR \fB}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Rename a chain\&. The new name is expected in a dedicated property named \fBnewname\fR\&.
+.SH "RULESET ELEMENTS"
+.SS "TABLE"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "table": {
+ "family":\fR \fISTRING\fR\fB,
+ "name":\fR \fISTRING\fR\fB,
+ "handle":\fR \fINUMBER\fR
+\fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This object describes a table\&.
+.PP
+\fBfamily\fR
+.RS 4
+The table\(cqs family, e\&.g\&.
+\fB"ip"\fR
+or
+\fB"ip6"\fR\&.
+.RE
+.PP
+\fBname\fR
+.RS 4
+The table\(cqs name\&.
+.RE
+.PP
+\fBhandle\fR
+.RS 4
+The table\(cqs handle\&. In input, it is used only in
+\fBdelete\fR
+command as alternative to
+\fBname\fR\&.
+.RE
+.SS "CHAIN"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "chain": {
+ "family":\fR \fISTRING\fR\fB,
+ "table":\fR \fISTRING\fR\fB,
+ "name":\fR \fISTRING\fR\fB,
+ "newname":\fR \fISTRING\fR\fB,
+ "handle":\fR \fINUMBER\fR\fB,
+ "type":\fR \fISTRING\fR\fB,
+ "hook":\fR \fISTRING\fR\fB,
+ "prio":\fR \fINUMBER\fR\fB,
+ "dev":\fR \fISTRING\fR\fB,
+ "policy":\fR \fISTRING\fR
+\fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This object describes a chain\&.
+.PP
+\fBfamily\fR
+.RS 4
+The table\(cqs family\&.
+.RE
+.PP
+\fBtable\fR
+.RS 4
+The table\(cqs name\&.
+.RE
+.PP
+\fBname\fR
+.RS 4
+The chain\(cqs name\&.
+.RE
+.PP
+\fBhandle\fR
+.RS 4
+The chain\(cqs handle\&. In input, it is used only in
+\fBdelete\fR
+command as alternative to
+\fBname\fR\&.
+.RE
+.PP
+\fBnewname\fR
+.RS 4
+A new name for the chain, only relevant in the
+\fBrename\fR
+command\&.
+.RE
+.sp
+The following properties are required for base chains:
+.PP
+\fBtype\fR
+.RS 4
+The chain\(cqs type\&.
+.RE
+.PP
+\fBhook\fR
+.RS 4
+The chain\(cqs hook\&.
+.RE
+.PP
+\fBprio\fR
+.RS 4
+The chain\(cqs priority\&.
+.RE
+.PP
+\fBdev\fR
+.RS 4
+The chain\(cqs bound interface (if in the netdev family)\&.
+.RE
+.PP
+\fBpolicy\fR
+.RS 4
+The chain\(cqs policy\&.
+.RE
+.SS "RULE"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "rule": {
+ "family":\fR \fISTRING\fR\fB,
+ "table":\fR \fISTRING\fR\fB,
+ "chain":\fR \fISTRING\fR\fB,
+ "expr": [\fR \fISTATEMENTS\fR \fB],
+ "handle":\fR \fINUMBER\fR\fB,
+ "index":\fR \fINUMBER\fR\fB,
+ "comment":\fR \fISTRING\fR
+\fB}}\fR
+
+\fISTATEMENTS\fR := \fISTATEMENT\fR [\fB,\fR \fISTATEMENTS\fR ]
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This object describes a rule\&. Basic building blocks of rules are statements\&. Each rule consists of at least one\&.
+.PP
+\fBfamily\fR
+.RS 4
+The table\(cqs family\&.
+.RE
+.PP
+\fBtable\fR
+.RS 4
+The table\(cqs name\&.
+.RE
+.PP
+\fBchain\fR
+.RS 4
+The chain\(cqs name\&.
+.RE
+.PP
+\fBexpr\fR
+.RS 4
+An array of statements this rule consists of\&. In input, it is used in
+\fBadd\fR/\fBinsert\fR/\fBreplace\fR
+commands only\&.
+.RE
+.PP
+\fBhandle\fR
+.RS 4
+The rule\(cqs handle\&. In
+\fBdelete\fR/\fBreplace\fR
+commands, it serves as an identifier of the rule to delete/replace\&. In
+\fBadd\fR/\fBinsert\fR
+commands, it serves as an identifier of an existing rule to append/prepend the rule to\&.
+.RE
+.PP
+\fBindex\fR
+.RS 4
+The rule\(cqs position for
+\fBadd\fR/\fBinsert\fR
+commands\&. It is used as an alternative to
+\fBhandle\fR
+then\&.
+.RE
+.PP
+\fBcomment\fR
+.RS 4
+Optional rule comment\&.
+.RE
+.SS "SET / MAP"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "set": {
+ "family":\fR \fISTRING\fR\fB,
+ "table":\fR \fISTRING\fR\fB,
+ "name":\fR \fISTRING\fR\fB,
+ "handle":\fR \fINUMBER\fR\fB,
+ "type":\fR \fISET_TYPE\fR\fB,
+ "policy":\fR \fISET_POLICY\fR\fB,
+ "flags": [\fR \fISET_FLAG_LIST\fR \fB],
+ "elem":\fR \fISET_ELEMENTS\fR\fB,
+ "timeout":\fR \fINUMBER\fR\fB,
+ "gc\-interval":\fR \fINUMBER\fR\fB,
+ "size":\fR \fINUMBER\fR
+\fB}}\fR
+
+\fB{ "map": {
+ "family":\fR \fISTRING\fR\fB,
+ "table":\fR \fISTRING\fR\fB,
+ "name":\fR \fISTRING\fR\fB,
+ "handle":\fR \fINUMBER\fR\fB,
+ "type":\fR \fISET_TYPE\fR\fB,
+ "map":\fR \fISTRING\fR\fB,
+ "policy":\fR \fISET_POLICY\fR\fB,
+ "flags": [\fR \fISET_FLAG_LIST\fR \fB],
+ "elem":\fR \fISET_ELEMENTS\fR\fB,
+ "timeout":\fR \fINUMBER\fR\fB,
+ "gc\-interval":\fR \fINUMBER\fR\fB,
+ "size":\fR \fINUMBER\fR
+\fB}}\fR
+
+\fISET_TYPE\fR := \fISTRING\fR | \fB[\fR \fISET_TYPE_LIST\fR \fB]\fR
+\fISET_TYPE_LIST\fR := \fISTRING\fR [\fB,\fR \fISET_TYPE_LIST\fR ]
+\fISET_POLICY\fR := \fB"performance"\fR | \fB"memory"\fR
+\fISET_FLAG_LIST\fR := \fISET_FLAG\fR [\fB,\fR \fISET_FLAG_LIST\fR ]
+\fISET_FLAG\fR := \fB"constant"\fR | \fB"interval"\fR | \fB"timeout"\fR
+\fISET_ELEMENTS\fR := \fIEXPRESSION\fR | \fB[\fR \fIEXPRESSION_LIST\fR \fB]\fR
+\fIEXPRESSION_LIST\fR := \fIEXPRESSION\fR [\fB,\fR \fIEXPRESSION_LIST\fR ]
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+These objects describe a named set or map\&. Maps are a special form of sets in that they translate a unique key to a value\&.
+.PP
+\fBfamily\fR
+.RS 4
+The table\(cqs family\&.
+.RE
+.PP
+\fBtable\fR
+.RS 4
+The table\(cqs name\&.
+.RE
+.PP
+\fBname\fR
+.RS 4
+The set\(cqs name\&.
+.RE
+.PP
+\fBhandle\fR
+.RS 4
+The set\(cqs handle\&. For input, it is used in the
+\fBdelete\fR
+command only\&.
+.RE
+.PP
+\fBtype\fR
+.RS 4
+The set\(cqs datatype, see below\&.
+.RE
+.PP
+\fBmap\fR
+.RS 4
+Type of values this set maps to (i\&.e\&. this set is a map)\&.
+.RE
+.PP
+\fBpolicy\fR
+.RS 4
+The set\(cqs policy\&.
+.RE
+.PP
+\fBflags\fR
+.RS 4
+The set\(cqs flags\&.
+.RE
+.PP
+\fBelem\fR
+.RS 4
+Initial set element(s), see below\&.
+.RE
+.PP
+\fBtimeout\fR
+.RS 4
+Element timeout in seconds\&.
+.RE
+.PP
+\fBgc\-interval\fR
+.RS 4
+Garbage collector interval in seconds\&.
+.RE
+.PP
+\fBsize\fR
+.RS 4
+Maximum number of elements supported\&.
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.ps +1
+\fBTYPE\fR
+.RS 4
+.sp
+The set type might be a string, such as \fB"ipv4_addr"\fR or an array consisting of strings (for concatenated types)\&.
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.ps +1
+\fBELEM\fR
+.RS 4
+.sp
+A single set element might be given as string, integer or boolean value for simple cases\&. If additional properties are required, a formal \fBelem\fR object may be used\&.
+.sp
+Multiple elements may be given in an array\&.
+.RE
+.SS "ELEMENT"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "element": {
+ "family":\fR \fISTRING\fR\fB,
+ "table":\fR \fISTRING\fR\fB,
+ "name":\fR \fISTRING\fR\fB,
+ "elem":\fR \fISET_ELEM\fR
+\fB}}\fR
+
+\fISET_ELEM\fR := \fIEXPRESSION\fR | \fB[\fR \fIEXPRESSION_LIST\fR \fB]\fR
+\fIEXPRESSION_LIST\fR := \fIEXPRESSION\fR [\fB,\fR \fIEXPRESSION\fR ]
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Manipulate element(s) in a named set\&.
+.PP
+\fBfamily\fR
+.RS 4
+The table\(cqs family\&.
+.RE
+.PP
+\fBtable\fR
+.RS 4
+The table\(cqs name\&.
+.RE
+.PP
+\fBname\fR
+.RS 4
+The set\(cqs name\&.
+.RE
+.PP
+\fBelem\fR
+.RS 4
+See elem property of set object\&.
+.RE
+.SS "FLOWTABLE"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "flowtable": {
+ "family":\fR \fISTRING\fR\fB,
+ "table":\fR \fISTRING\fR\fB,
+ "name":\fR \fISTRING\fR\fB,
+ "handle":\fR \fINUMBER\fR\fB,
+ "hook":\fR \fISTRING\fR\fB,
+ "prio":\fR \fINUMBER\fR\fB,
+ "dev":\fR \fIFT_INTERFACE\fR
+\fB}}\fR
+
+\fIFT_INTERFACE\fR := \fISTRING\fR | \fB[\fR \fIFT_INTERFACE_LIST\fR \fB]\fR
+\fIFT_INTERFACE_LIST\fR := \fISTRING\fR [\fB,\fR \fISTRING\fR ]
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This object represents a named flowtable\&.
+.PP
+\fBfamily\fR
+.RS 4
+The table\(cqs family\&.
+.RE
+.PP
+\fBtable\fR
+.RS 4
+The table\(cqs name\&.
+.RE
+.PP
+\fBname\fR
+.RS 4
+The flow table\(cqs name\&.
+.RE
+.PP
+\fBhandle\fR
+.RS 4
+The flow table\(cqs handle\&. In input, it is used by the
+\fBdelete\fR
+command only\&.
+.RE
+.PP
+\fBhook\fR
+.RS 4
+The flow table\(cqs hook\&.
+.RE
+.PP
+\fBprio\fR
+.RS 4
+The flow table\(cqs priority\&.
+.RE
+.PP
+\fBdev\fR
+.RS 4
+The flow table\(cqs interface(s)\&.
+.RE
+.SS "COUNTER"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "counter": {
+ "family":\fR \fISTRING\fR\fB,
+ "table":\fR \fISTRING\fR\fB,
+ "name":\fR \fISTRING\fR\fB,
+ "handle":\fR \fINUMBER\fR\fB,
+ "packets":\fR \fINUMBER\fR\fB,
+ "bytes":\fR \fINUMBER\fR
+\fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This object represents a named counter\&.
+.PP
+\fBfamily\fR
+.RS 4
+The table\(cqs family\&.
+.RE
+.PP
+\fBtable\fR
+.RS 4
+The table\(cqs name\&.
+.RE
+.PP
+\fBname\fR
+.RS 4
+The counter\(cqs name\&.
+.RE
+.PP
+\fBhandle\fR
+.RS 4
+The counter\(cqs handle\&. In input, it is used by the
+\fBdelete\fR
+command only\&.
+.RE
+.PP
+\fBpackets\fR
+.RS 4
+Packet counter value\&.
+.RE
+.PP
+\fBbytes\fR
+.RS 4
+Byte counter value\&.
+.RE
+.SS "QUOTA"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "quota": {
+ "family":\fR \fISTRING\fR\fB,
+ "table":\fR \fISTRING\fR\fB,
+ "name":\fR \fISTRING\fR\fB,
+ "handle":\fR \fINUMBER\fR\fB,
+ "bytes":\fR \fINUMBER\fR\fB,
+ "used":\fR \fINUMBER\fR\fB,
+ "inv":\fR \fIBOOLEAN\fR
+\fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This object represents a named quota\&.
+.PP
+\fBfamily\fR
+.RS 4
+The table\(cqs family\&.
+.RE
+.PP
+\fBtable\fR
+.RS 4
+The table\(cqs name\&.
+.RE
+.PP
+\fBname\fR
+.RS 4
+The quota\(cqs name\&.
+.RE
+.PP
+\fBhandle\fR
+.RS 4
+The quota\(cqs handle\&. In input, it is used by the
+\fBdelete\fR
+command only\&.
+.RE
+.PP
+\fBbytes\fR
+.RS 4
+Quota threshold\&.
+.RE
+.PP
+\fBused\fR
+.RS 4
+Quota used so far\&.
+.RE
+.PP
+\fBinv\fR
+.RS 4
+If true, match if the quota has been exceeded\&.
+.RE
+.SS "CT HELPER"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "ct helper": {
+ "family":\fR \fISTRING\fR\fB,
+ "table":\fR \fISTRING\fR\fB,
+ "name":\fR \fISTRING\fR\fB,
+ "handle":\fR \fI\&... \*(Aq\fR\fI\fB,
+ "type":\fR\fR\fI \*(AqSTRING\fR\fB,
+ "protocol":\fR \fICTH_PROTO\fR\fB,
+ "l3proto":\fR \fISTRING\fR
+\fB}}\fR
+
+\fICTH_PROTO\fR := \fB"tcp"\fR | \fB"udp"\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This object represents a named conntrack helper\&.
+.PP
+\fBfamily\fR
+.RS 4
+The table\(cqs family\&.
+.RE
+.PP
+\fBtable\fR
+.RS 4
+The table\(cqs name\&.
+.RE
+.PP
+\fBname\fR
+.RS 4
+The ct helper\(cqs name\&.
+.RE
+.PP
+\fBhandle\fR
+.RS 4
+The ct helper\(cqs handle\&. In input, it is used by the
+\fBdelete\fR
+command only\&.
+.RE
+.PP
+\fBtype\fR
+.RS 4
+The ct helper type name, e\&.g\&.
+\fB"ftp"\fR
+or
+\fB"tftp"\fR\&.
+.RE
+.PP
+\fBprotocol\fR
+.RS 4
+The ct helper\(cqs layer 4 protocol\&.
+.RE
+.PP
+\fBl3proto\fR
+.RS 4
+The ct helper\(cqs layer 3 protocol, e\&.g\&.
+\fB"ip"\fR
+or
+\fB"ip6"\fR\&.
+.RE
+.SS "LIMIT"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "limit": {
+ "family":\fR \fISTRING\fR\fB,
+ "table":\fR \fISTRING\fR\fB,
+ "name":\fR \fISTRING\fR\fB,
+ "handle":\fR \fINUMBER\fR\fB,
+ "rate":\fR \fINUMBER\fR\fB,
+ "per":\fR \fISTRING\fR\fB,
+ "burst":\fR \fINUMBER\fR\fB,
+ "unit":\fR \fILIMIT_UNIT\fR\fB,
+ "inv":\fR \fIBOOLEAN\fR
+\fB}}\fR
+
+\fILIMIT_UNIT\fR := \fB"packets"\fR | \fB"bytes"\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This object represents a named limit\&.
+.PP
+\fBfamily\fR
+.RS 4
+The table\(cqs family\&.
+.RE
+.PP
+\fBtable\fR
+.RS 4
+The table\(cqs name\&.
+.RE
+.PP
+\fBname\fR
+.RS 4
+The limit\(cqs name\&.
+.RE
+.PP
+\fBhandle\fR
+.RS 4
+The limit\(cqs handle\&. In input, it is used by the
+\fBdelete\fR
+command only\&.
+.RE
+.PP
+\fBrate\fR
+.RS 4
+The limit\(cqs rate value\&.
+.RE
+.PP
+\fBper\fR
+.RS 4
+Time unit to apply the limit to, e\&.g\&.
+\fB"week"\fR,
+\fB"day"\fR,
+\fB"hour"\fR, etc\&. If omitted, defaults to
+\fB"second"\fR\&.
+.RE
+.PP
+\fBburst\fR
+.RS 4
+The limit\(cqs burst value\&. If omitted, defaults to
+\fB0\fR\&.
+.RE
+.PP
+\fBunit\fR
+.RS 4
+Unit of rate and burst values\&. If omitted, defaults to
+\fB"packets"\fR\&.
+.RE
+.PP
+\fBinv\fR
+.RS 4
+If true, match if limit was exceeded\&. If omitted, defaults to
+\fBfalse\fR\&.
+.RE
+.SS "CT TIMEOUT"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "ct timeout": {
+ "family":\fR \fISTRING\fR\fB,
+ "table":\fR \fISTRING\fR\fB,
+ "name":\fR \fISTRING\fR\fB,
+ "handle":\fR \fINUMBER\fR\fB,
+ "protocol":\fR \fICTH_PROTO\fR\fB,
+ "state":\fR \fISTRING\fR\fB,
+ "value:\fR \fINUMBER\fR\fB,
+ "l3proto":\fR \fISTRING\fR
+\fB}}\fR
+
+\fICTH_PROTO\fR := \fB"tcp"\fR | \fB"udp"\fR | \fB"dccp"\fR | \fB"sctp"\fR | \fB"gre"\fR | \fB"icmpv6"\fR | \fB"icmp"\fR | \fB"generic"\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This object represents a named conntrack timeout policy\&.
+.PP
+\fBfamily\fR
+.RS 4
+The table\(cqs family\&.
+.RE
+.PP
+\fBtable\fR
+.RS 4
+The table\(cqs name\&.
+.RE
+.PP
+\fBname\fR
+.RS 4
+The ct timeout object\(cqs name\&.
+.RE
+.PP
+\fBhandle\fR
+.RS 4
+The ct timeout object\(cqs handle\&. In input, it is used by
+\fBdelete\fR
+command only\&.
+.RE
+.PP
+\fBprotocol\fR
+.RS 4
+The ct timeout object\(cqs layer 4 protocol\&.
+.RE
+.PP
+\fBstate\fR
+.RS 4
+The connection state name, e\&.g\&.
+\fB"established"\fR,
+\fB"syn_sent"\fR,
+\fB"close"\fR
+or
+\fB"close_wait"\fR, for which the timeout value has to be updated\&.
+.RE
+.PP
+\fBvalue\fR
+.RS 4
+The updated timeout value for the specified connection state\&.
+.RE
+.PP
+\fBl3proto\fR
+.RS 4
+The ct timeout object\(cqs layer 3 protocol, e\&.g\&.
+\fB"ip"\fR
+or
+\fB"ip6"\fR\&.
+.RE
+.SS "CT EXPECTATION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "ct expectation": {
+ "family":\fR \fISTRING\fR\fB,
+ "table":\fR \fISTRING\fR\fB,
+ "name":\fR \fISTRING\fR\fB,
+ "handle":\fR \fINUMBER\fR\fB,
+ "l3proto":\fR \fISTRING\fR
+ "protocol":* \fICTH_PROTO\fR\fB,
+ "dport":\fR \fINUMBER\fR\fB,
+ "timeout:\fR \fINUMBER\fR\fB,
+ "size:\fR \fINUMBER\fR\fB,
+*}}\fR
+
+\fICTH_PROTO\fR := \fB"tcp"\fR | \fB"udp"\fR | \fB"dccp"\fR | \fB"sctp"\fR | \fB"gre"\fR | \fB"icmpv6"\fR | \fB"icmp"\fR | \fB"generic"\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This object represents a named conntrack expectation\&.
+.PP
+\fBfamily\fR
+.RS 4
+The table\(cqs family\&.
+.RE
+.PP
+\fBtable\fR
+.RS 4
+The table\(cqs name\&.
+.RE
+.PP
+\fBname\fR
+.RS 4
+The ct expectation object\(cqs name\&.
+.RE
+.PP
+\fBhandle\fR
+.RS 4
+The ct expectation object\(cqs handle\&. In input, it is used by
+\fBdelete\fR
+command only\&.
+.RE
+.PP
+\fBl3proto\fR
+.RS 4
+The ct expectation object\(cqs layer 3 protocol, e\&.g\&.
+\fB"ip"\fR
+or
+\fB"ip6"\fR\&.
+.RE
+.PP
+\fBprotocol\fR
+.RS 4
+The ct expectation object\(cqs layer 4 protocol\&.
+.RE
+.PP
+\fBdport\fR
+.RS 4
+The destination port of the expected connection\&.
+.RE
+.PP
+\fBtimeout\fR
+.RS 4
+The time in millisecond that this expectation will live\&.
+.RE
+.PP
+\fBsize\fR
+.RS 4
+The maximum count of expectations to be living in the same time\&.
+.RE
+.SH "STATEMENTS"
+.sp
+Statements are the building blocks for rules\&. Each rule consists of at least one\&.
+.SS "VERDICT"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "accept": null }\fR
+\fB{ "drop": null }\fR
+\fB{ "continue": null }\fR
+\fB{ "return": null }\fR
+\fB{ "jump": { "target": * \fR\fB\fISTRING\fR\fR\fB *}}\fR
+\fB{ "goto": { "target": * \fR\fB\fISTRING\fR\fR\fB *}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+A verdict either terminates packet traversal through the current chain or delegates to a different one\&.
+.sp
+\fBjump\fR and \fBgoto\fR statements expect a target chain name\&.
+.SS "MATCH"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "match": {
+ "left":\fR \fIEXPRESSION\fR\fB,
+ "right":\fR \fIEXPRESSION\fR\fB,
+ "op":\fR \fISTRING\fR
+\fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This matches the expression on left hand side (typically a packet header or packet meta info) with the expression on right hand side (typically a constant value)\&. If the statement evaluates to true, the next statement in this rule is considered\&. If not, processing continues with the next rule in the same chain\&.
+.PP
+\fBleft\fR
+.RS 4
+Left hand side of this match\&.
+.RE
+.PP
+\fBright\fR
+.RS 4
+Right hand side of this match\&.
+.RE
+.PP
+\fBop\fR
+.RS 4
+Operator indicating the type of comparison\&.
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.ps +1
+\fBOPERATORS\fR
+.RS 4
+.TS
+tab(:);
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+\fB&\fR
+T}:T{
+.sp
+Binary AND
+T}
+T{
+.sp
+\fB|\fR
+T}:T{
+.sp
+Binary OR
+T}
+T{
+.sp
+\fB^\fR
+T}:T{
+.sp
+Binary XOR
+T}
+T{
+.sp
+\fB<<\fR
+T}:T{
+.sp
+Left shift
+T}
+T{
+.sp
+\fB>>\fR
+T}:T{
+.sp
+Right shift
+T}
+T{
+.sp
+\fB==\fR
+T}:T{
+.sp
+Equal
+T}
+T{
+.sp
+\fB!=\fR
+T}:T{
+.sp
+Not equal
+T}
+T{
+.sp
+\fB<\fR
+T}:T{
+.sp
+Less than
+T}
+T{
+.sp
+\fB>\fR
+T}:T{
+.sp
+Greater than
+T}
+T{
+.sp
+\fB⇐\fR
+T}:T{
+.sp
+Less than or equal to
+T}
+T{
+.sp
+\fB>=\fR
+T}:T{
+.sp
+Greater than or equal to
+T}
+T{
+.sp
+\fBin\fR
+T}:T{
+.sp
+Perform a lookup, i\&.e\&. test if bits on RHS are contained in LHS value
+T}
+.TE
+.sp 1
+.sp
+Unlike with the standard API, the operator is mandatory here\&. In the standard API, a missing operator may be resolved in two ways, depending on the type of expression on the RHS:
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+If the RHS is a bitmask or a list of bitmasks, the expression resolves into a binary operation with the inequality operator, like this:
+\fILHS & RHS != 0\fR\&.
+.RE
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+In any other case, the equality operator is simply inserted\&.
+.RE
+.sp
+For the non\-trivial first case, the JSON API supports the \fBin\fR operator\&.
+.RE
+.SS "COUNTER"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "counter": {
+ "packets":\fR \fINUMBER\fR\fB,
+ "bytes":\fR \fINUMBER\fR
+\fB}}\fR
+
+\fB{ "counter":\fR \fISTRING\fR \fB}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This object represents a byte/packet counter\&. In input, no properties are required\&. If given, they act as initial values for the counter\&.
+.sp
+The first form creates an anonymous counter which lives in the rule it appears in\&. The second form specifies a reference to a named counter object\&.
+.PP
+\fBpackets\fR
+.RS 4
+Packets counted\&.
+.RE
+.PP
+\fBbytes\fR
+.RS 4
+Bytes counted\&.
+.RE
+.SS "MANGLE"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "mangle": {
+ "key":\fR \fIEXPRESSION\fR\fB,
+ "value":\fR \fIEXPRESSION\fR
+\fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This changes the packet data or meta info\&.
+.PP
+\fBkey\fR
+.RS 4
+The packet data to be changed, given as an
+\fBexthdr\fR,
+\fBpayload\fR,
+\fBmeta\fR,
+\fBct\fR
+or
+\fBct helper\fR
+expression\&.
+.RE
+.PP
+\fBvalue\fR
+.RS 4
+Value to change data to\&.
+.RE
+.SS "QUOTA"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "quota": {
+ "val":\fR \fINUMBER\fR\fB,
+ "val_unit":\fR \fISTRING\fR\fB,
+ "used":\fR \fINUMBER\fR\fB,
+ "used_unit":\fR \fISTRING\fR\fB,
+ "inv":\fR \fIBOOLEAN\fR
+\fB}}\fR
+
+\fB{ "quota":\fR \fISTRING\fR \fB}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The first form creates an anonymous quota which lives in the rule it appears in\&. The second form specifies a reference to a named quota object\&.
+.PP
+\fBval\fR
+.RS 4
+Quota value\&.
+.RE
+.PP
+\fBval_unit\fR
+.RS 4
+Unit of
+\fBval\fR, e\&.g\&.
+\fB"kbytes"\fR
+or
+\fB"mbytes"\fR\&. If omitted, defaults to
+\fB"bytes"\fR\&.
+.RE
+.PP
+\fBused\fR
+.RS 4
+Quota used so far\&. Optional on input\&. If given, serves as initial value\&.
+.RE
+.PP
+\fBused_unit\fR
+.RS 4
+Unit of
+\fBused\fR\&. Defaults to
+\fB"bytes"\fR\&.
+.RE
+.PP
+\fBinv\fR
+.RS 4
+If
+\fBtrue\fR, will match if quota was exceeded\&. Defaults to
+\fBfalse\fR\&.
+.RE
+.SS "LIMIT"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "limit": {
+ "rate":\fR \fINUMBER\fR\fB,
+ "rate_unit":\fR \fISTRING\fR\fB,
+ "per":\fR \fISTRING\fR\fB,
+ "burst":\fR \fINUMBER\fR\fB,
+ "burst_unit":\fR \fISTRING\fR\fB,
+ "inv":\fR \fIBOOLEAN\fR
+\fB}}\fR
+
+\fB{ "limit":\fR \fISTRING\fR \fB}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The first form creates an anonymous limit which lives in the rule it appears in\&. The second form specifies a reference to a named limit object\&.
+.PP
+\fBrate\fR
+.RS 4
+Rate value to limit to\&.
+.RE
+.PP
+\fBrate_unit\fR
+.RS 4
+Unit of
+\fBrate\fR, e\&.g\&.
+\fB"packets"\fR
+or
+\fB"mbytes"\fR\&. Defaults to
+\fB"packets"\fR\&.
+.RE
+.PP
+\fBper\fR
+.RS 4
+Denominator of
+\fBrate\fR, e\&.g\&.
+\fB"week"\fR
+or
+\fB"minutes"\fR\&.
+.RE
+.PP
+\fBburst\fR
+.RS 4
+Burst value\&. Defaults to
+\fB0\fR\&.
+.RE
+.PP
+\fBburst_unit\fR
+.RS 4
+Unit of
+\fBburst\fR, ignored if
+\fBrate_unit\fR
+is
+\fB"packets"\fR\&. Defaults to
+\fB"bytes"\fR\&.
+.RE
+.PP
+\fBinv\fR
+.RS 4
+If
+\fBtrue\fR, matches if the limit was exceeded\&. Defaults to
+\fBfalse\fR\&.
+.RE
+.SS "FWD"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "fwd": {
+ "dev":\fR \fIEXPRESSION\fR\fB,
+ "family":\fR \fIFWD_FAMILY\fR\fB,
+ "addr":\fR \fIEXPRESSION\fR
+\fB}}\fR
+
+\fIFWD_FAMILY\fR := \fB"ip"\fR | \fB"ip6"\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Forward a packet to a different destination\&.
+.PP
+\fBdev\fR
+.RS 4
+Interface to forward the packet on\&.
+.RE
+.PP
+\fBfamily\fR
+.RS 4
+Family of
+\fBaddr\fR\&.
+.RE
+.PP
+\fBaddr\fR
+.RS 4
+IP(v6) address to forward the packet to\&.
+.RE
+.sp
+Both \fBfamily\fR and \fBaddr\fR are optional, but if at least one is given, both must be present\&.
+.SS "NOTRACK"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "notrack": null }\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Disable connection tracking for the packet\&.
+.SS "DUP"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "dup": {
+ "addr":\fR \fIEXPRESSION\fR\fB,
+ "dev":\fR \fIEXPRESSION\fR
+\fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Duplicate a packet to a different destination\&.
+.PP
+\fBaddr\fR
+.RS 4
+Address to duplicate packet to\&.
+.RE
+.PP
+\fBdev\fR
+.RS 4
+Interface to duplicate packet on\&. May be omitted to not specify an interface explicitly\&.
+.RE
+.SS "NETWORK ADDRESS TRANSLATION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "snat": {
+ "addr":\fR \fIEXPRESSION\fR\fB,
+ "family":\fR \fISTRING\fR\fB,
+ "port":\fR \fIEXPRESSION\fR\fB,
+ "flags":\fR \fIFLAGS\fR
+\fB}}\fR
+
+\fB{ "dnat": {
+ "addr":\fR \fIEXPRESSION\fR\fB,
+ "family":\fR \fISTRING\fR\fB,
+ "port":\fR \fIEXPRESSION\fR\fB,
+ "flags":\fR \fIFLAGS\fR
+\fB}}\fR
+
+\fB{ "masquerade": {
+ "port":\fR \fIEXPRESSION\fR\fB,
+ "flags":\fR \fIFLAGS\fR
+\fB}}\fR
+
+\fB{ "redirect": {
+ "port":\fR \fIEXPRESSION\fR\fB,
+ "flags":\fR \fIFLAGS\fR
+\fB}}\fR
+
+\fIFLAGS\fR := \fIFLAG\fR | \fB[\fR \fIFLAG_LIST\fR \fB]\fR
+\fIFLAG_LIST\fR := \fIFLAG\fR [\fB,\fR \fIFLAG_LIST\fR ]
+\fIFLAG\fR := \fB"random"\fR | \fB"fully\-random"\fR | \fB"persistent"\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Perform Network Address Translation\&.
+.PP
+\fBaddr\fR
+.RS 4
+Address to translate to\&.
+.RE
+.PP
+\fBfamily\fR
+.RS 4
+Family of
+\fBaddr\fR, either
+\fBip\fR
+or
+\fBip6\fR\&. Required in
+\fBinet\fR
+table family\&.
+.RE
+.PP
+\fBport\fR
+.RS 4
+Port to translate to\&.
+.RE
+.PP
+\fBflags\fR
+.RS 4
+Flag(s)\&.
+.RE
+.sp
+All properties are optional and default to none\&.
+.SS "REJECT"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "reject": {
+ "type":\fR \fISTRING\fR\fB,
+ "expr":\fR \fIEXPRESSION\fR
+\fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Reject the packet and send the given error reply\&.
+.PP
+\fBtype\fR
+.RS 4
+Type of reject, either
+\fB"tcp reset"\fR,
+\fB"icmpx"\fR,
+\fB"icmp"\fR
+or
+\fB"icmpv6"\fR\&.
+.RE
+.PP
+\fBexpr\fR
+.RS 4
+ICMP code to reject with\&.
+.RE
+.sp
+All properties are optional\&.
+.SS "SET"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "set": {
+ "op":\fR \fISTRING\fR\fB,
+ "elem":\fR \fIEXPRESSION\fR\fB,
+ "set":\fR \fISTRING\fR
+\fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Dynamically add/update elements to a set\&.
+.PP
+\fBop\fR
+.RS 4
+Operator on set, either
+\fB"add"\fR
+or
+\fB"update"\fR\&.
+.RE
+.PP
+\fBelem\fR
+.RS 4
+Set element to add or update\&.
+.RE
+.PP
+\fBset\fR
+.RS 4
+Set reference\&.
+.RE
+.SS "LOG"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "log": {
+ "prefix":\fR \fISTRING\fR\fB,
+ "group":\fR \fINUMBER\fR\fB,
+ "snaplen":\fR \fINUMBER\fR\fB,
+ "queue\-threshold":\fR \fINUMBER\fR\fB,
+ "level":\fR \fILEVEL\fR\fB,
+ "flags":\fR \fIFLAGS\fR
+\fB}}\fR
+
+\fILEVEL\fR := \fB"emerg"\fR | \fB"alert"\fR | \fB"crit"\fR | \fB"err"\fR | \fB"warn"\fR | \fB"notice"\fR |
+ \fB"info"\fR | \fB"debug"\fR | \fB"audit"\fR
+
+\fIFLAGS\fR := \fIFLAG\fR | \fB[\fR \fIFLAG_LIST\fR \fB]\fR
+\fIFLAG_LIST\fR := \fIFLAG\fR [\fB,\fR \fIFLAG_LIST\fR ]
+\fIFLAG\fR := \fB"tcp sequence"\fR | \fB"tcp options"\fR | \fB"ip options"\fR | \fB"skuid"\fR |
+ \fB"ether"\fR | \fB"all"\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Log the packet\&.
+.PP
+\fBprefix\fR
+.RS 4
+Prefix for log entries\&.
+.RE
+.PP
+\fBgroup\fR
+.RS 4
+Log group\&.
+.RE
+.PP
+\fBsnaplen\fR
+.RS 4
+Snaplen for logging\&.
+.RE
+.PP
+\fBqueue\-threshold\fR
+.RS 4
+Queue threshold\&.
+.RE
+.PP
+\fBlevel\fR
+.RS 4
+Log level\&. Defaults to
+\fB"warn"\fR\&.
+.RE
+.PP
+\fBflags\fR
+.RS 4
+Log flags\&.
+.RE
+.sp
+All properties are optional\&.
+.SS "CT HELPER"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "ct helper":\fR \fIEXPRESSION\fR \fB}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Enable the specified conntrack helper for this packet\&.
+.PP
+\fBct helper\fR
+.RS 4
+CT helper reference\&.
+.RE
+.SS "METER"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "meter": {
+ "name":\fR \fISTRING\fR\fB,
+ "key":\fR \fIEXPRESSION\fR\fB,
+ "stmt":\fR \fISTATEMENT\fR
+\fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Apply a given statement using a meter\&.
+.PP
+\fBname\fR
+.RS 4
+Meter name\&.
+.RE
+.PP
+\fBkey\fR
+.RS 4
+Meter key\&.
+.RE
+.PP
+\fBstmt\fR
+.RS 4
+Meter statement\&.
+.RE
+.SS "QUEUE"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "queue": {
+ "num":\fR \fIEXPRESSION\fR\fB,
+ "flags":\fR \fIFLAGS\fR
+\fB}}\fR
+
+\fIFLAGS\fR := \fIFLAG\fR | \fB[\fR \fIFLAG_LIST\fR \fB]\fR
+\fIFLAG_LIST\fR := \fIFLAG\fR [\fB,\fR \fIFLAG_LIST\fR ]
+\fIFLAG\fR := \fB"bypass"\fR | \fB"fanout"\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Queue the packet to userspace\&.
+.PP
+\fBnum\fR
+.RS 4
+Queue number\&.
+.RE
+.PP
+\fBflags\fR
+.RS 4
+Queue flags\&.
+.RE
+.SS "VERDICT MAP"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "vmap": {
+ "key":\fR \fIEXPRESSION\fR\fB,
+ "data":\fR \fIEXPRESSION\fR
+\fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Apply a verdict conditionally\&.
+.PP
+\fBkey\fR
+.RS 4
+Map key\&.
+.RE
+.PP
+\fBdata\fR
+.RS 4
+Mapping expression consisting of value/verdict pairs\&.
+.RE
+.SS "CT COUNT"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "ct count": {
+ "val":\fR \fINUMBER\fR\fB,
+ "inv":\fR \fIBOOLEAN\fR
+\fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Limit the number of connections using conntrack\&.
+.PP
+\fBval\fR
+.RS 4
+Connection count threshold\&.
+.RE
+.PP
+\fBinv\fR
+.RS 4
+If
+\fBtrue\fR, match if
+\fBval\fR
+was exceeded\&. If omitted, defaults to
+\fBfalse\fR\&.
+.RE
+.SS "CT TIMEOUT"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "ct timeout":\fR \fIEXPRESSION\fR \fB}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Assign connection tracking timeout policy\&.
+.PP
+\fBct timeout\fR
+.RS 4
+CT timeout reference\&.
+.RE
+.SS "CT EXPECTATION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "ct expectation":\fR \fIEXPRESSION\fR \fB}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Assign connection tracking expectation\&.
+.PP
+\fBct expectation\fR
+.RS 4
+CT expectation reference\&.
+.RE
+.SS "XT"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "xt": {
+ "type":\fR \fITYPENAME\fR\fB,
+ "name":\fR \fISTRING\fR
+\fB}}\fR
+
+\fITYPENAME\fR := \fBmatch\fR | \fBtarget\fR | \fBwatcher\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This represents an xt statement from xtables compat interface\&. It is a fallback if translation is not available or not complete\&.
+.sp
+Seeing this means the ruleset (or parts of it) were created by \fBiptables\-nft\fR and one should use that to manage it\&.
+.sp
+\fBBEWARE:\fR nftables won\(cqt restore these statements\&.
+.SH "EXPRESSIONS"
+.sp
+Expressions are the building blocks of (most) statements\&. In their most basic form, they are just immediate values represented as a JSON string, integer or boolean type\&.
+.SS "IMMEDIATES"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fISTRING\fR
+\fINUMBER\fR
+\fIBOOLEAN\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Immediate expressions are typically used for constant values\&. For strings, there are two special cases:
+.PP
+\fB@STRING\fR
+.RS 4
+The remaining part is taken as set name to create a set reference\&.
+.RE
+.PP
+\fB\e\fR*
+.RS 4
+Construct a wildcard expression\&.
+.RE
+.SS "LISTS"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fIARRAY\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+List expressions are constructed by plain arrays containing of an arbitrary number of expressions\&.
+.SS "CONCAT"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "concat":\fR \fICONCAT\fR \fB}\fR
+
+\fICONCAT\fR := \fB[\fR \fIEXPRESSION_LIST\fR \fB]\fR
+\fIEXPRESSION_LIST\fR := \fIEXPRESSION\fR [\fB,\fR \fIEXPRESSION_LIST\fR ]
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Concatenate several expressions\&.
+.SS "SET"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "set":\fR \fISET\fR \fB}\fR
+
+\fISET\fR := \fIEXPRESSION\fR | \fB[\fR \fIEXPRESSION_LIST\fR \fB]\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This object constructs an anonymous set\&. For mappings, an array of arrays with exactly two elements is expected\&.
+.SS "MAP"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "map": {
+ "key":\fR \fIEXPRESSION\fR\fB,
+ "data":\fR \fIEXPRESSION\fR
+\fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Map a key to a value\&.
+.PP
+\fBkey\fR
+.RS 4
+Map key\&.
+.RE
+.PP
+\fBdata\fR
+.RS 4
+Mapping expression consisting of value/target pairs\&.
+.RE
+.SS "PREFIX"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "prefix": {
+ "addr":\fR \fIEXPRESSION\fR\fB,
+ "len":\fR \fINUMBER\fR
+\fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Construct an IPv4 or IPv6 prefix consisting of address part in \fBaddr\fR and prefix length in \fBlen\fR\&.
+.SS "RANGE"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "range": [\fR \fIEXPRESSION\fR \fB,\fR \fIEXPRESSION\fR \fB] }\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Construct a range of values\&. The first array item denotes the lower boundary, the second one the upper boundary\&.
+.SS "PAYLOAD"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "payload": {
+ "base":\fR \fIBASE\fR\fB,
+ "offset":\fR \fINUMBER\fR\fB,
+ "len":\fR \fINUMBER\fR
+\fB}}\fR
+
+\fB{ "payload": {
+ "protocol":\fR \fISTRING\fR\fB,
+ "field":\fR \fISTRING\fR
+\fB}}\fR
+
+\fIBASE\fR := \fB"ll"\fR | \fB"nh"\fR | \fB"th"\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Construct a payload expression, i\&.e\&. a reference to a certain part of packet data\&. The first form creates a raw payload expression to point at a random number (\fBlen\fR) of bytes at a certain offset (\fBoffset\fR) from a given reference point (\fBbase\fR)\&. The following \fBbase\fR values are accepted:
+.PP
+\fB"ll"\fR
+.RS 4
+The offset is relative to Link Layer header start offset\&.
+.RE
+.PP
+\fB"nh"\fR
+.RS 4
+The offset is relative to Network Layer header start offset\&.
+.RE
+.PP
+\fB"th"\fR
+.RS 4
+The offset is relative to Transport Layer header start offset\&.
+.RE
+.sp
+The second form allows one to reference a field by name (\fBfield\fR) in a named packet header (\fBprotocol\fR)\&.
+.SS "EXTHDR"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "exthdr": {
+ "name":\fR \fISTRING\fR\fB,
+ "field":\fR \fISTRING\fR\fB,
+ "offset":\fR \fINUMBER\fR
+\fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Create a reference to a field (\fBfield\fR) in an IPv6 extension header (\fBname\fR)\&. \fBoffset\fR is used only for \fBrt0\fR protocol\&.
+.sp
+If the \fBfield\fR property is not given, the expression is to be used as a header existence check in a \fBmatch\fR statement with a boolean on the right hand side\&.
+.SS "TCP OPTION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "tcp option": {
+ "name":\fR \fISTRING\fR\fB,
+ "field":\fR \fISTRING\fR
+\fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Create a reference to a field (\fBfield\fR) of a TCP option header (\fBname\fR)\&.
+.sp
+If the \fBfield\fR property is not given, the expression is to be used as a TCP option existence check in a \fBmatch\fR statement with a boolean on the right hand side\&.
+.SS "SCTP CHUNK"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "sctp chunk": {
+ "name":\fR \fISTRING\fR\fB,
+ "field":\fR \fISTRING\fR
+\fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Create a reference to a field (\fBfield\fR) of an SCTP chunk (\fBname\fR)\&.
+.sp
+If the \fBfield\fR property is not given, the expression is to be used as an SCTP chunk existence check in a \fBmatch\fR statement with a boolean on the right hand side\&.
+.SS "DCCP OPTION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "dccp option": {
+ "type":\fR \fINUMBER\fR*
+\fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Create a reference to a DCCP option (\fBtype\fR)\&.
+.sp
+The expression is to be used as a DCCP option existence check in a \fBmatch\fR statement with a boolean on the right hand side\&.
+.SS "META"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "meta": {
+ "key":\fR \fIMETA_KEY\fR
+\fB}}\fR
+
+\fIMETA_KEY\fR := \fB"length"\fR | \fB"protocol"\fR | \fB"priority"\fR | \fB"random"\fR | \fB"mark"\fR |
+ \fB"iif"\fR | \fB"iifname"\fR | \fB"iiftype"\fR | \fB"oif"\fR | \fB"oifname"\fR |
+ \fB"oiftype"\fR | \fB"skuid"\fR | \fB"skgid"\fR | \fB"nftrace"\fR |
+ \fB"rtclassid"\fR | \fB"ibriport"\fR | \fB"obriport"\fR | \fB"ibridgename"\fR |
+ \fB"obridgename"\fR | \fB"pkttype"\fR | \fB"cpu"\fR | \fB"iifgroup"\fR |
+ \fB"oifgroup"\fR | \fB"cgroup"\fR | \fB"nfproto"\fR | \fB"l4proto"\fR |
+ \fB"secpath"\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Create a reference to packet meta data\&.
+.SS "RT"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "rt": {
+ "key":\fR \fIRT_KEY\fR\fB,
+ "family":\fR \fIRT_FAMILY\fR
+\fB}}\fR
+
+\fIRT_KEY\fR := \fB"classid"\fR | \fB"nexthop"\fR | \fB"mtu"\fR
+\fIRT_FAMILY\fR := \fB"ip"\fR | \fB"ip6"\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Create a reference to packet routing data\&.
+.sp
+The \fBfamily\fR property is optional and defaults to unspecified\&.
+.SS "CT"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "ct": {
+ "key":\fR \fISTRING\fR\fB,
+ "family":\fR \fICT_FAMILY\fR\fB,
+ "dir":\fR \fICT_DIRECTION\fR
+\fB}}\fR
+
+\fICT_FAMILY\fR := \fB"ip"\fR | \fB"ip6"\fR
+\fICT_DIRECTION\fR := \fB"original"\fR | \fB"reply"\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Create a reference to packet conntrack data\&.
+.sp
+Some CT keys do not support a direction\&. In this case, \fBdir\fR must not be given\&.
+.SS "NUMGEN"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "numgen": {
+ "mode":\fR \fING_MODE\fR\fB,
+ "mod":\fR \fINUMBER\fR\fB,
+ "offset":\fR \fINUMBER\fR
+\fB}}\fR
+
+\fING_MODE\fR := \fB"inc"\fR | \fB"random"\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Create a number generator\&.
+.sp
+The \fBoffset\fR property is optional and defaults to 0\&.
+.SS "HASH"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "jhash": {
+ "mod":\fR \fINUMBER\fR\fB,
+ "offset":\fR \fINUMBER\fR\fB,
+ "expr":\fR \fIEXPRESSION\fR\fB,
+ "seed":\fR \fINUMBER\fR
+\fB}}\fR
+
+\fB{ "symhash": {
+ "mod":\fR \fINUMBER\fR\fB,
+ "offset":\fR \fINUMBER\fR
+\fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Hash packet data\&.
+.sp
+The \fBoffset\fR and \fBseed\fR properties are optional and default to 0\&.
+.SS "FIB"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "fib": {
+ "result":\fR \fIFIB_RESULT\fR\fB,
+ "flags":\fR \fIFIB_FLAGS\fR
+\fB}}\fR
+
+\fIFIB_RESULT\fR := \fB"oif"\fR | \fB"oifname"\fR | \fB"type"\fR
+
+\fIFIB_FLAGS\fR := \fIFIB_FLAG\fR | \fB[\fR \fIFIB_FLAG_LIST\fR \fB]\fR
+\fIFIB_FLAG_LIST\fR := \fIFIB_FLAG\fR [\fB,\fR \fIFIB_FLAG_LIST\fR ]
+\fIFIB_FLAG\fR := \fB"saddr"\fR | \fB"daddr"\fR | \fB"mark"\fR | \fB"iif"\fR | \fB"oif"\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Perform kernel Forwarding Information Base lookups\&.
+.SS "BINARY OPERATION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "|": [\fR \fIEXPRESSION\fR\fB,\fR \fIEXPRESSION\fR \fB] }\fR
+\fB{ "^": [\fR \fIEXPRESSION\fR\fB,\fR \fIEXPRESSION\fR \fB] }\fR
+\fB{ "&": [\fR \fIEXPRESSION\fR\fB,\fR \fIEXPRESSION\fR \fB] }\fR
+\fB{ "\fR\fB<<\fR\fB": [\fR \fIEXPRESSION\fR\fB,\fR \fIEXPRESSION\fR \fB] }\fR
+\fB{ ">>": [\fR \fIEXPRESSION\fR\fB,\fR \fIEXPRESSION\fR \fB] }\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+All binary operations expect an array of exactly two expressions, of which the first element denotes the left hand side and the second one the right hand side\&.
+.SS "VERDICT"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "accept": null }\fR
+\fB{ "drop": null }\fR
+\fB{ "continue": null }\fR
+\fB{ "return": null }\fR
+\fB{ "jump": { "target":\fR \fISTRING\fR \fB}}\fR
+\fB{ "goto": { "target":\fR \fISTRING\fR \fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Same as the \fBverdict\fR statement, but for use in verdict maps\&.
+.sp
+\fBjump\fR and \fBgoto\fR verdicts expect a target chain name\&.
+.SS "ELEM"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "elem": {
+ "val":\fR \fIEXPRESSION\fR\fB,
+ "timeout":\fR \fINUMBER\fR\fB,
+ "expires":\fR \fINUMBER\fR\fB,
+ "comment":\fR \fISTRING\fR
+\fB}}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Explicitly set element object, in case \fBtimeout\fR, \fBexpires\fR or \fBcomment\fR are desired\&. Otherwise, it may be replaced by the value of \fBval\fR\&.
+.SS "SOCKET"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "socket": {
+ "key":\fR \fISOCKET_KEY\fR
+\fB}}\fR
+
+\fISOCKET_KEY\fR := \fB"transparent"\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Construct a reference to packet\(cqs socket\&.
+.SS "OSF"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB{ "osf": {
+ "key":\fR \fIOSF_KEY\fR\fB,
+ "ttl":\fR \fIOSF_TTL\fR
+\fB}}\fR
+
+\fIOSF_KEY\fR := \fB"name"\fR
+\fIOSF_TTL\fR := \fB"loose"\fR | \fB"skip"\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Perform OS fingerprinting\&. This expression is typically used in the LHS of a \fBmatch\fR statement\&.
+.PP
+\fBkey\fR
+.RS 4
+Which part of the fingerprint info to match against\&. At this point, only the OS name is supported\&.
+.RE
+.PP
+\fBttl\fR
+.RS 4
+Define how the packet\(cqs TTL value is to be matched\&. This property is optional\&. If omitted, the TTL value has to match exactly\&. A value of
+\fBloose\fR
+accepts TTL values less than the fingerprint one\&. A value of
+\fBskip\fR
+omits TTL value comparison entirely\&.
+.RE
+.SH "AUTHOR"
+.PP
+\fBPhil Sutter\fR <\&phil@nwl\&.cc\&>
+.RS 4
+Author.
+.RE
diff --git a/doc/libnftables-json.adoc b/doc/libnftables-json.adoc
new file mode 100644
index 0000000..3e6e1db
--- /dev/null
+++ b/doc/libnftables-json.adoc
@@ -0,0 +1,1416 @@
+libnftables-json(5)
+===================
+Phil Sutter <phil@nwl.cc>
+:doctype: manpage
+:compat-mode!:
+
+== NAME
+libnftables-json - Supported JSON schema by libnftables
+
+== SYNOPSIS
+*{ "nftables": [* 'OBJECTS' *] }*
+
+'OBJECTS' := 'LIST_OBJECTS' | 'CMD_OBJECTS'
+
+'LIST_OBJECTS' := 'LIST_OBJECT' [ *,* 'LIST_OBJECTS' ]
+
+'CMD_OBJECTS' := 'CMD_OBJECT' [ *,* 'CMD_OBJECTS' ]
+
+'CMD_OBJECT' := *{* 'CMD'*:* 'LIST_OBJECT' *}* | 'METAINFO_OBJECT'
+
+'CMD' := *"add"* | *"replace"* | *"create"* | *"insert"* | *"delete"* |
+ *"list"* | *"reset"* | *"flush"* | *"rename"*
+
+'LIST_OBJECT' := 'TABLE' | 'CHAIN' | 'RULE' | 'SET' | 'MAP' | 'ELEMENT' |
+ 'FLOWTABLE' | 'COUNTER' | 'QUOTA' | 'CT_HELPER' | 'LIMIT' |
+ 'METAINFO_OBJECT' | 'CT_TIMEOUT' | 'CT_EXPECTATION'
+
+== DESCRIPTION
+libnftables supports JSON formatted input and output. This is implemented as an
+alternative frontend to the standard CLI syntax parser, therefore basic
+behaviour is identical and, for (almost) any operation available in standard
+syntax, there should be an equivalent one in JSON.
+
+JSON input may be provided in a single string as parameter to
+*nft_run_cmd_from_buffer()* or in a file identified by the 'filename' parameter
+of the *nft_run_cmd_from_filename()* function.
+
+JSON output has to be enabled via the *nft_ctx_output_set_json()* function, turning
+library standard output into JSON format. Error output remains unaffected.
+
+== GLOBAL STRUCTURE
+In general, any JSON input or output is enclosed in an object with a single
+property named 'nftables'. Its value is an array containing commands (for
+input) or ruleset elements (for output).
+
+A command is an object with a single property whose name identifies the command.
+Its value is a ruleset element - basically identical to output elements, apart
+from certain properties which may be interpreted differently or are required
+when output generally omits them.
+
+== METAINFO OBJECT
+In output, the first object in an *nftables* array is a special one containing
+library information. Its content is as follows:
+
+[verse]
+*{ "metainfo": {
+ "version":* 'STRING'*,
+ "release_name":* 'STRING'*,
+ "json_schema_version":* 'NUMBER'
+*}}*
+
+The values of *version* and *release_name* properties are equal to the package
+version and release name as printed by *nft -v*. The value of the
+*json_schema_version* property is an integer indicating the schema version.
+
+If supplied in library input, the parser will verify the *json_schema_version* value
+to not exceed the internally hardcoded one (to make sure the given schema is
+fully understood). In future, a lower number than the internal one may activate
+compatibility mode to parse outdated and incompatible JSON input.
+
+== COMMAND OBJECTS
+The structure accepts an arbitrary amount of commands which are interpreted in
+order of appearance. For instance, the following standard syntax input:
+
+----
+flush ruleset
+add table inet mytable
+add chain inet mytable mychain
+add rule inet mytable mychain tcp dport 22 accept
+----
+
+translates into JSON as such:
+
+----
+{ "nftables": [
+ { "flush": { "ruleset": null }},
+ { "add": { "table": {
+ "family": "inet",
+ "name": "mytable"
+ }}},
+ { "add": { "chain": {
+ "family": "inet",
+ "table": "mytable",
+ "name": "mychain"
+ }}},
+ { "add": { "rule": {
+ "family": "inet",
+ "table": "mytable",
+ "chain": "mychain",
+ "expr": [
+ { "match": {
+ "op": "==",
+ "left": { "payload": {
+ "protocol": "tcp",
+ "field": "dport"
+ }},
+ "right": 22
+ }},
+ { "accept": null }
+ ]
+ }}}
+]}
+----
+
+=== ADD
+[verse]
+____
+*{ "add":* 'ADD_OBJECT' *}*
+
+'ADD_OBJECT' := 'TABLE' | 'CHAIN' | 'RULE' | 'SET' | 'MAP' | 'ELEMENT' |
+ 'FLOWTABLE' | 'COUNTER' | 'QUOTA' | 'CT_HELPER' | 'LIMIT' |
+ 'CT_TIMEOUT' | 'CT_EXPECTATION'
+____
+
+Add a new ruleset element to the kernel.
+
+=== REPLACE
+[verse]
+*{ "replace":* 'RULE' *}*
+
+Replace a rule. In 'RULE', the *handle* property is mandatory and identifies the
+rule to be replaced.
+
+=== CREATE
+[verse]
+*{ "create":* 'ADD_OBJECT' *}*
+
+Identical to *add* command, but returns an error if the object already exists.
+
+=== INSERT
+[verse]
+*{ "insert":* 'RULE' *}*
+
+This command is identical to *add* for rules, but instead of appending the rule
+to the chain by default, it inserts at first position. If a *handle* or *index*
+property is given, the rule is inserted before the rule identified by those
+properties.
+
+=== DELETE
+[verse]
+*{ "delete":* 'ADD_OBJECT' *}*
+
+Delete an object from the ruleset. Only the minimal number of properties
+required to uniquely identify an object is generally needed in 'ADD_OBJECT'. For
+most ruleset elements, this is *family* and *table* plus either *handle* or
+*name* (except rules since they don't have a name).
+
+=== LIST
+[verse]
+____
+*{ "list":* 'LIST_OBJECT' *}*
+
+'LIST_OBJECT' := 'TABLE' | 'TABLES' | 'CHAIN' | 'CHAINS' | 'SET' | 'SETS' |
+ 'MAP' | 'MAPS | COUNTER' | 'COUNTERS' | 'QUOTA' | 'QUOTAS' |
+ 'CT_HELPER' | 'CT_HELPERS' | 'LIMIT' | 'LIMITS' | 'RULESET' |
+ 'METER' | 'METERS' | 'FLOWTABLE' | 'FLOWTABLES' |
+ 'CT_TIMEOUT' | 'CT_EXPECTATION'
+____
+
+List ruleset elements. The plural forms are used to list all objects of that
+kind, optionally filtered by *family* and for some, also *table*.
+
+=== RESET
+[verse]
+____
+*{ "reset":* 'RESET_OBJECT' *}*
+
+'RESET_OBJECT' := 'COUNTER' | 'COUNTERS' | 'QUOTA' | 'QUOTAS' | 'RULE' | 'RULES' | 'SET' | 'MAP' | 'ELEMENT'
+____
+
+Reset state in suitable objects, i.e. zero their internal counter.
+
+=== FLUSH
+[verse]
+____
+*{ "flush":* 'FLUSH_OBJECT' *}*
+
+'FLUSH_OBJECT' := 'TABLE' | 'CHAIN' | 'SET' | 'MAP' | 'METER' | 'RULESET'
+____
+
+Empty contents in given object, e.g. remove all chains from given *table* or
+remove all elements from given *set*.
+
+=== RENAME
+[verse]
+*{ "rename":* 'CHAIN' *}*
+
+Rename a chain. The new name is expected in a dedicated property named
+*newname*.
+
+== RULESET ELEMENTS
+
+=== TABLE
+[verse]
+*{ "table": {
+ "family":* 'STRING'*,
+ "name":* 'STRING'*,
+ "handle":* 'NUMBER'
+*}}*
+
+This object describes a table.
+
+*family*::
+ The table's family, e.g. *"ip"* or *"ip6"*.
+*name*::
+ The table's name.
+*handle*::
+ The table's handle. In input, it is used only in *delete* command as
+ alternative to *name*.
+
+=== CHAIN
+[verse]
+*{ "chain": {
+ "family":* 'STRING'*,
+ "table":* 'STRING'*,
+ "name":* 'STRING'*,
+ "newname":* 'STRING'*,
+ "handle":* 'NUMBER'*,
+ "type":* 'STRING'*,
+ "hook":* 'STRING'*,
+ "prio":* 'NUMBER'*,
+ "dev":* 'STRING'*,
+ "policy":* 'STRING'
+*}}*
+
+This object describes a chain.
+
+*family*::
+ The table's family.
+*table*::
+ The table's name.
+*name*::
+ The chain's name.
+*handle*::
+ The chain's handle. In input, it is used only in *delete* command as
+ alternative to *name*.
+*newname*::
+ A new name for the chain, only relevant in the *rename* command.
+
+The following properties are required for base chains:
+
+*type*::
+ The chain's type.
+*hook*::
+ The chain's hook.
+*prio*::
+ The chain's priority.
+*dev*::
+ The chain's bound interface (if in the netdev family).
+*policy*::
+ The chain's policy.
+
+=== RULE
+[verse]
+____
+*{ "rule": {
+ "family":* 'STRING'*,
+ "table":* 'STRING'*,
+ "chain":* 'STRING'*,
+ "expr": [* 'STATEMENTS' *],
+ "handle":* 'NUMBER'*,
+ "index":* 'NUMBER'*,
+ "comment":* 'STRING'
+*}}*
+
+'STATEMENTS' := 'STATEMENT' [*,* 'STATEMENTS' ]
+____
+
+This object describes a rule. Basic building blocks of rules are statements.
+Each rule consists of at least one.
+
+*family*::
+ The table's family.
+*table*::
+ The table's name.
+*chain*::
+ The chain's name.
+*expr*::
+ An array of statements this rule consists of. In input, it is used in
+ *add*/*insert*/*replace* commands only.
+*handle*::
+ The rule's handle. In *delete*/*replace* commands, it serves as an identifier
+ of the rule to delete/replace. In *add*/*insert* commands, it serves as
+ an identifier of an existing rule to append/prepend the rule to.
+*index*::
+ The rule's position for *add*/*insert* commands. It is used as an alternative to
+ *handle* then.
+*comment*::
+ Optional rule comment.
+
+=== SET / MAP
+[verse]
+____
+*{ "set": {
+ "family":* 'STRING'*,
+ "table":* 'STRING'*,
+ "name":* 'STRING'*,
+ "handle":* 'NUMBER'*,
+ "type":* 'SET_TYPE'*,
+ "policy":* 'SET_POLICY'*,
+ "flags": [* 'SET_FLAG_LIST' *],
+ "elem":* 'SET_ELEMENTS'*,
+ "timeout":* 'NUMBER'*,
+ "gc-interval":* 'NUMBER'*,
+ "size":* 'NUMBER'
+*}}*
+
+*{ "map": {
+ "family":* 'STRING'*,
+ "table":* 'STRING'*,
+ "name":* 'STRING'*,
+ "handle":* 'NUMBER'*,
+ "type":* 'SET_TYPE'*,
+ "map":* 'STRING'*,
+ "policy":* 'SET_POLICY'*,
+ "flags": [* 'SET_FLAG_LIST' *],
+ "elem":* 'SET_ELEMENTS'*,
+ "timeout":* 'NUMBER'*,
+ "gc-interval":* 'NUMBER'*,
+ "size":* 'NUMBER'
+*}}*
+
+'SET_TYPE' := 'STRING' | *[* 'SET_TYPE_LIST' *]*
+'SET_TYPE_LIST' := 'STRING' [*,* 'SET_TYPE_LIST' ]
+'SET_POLICY' := *"performance"* | *"memory"*
+'SET_FLAG_LIST' := 'SET_FLAG' [*,* 'SET_FLAG_LIST' ]
+'SET_FLAG' := *"constant"* | *"interval"* | *"timeout"*
+'SET_ELEMENTS' := 'EXPRESSION' | *[* 'EXPRESSION_LIST' *]*
+'EXPRESSION_LIST' := 'EXPRESSION' [*,* 'EXPRESSION_LIST' ]
+____
+
+These objects describe a named set or map. Maps are a special form of sets in
+that they translate a unique key to a value.
+
+*family*::
+ The table's family.
+*table*::
+ The table's name.
+*name*::
+ The set's name.
+*handle*::
+ The set's handle. For input, it is used in the *delete* command only.
+*type*::
+ The set's datatype, see below.
+*map*::
+ Type of values this set maps to (i.e. this set is a map).
+*policy*::
+ The set's policy.
+*flags*::
+ The set's flags.
+*elem*::
+ Initial set element(s), see below.
+*timeout*::
+ Element timeout in seconds.
+*gc-interval*::
+ Garbage collector interval in seconds.
+*size*::
+ Maximum number of elements supported.
+
+==== TYPE
+The set type might be a string, such as *"ipv4_addr"* or an array
+consisting of strings (for concatenated types).
+
+==== ELEM
+A single set element might be given as string, integer or boolean value for
+simple cases. If additional properties are required, a formal *elem* object may
+be used.
+
+Multiple elements may be given in an array.
+
+=== ELEMENT
+[verse]
+____
+*{ "element": {
+ "family":* 'STRING'*,
+ "table":* 'STRING'*,
+ "name":* 'STRING'*,
+ "elem":* 'SET_ELEM'
+*}}*
+
+'SET_ELEM' := 'EXPRESSION' | *[* 'EXPRESSION_LIST' *]*
+'EXPRESSION_LIST' := 'EXPRESSION' [*,* 'EXPRESSION' ]
+____
+
+Manipulate element(s) in a named set.
+
+*family*::
+ The table's family.
+*table*::
+ The table's name.
+*name*::
+ The set's name.
+*elem*::
+ See elem property of set object.
+
+=== FLOWTABLE
+[verse]
+____
+*{ "flowtable": {
+ "family":* 'STRING'*,
+ "table":* 'STRING'*,
+ "name":* 'STRING'*,
+ "handle":* 'NUMBER'*,
+ "hook":* 'STRING'*,
+ "prio":* 'NUMBER'*,
+ "dev":* 'FT_INTERFACE'
+*}}*
+
+'FT_INTERFACE' := 'STRING' | *[* 'FT_INTERFACE_LIST' *]*
+'FT_INTERFACE_LIST' := 'STRING' [*,* 'STRING' ]
+____
+
+This object represents a named flowtable.
+
+*family*::
+ The table's family.
+*table*::
+ The table's name.
+*name*::
+ The flow table's name.
+*handle*::
+ The flow table's handle. In input, it is used by the *delete* command only.
+*hook*::
+ The flow table's hook.
+*prio*::
+ The flow table's priority.
+*dev*::
+ The flow table's interface(s).
+
+=== COUNTER
+[verse]
+*{ "counter": {
+ "family":* 'STRING'*,
+ "table":* 'STRING'*,
+ "name":* 'STRING'*,
+ "handle":* 'NUMBER'*,
+ "packets":* 'NUMBER'*,
+ "bytes":* 'NUMBER'
+*}}*
+
+This object represents a named counter.
+
+*family*::
+ The table's family.
+*table*::
+ The table's name.
+*name*::
+ The counter's name.
+*handle*::
+ The counter's handle. In input, it is used by the *delete* command only.
+*packets*::
+ Packet counter value.
+*bytes*::
+ Byte counter value.
+
+=== QUOTA
+[verse]
+*{ "quota": {
+ "family":* 'STRING'*,
+ "table":* 'STRING'*,
+ "name":* 'STRING'*,
+ "handle":* 'NUMBER'*,
+ "bytes":* 'NUMBER'*,
+ "used":* 'NUMBER'*,
+ "inv":* 'BOOLEAN'
+*}}*
+
+This object represents a named quota.
+
+*family*::
+ The table's family.
+*table*::
+ The table's name.
+*name*::
+ The quota's name.
+*handle*::
+ The quota's handle. In input, it is used by the *delete* command only.
+*bytes*::
+ Quota threshold.
+*used*::
+ Quota used so far.
+*inv*::
+ If true, match if the quota has been exceeded.
+
+=== CT HELPER
+[verse]
+____
+*{ "ct helper": {
+ "family":* 'STRING'*,
+ "table":* 'STRING'*,
+ "name":* 'STRING'*,
+ "handle":* '... '*,
+ "type":* 'STRING'*,
+ "protocol":* 'CTH_PROTO'*,
+ "l3proto":* 'STRING'
+*}}*
+
+'CTH_PROTO' := *"tcp"* | *"udp"*
+____
+
+This object represents a named conntrack helper.
+
+*family*::
+ The table's family.
+*table*::
+ The table's name.
+*name*::
+ The ct helper's name.
+*handle*::
+ The ct helper's handle. In input, it is used by the *delete* command only.
+*type*::
+ The ct helper type name, e.g. *"ftp"* or *"tftp"*.
+*protocol*::
+ The ct helper's layer 4 protocol.
+*l3proto*::
+ The ct helper's layer 3 protocol, e.g. *"ip"* or *"ip6"*.
+
+=== LIMIT
+[verse]
+____
+*{ "limit": {
+ "family":* 'STRING'*,
+ "table":* 'STRING'*,
+ "name":* 'STRING'*,
+ "handle":* 'NUMBER'*,
+ "rate":* 'NUMBER'*,
+ "per":* 'STRING'*,
+ "burst":* 'NUMBER'*,
+ "unit":* 'LIMIT_UNIT'*,
+ "inv":* 'BOOLEAN'
+*}}*
+
+'LIMIT_UNIT' := *"packets"* | *"bytes"*
+____
+
+This object represents a named limit.
+
+*family*::
+ The table's family.
+*table*::
+ The table's name.
+*name*::
+ The limit's name.
+*handle*::
+ The limit's handle. In input, it is used by the *delete* command only.
+*rate*::
+ The limit's rate value.
+*per*::
+ Time unit to apply the limit to, e.g. *"week"*, *"day"*, *"hour"*, etc.
+ If omitted, defaults to *"second"*.
+*burst*::
+ The limit's burst value. If omitted, defaults to *0*.
+*unit*::
+ Unit of rate and burst values. If omitted, defaults to *"packets"*.
+*inv*::
+ If true, match if limit was exceeded. If omitted, defaults to *false*.
+
+=== CT TIMEOUT
+[verse]
+____
+*{ "ct timeout": {
+ "family":* 'STRING'*,
+ "table":* 'STRING'*,
+ "name":* 'STRING'*,
+ "handle":* 'NUMBER'*,
+ "protocol":* 'CTH_PROTO'*,
+ "state":* 'STRING'*,
+ "value:* 'NUMBER'*,
+ "l3proto":* 'STRING'
+*}}*
+
+'CTH_PROTO' := *"tcp"* | *"udp"* | *"dccp"* | *"sctp"* | *"gre"* | *"icmpv6"* | *"icmp"* | *"generic"*
+____
+
+This object represents a named conntrack timeout policy.
+
+*family*::
+ The table's family.
+*table*::
+ The table's name.
+*name*::
+ The ct timeout object's name.
+*handle*::
+ The ct timeout object's handle. In input, it is used by *delete* command only.
+*protocol*::
+ The ct timeout object's layer 4 protocol.
+*state*::
+ The connection state name, e.g. *"established"*, *"syn_sent"*, *"close"* or
+ *"close_wait"*, for which the timeout value has to be updated.
+*value*::
+ The updated timeout value for the specified connection state.
+*l3proto*::
+ The ct timeout object's layer 3 protocol, e.g. *"ip"* or *"ip6"*.
+
+=== CT EXPECTATION
+[verse]
+____
+*{ "ct expectation": {
+ "family":* 'STRING'*,
+ "table":* 'STRING'*,
+ "name":* 'STRING'*,
+ "handle":* 'NUMBER'*,
+ "l3proto":* 'STRING'
+ "protocol":* 'CTH_PROTO'*,
+ "dport":* 'NUMBER'*,
+ "timeout:* 'NUMBER'*,
+ "size:* 'NUMBER'*,
+*}}*
+
+'CTH_PROTO' := *"tcp"* | *"udp"* | *"dccp"* | *"sctp"* | *"gre"* | *"icmpv6"* | *"icmp"* | *"generic"*
+____
+
+This object represents a named conntrack expectation.
+
+*family*::
+ The table's family.
+*table*::
+ The table's name.
+*name*::
+ The ct expectation object's name.
+*handle*::
+ The ct expectation object's handle. In input, it is used by *delete* command only.
+*l3proto*::
+ The ct expectation object's layer 3 protocol, e.g. *"ip"* or *"ip6"*.
+*protocol*::
+ The ct expectation object's layer 4 protocol.
+*dport*::
+ The destination port of the expected connection.
+*timeout*::
+ The time in millisecond that this expectation will live.
+*size*::
+ The maximum count of expectations to be living in the same time.
+
+== STATEMENTS
+Statements are the building blocks for rules. Each rule consists of at least
+one.
+
+=== VERDICT
+[verse]
+*{ "accept": null }*
+*{ "drop": null }*
+*{ "continue": null }*
+*{ "return": null }*
+*{ "jump": { "target": * 'STRING' *}}*
+*{ "goto": { "target": * 'STRING' *}}*
+
+A verdict either terminates packet traversal through the current chain or
+delegates to a different one.
+
+*jump* and *goto* statements expect a target chain name.
+
+=== MATCH
+[verse]
+*{ "match": {
+ "left":* 'EXPRESSION'*,
+ "right":* 'EXPRESSION'*,
+ "op":* 'STRING'
+*}}*
+
+This matches the expression on left hand side (typically a packet header or packet meta
+info) with the expression on right hand side (typically a constant value). If the
+statement evaluates to true, the next statement in this rule is considered. If not,
+processing continues with the next rule in the same chain.
+
+*left*::
+ Left hand side of this match.
+*right*::
+ Right hand side of this match.
+*op*::
+ Operator indicating the type of comparison.
+
+==== OPERATORS
+
+[horizontal]
+*&*:: Binary AND
+*|*:: Binary OR
+*^*:: Binary XOR
+*<<*:: Left shift
+*>>*:: Right shift
+*==*:: Equal
+*!=*:: Not equal
+*<*:: Less than
+*>*:: Greater than
+*<=*:: Less than or equal to
+*>=*:: Greater than or equal to
+*in*:: Perform a lookup, i.e. test if bits on RHS are contained in LHS value
+
+Unlike with the standard API, the operator is mandatory here. In the standard API,
+a missing operator may be resolved in two ways, depending on the type of expression
+on the RHS:
+
+- If the RHS is a bitmask or a list of bitmasks, the expression resolves into a
+ binary operation with the inequality operator, like this: '+LHS & RHS != 0+'.
+- In any other case, the equality operator is simply inserted.
+
+For the non-trivial first case, the JSON API supports the *in* operator.
+
+=== COUNTER
+[verse]
+____
+*{ "counter": {
+ "packets":* 'NUMBER'*,
+ "bytes":* 'NUMBER'
+*}}*
+
+*{ "counter":* 'STRING' *}*
+____
+
+This object represents a byte/packet counter. In input, no properties are
+required. If given, they act as initial values for the counter.
+
+The first form creates an anonymous counter which lives in the rule it appears
+in. The second form specifies a reference to a named counter object.
+
+*packets*::
+ Packets counted.
+*bytes*::
+ Bytes counted.
+
+=== MANGLE
+[verse]
+*{ "mangle": {
+ "key":* 'EXPRESSION'*,
+ "value":* 'EXPRESSION'
+*}}*
+
+This changes the packet data or meta info.
+
+*key*::
+ The packet data to be changed, given as an *exthdr*, *payload*, *meta*, *ct* or
+ *ct helper* expression.
+*value*::
+ Value to change data to.
+
+=== QUOTA
+[verse]
+____
+*{ "quota": {
+ "val":* 'NUMBER'*,
+ "val_unit":* 'STRING'*,
+ "used":* 'NUMBER'*,
+ "used_unit":* 'STRING'*,
+ "inv":* 'BOOLEAN'
+*}}*
+
+*{ "quota":* 'STRING' *}*
+____
+
+The first form creates an anonymous quota which lives in the rule it appears in.
+The second form specifies a reference to a named quota object.
+
+*val*::
+ Quota value.
+*val_unit*::
+ Unit of *val*, e.g. *"kbytes"* or *"mbytes"*. If omitted, defaults to
+ *"bytes"*.
+*used*::
+ Quota used so far. Optional on input. If given, serves as initial value.
+*used_unit*::
+ Unit of *used*. Defaults to *"bytes"*.
+*inv*::
+ If *true*, will match if quota was exceeded. Defaults to *false*.
+
+=== LIMIT
+[verse]
+____
+*{ "limit": {
+ "rate":* 'NUMBER'*,
+ "rate_unit":* 'STRING'*,
+ "per":* 'STRING'*,
+ "burst":* 'NUMBER'*,
+ "burst_unit":* 'STRING'*,
+ "inv":* 'BOOLEAN'
+*}}*
+
+*{ "limit":* 'STRING' *}*
+____
+
+The first form creates an anonymous limit which lives in the rule it appears in.
+The second form specifies a reference to a named limit object.
+
+*rate*::
+ Rate value to limit to.
+*rate_unit*::
+ Unit of *rate*, e.g. *"packets"* or *"mbytes"*. Defaults to *"packets"*.
+*per*::
+ Denominator of *rate*, e.g. *"week"* or *"minutes"*.
+*burst*::
+ Burst value. Defaults to *0*.
+*burst_unit*::
+ Unit of *burst*, ignored if *rate_unit* is *"packets"*. Defaults to
+ *"bytes"*.
+*inv*::
+ If *true*, matches if the limit was exceeded. Defaults to *false*.
+
+=== FWD
+[verse]
+____
+*{ "fwd": {
+ "dev":* 'EXPRESSION'*,
+ "family":* 'FWD_FAMILY'*,
+ "addr":* 'EXPRESSION'
+*}}*
+
+'FWD_FAMILY' := *"ip"* | *"ip6"*
+____
+
+Forward a packet to a different destination.
+
+*dev*::
+ Interface to forward the packet on.
+*family*::
+ Family of *addr*.
+*addr*::
+ IP(v6) address to forward the packet to.
+
+Both *family* and *addr* are optional, but if at least one is given, both must be present.
+
+=== NOTRACK
+[verse]
+*{ "notrack": null }*
+
+Disable connection tracking for the packet.
+
+=== DUP
+[verse]
+*{ "dup": {
+ "addr":* 'EXPRESSION'*,
+ "dev":* 'EXPRESSION'
+*}}*
+
+Duplicate a packet to a different destination.
+
+*addr*::
+ Address to duplicate packet to.
+*dev*::
+ Interface to duplicate packet on. May be omitted to not specify an
+ interface explicitly.
+
+=== NETWORK ADDRESS TRANSLATION
+[verse]
+____
+*{ "snat": {
+ "addr":* 'EXPRESSION'*,
+ "family":* 'STRING'*,
+ "port":* 'EXPRESSION'*,
+ "flags":* 'FLAGS'
+*}}*
+
+*{ "dnat": {
+ "addr":* 'EXPRESSION'*,
+ "family":* 'STRING'*,
+ "port":* 'EXPRESSION'*,
+ "flags":* 'FLAGS'
+*}}*
+
+*{ "masquerade": {
+ "port":* 'EXPRESSION'*,
+ "flags":* 'FLAGS'
+*}}*
+
+*{ "redirect": {
+ "port":* 'EXPRESSION'*,
+ "flags":* 'FLAGS'
+*}}*
+
+'FLAGS' := 'FLAG' | *[* 'FLAG_LIST' *]*
+'FLAG_LIST' := 'FLAG' [*,* 'FLAG_LIST' ]
+'FLAG' := *"random"* | *"fully-random"* | *"persistent"*
+____
+
+Perform Network Address Translation.
+
+*addr*::
+ Address to translate to.
+*family*::
+ Family of *addr*, either *ip* or *ip6*. Required in *inet*
+ table family.
+*port*::
+ Port to translate to.
+*flags*::
+ Flag(s).
+
+All properties are optional and default to none.
+
+=== REJECT
+[verse]
+*{ "reject": {
+ "type":* 'STRING'*,
+ "expr":* 'EXPRESSION'
+*}}*
+
+Reject the packet and send the given error reply.
+
+*type*::
+ Type of reject, either *"tcp reset"*, *"icmpx"*, *"icmp"* or *"icmpv6"*.
+*expr*::
+ ICMP code to reject with.
+
+All properties are optional.
+
+=== SET
+[verse]
+*{ "set": {
+ "op":* 'STRING'*,
+ "elem":* 'EXPRESSION'*,
+ "set":* 'STRING'
+*}}*
+
+Dynamically add/update elements to a set.
+
+*op*::
+ Operator on set, either *"add"* or *"update"*.
+*elem*::
+ Set element to add or update.
+*set*::
+ Set reference.
+
+=== LOG
+[verse]
+____
+*{ "log": {
+ "prefix":* 'STRING'*,
+ "group":* 'NUMBER'*,
+ "snaplen":* 'NUMBER'*,
+ "queue-threshold":* 'NUMBER'*,
+ "level":* 'LEVEL'*,
+ "flags":* 'FLAGS'
+*}}*
+
+'LEVEL' := *"emerg"* | *"alert"* | *"crit"* | *"err"* | *"warn"* | *"notice"* |
+ *"info"* | *"debug"* | *"audit"*
+
+'FLAGS' := 'FLAG' | *[* 'FLAG_LIST' *]*
+'FLAG_LIST' := 'FLAG' [*,* 'FLAG_LIST' ]
+'FLAG' := *"tcp sequence"* | *"tcp options"* | *"ip options"* | *"skuid"* |
+ *"ether"* | *"all"*
+____
+
+Log the packet.
+
+*prefix*::
+ Prefix for log entries.
+*group*::
+ Log group.
+*snaplen*::
+ Snaplen for logging.
+*queue-threshold*::
+ Queue threshold.
+*level*::
+ Log level. Defaults to *"warn"*.
+*flags*::
+ Log flags.
+
+All properties are optional.
+
+=== CT HELPER
+[verse]
+*{ "ct helper":* 'EXPRESSION' *}*
+
+Enable the specified conntrack helper for this packet.
+
+*ct helper*::
+ CT helper reference.
+
+=== METER
+[verse]
+*{ "meter": {
+ "name":* 'STRING'*,
+ "key":* 'EXPRESSION'*,
+ "stmt":* 'STATEMENT'
+*}}*
+
+Apply a given statement using a meter.
+
+*name*::
+ Meter name.
+*key*::
+ Meter key.
+*stmt*::
+ Meter statement.
+
+=== QUEUE
+[verse]
+____
+*{ "queue": {
+ "num":* 'EXPRESSION'*,
+ "flags":* 'FLAGS'
+*}}*
+
+'FLAGS' := 'FLAG' | *[* 'FLAG_LIST' *]*
+'FLAG_LIST' := 'FLAG' [*,* 'FLAG_LIST' ]
+'FLAG' := *"bypass"* | *"fanout"*
+____
+
+Queue the packet to userspace.
+
+*num*::
+ Queue number.
+*flags*::
+ Queue flags.
+
+=== VERDICT MAP
+[verse]
+*{ "vmap": {
+ "key":* 'EXPRESSION'*,
+ "data":* 'EXPRESSION'
+*}}*
+
+Apply a verdict conditionally.
+
+*key*::
+ Map key.
+*data*::
+ Mapping expression consisting of value/verdict pairs.
+
+=== CT COUNT
+[verse]
+*{ "ct count": {
+ "val":* 'NUMBER'*,
+ "inv":* 'BOOLEAN'
+*}}*
+
+Limit the number of connections using conntrack.
+
+*val*::
+ Connection count threshold.
+*inv*::
+ If *true*, match if *val* was exceeded. If omitted, defaults to
+ *false*.
+
+=== CT TIMEOUT
+[verse]
+*{ "ct timeout":* 'EXPRESSION' *}*
+
+Assign connection tracking timeout policy.
+
+*ct timeout*::
+ CT timeout reference.
+
+=== CT EXPECTATION
+[verse]
+*{ "ct expectation":* 'EXPRESSION' *}*
+
+Assign connection tracking expectation.
+
+*ct expectation*::
+ CT expectation reference.
+
+=== XT
+[verse]
+____
+*{ "xt": {
+ "type":* 'TYPENAME'*,
+ "name":* 'STRING'
+*}}*
+
+'TYPENAME' := *match* | *target* | *watcher*
+____
+
+This represents an xt statement from xtables compat interface. It is a
+fallback if translation is not available or not complete.
+
+Seeing this means the ruleset (or parts of it) were created by *iptables-nft*
+and one should use that to manage it.
+
+*BEWARE:* nftables won't restore these statements.
+
+== EXPRESSIONS
+Expressions are the building blocks of (most) statements. In their most basic
+form, they are just immediate values represented as a JSON string, integer or
+boolean type.
+
+=== IMMEDIATES
+[verse]
+'STRING'
+'NUMBER'
+'BOOLEAN'
+
+Immediate expressions are typically used for constant values. For strings, there
+are two special cases:
+
+*@STRING*::
+ The remaining part is taken as set name to create a set reference.
+*\**::
+ Construct a wildcard expression.
+
+=== LISTS
+[verse]
+'ARRAY'
+
+List expressions are constructed by plain arrays containing of an arbitrary
+number of expressions.
+
+=== CONCAT
+[verse]
+____
+*{ "concat":* 'CONCAT' *}*
+
+'CONCAT' := *[* 'EXPRESSION_LIST' *]*
+'EXPRESSION_LIST' := 'EXPRESSION' [*,* 'EXPRESSION_LIST' ]
+____
+
+Concatenate several expressions.
+
+=== SET
+[verse]
+____
+*{ "set":* 'SET' *}*
+
+'SET' := 'EXPRESSION' | *[* 'EXPRESSION_LIST' *]*
+____
+
+This object constructs an anonymous set. For mappings, an array of arrays with
+exactly two elements is expected.
+
+=== MAP
+[verse]
+*{ "map": {
+ "key":* 'EXPRESSION'*,
+ "data":* 'EXPRESSION'
+*}}*
+
+Map a key to a value.
+
+*key*::
+ Map key.
+*data*::
+ Mapping expression consisting of value/target pairs.
+
+=== PREFIX
+[verse]
+*{ "prefix": {
+ "addr":* 'EXPRESSION'*,
+ "len":* 'NUMBER'
+*}}*
+
+Construct an IPv4 or IPv6 prefix consisting of address part in *addr* and prefix
+length in *len*.
+
+=== RANGE
+[verse]
+*{ "range": [* 'EXPRESSION' *,* 'EXPRESSION' *] }*
+
+Construct a range of values. The first array item denotes the lower boundary,
+the second one the upper boundary.
+
+=== PAYLOAD
+[verse]
+____
+*{ "payload": {
+ "base":* 'BASE'*,
+ "offset":* 'NUMBER'*,
+ "len":* 'NUMBER'
+*}}*
+
+*{ "payload": {
+ "protocol":* 'STRING'*,
+ "field":* 'STRING'
+*}}*
+
+'BASE' := *"ll"* | *"nh"* | *"th"*
+____
+
+Construct a payload expression, i.e. a reference to a certain part of packet
+data. The first form creates a raw payload expression to point at a random
+number (*len*) of bytes at a certain offset (*offset*) from a given reference
+point (*base*). The following *base* values are accepted:
+
+*"ll"*::
+ The offset is relative to Link Layer header start offset.
+*"nh"*::
+ The offset is relative to Network Layer header start offset.
+*"th"*::
+ The offset is relative to Transport Layer header start offset.
+
+The second form allows one to reference a field by name (*field*) in a named packet
+header (*protocol*).
+
+=== EXTHDR
+[verse]
+*{ "exthdr": {
+ "name":* 'STRING'*,
+ "field":* 'STRING'*,
+ "offset":* 'NUMBER'
+*}}*
+
+Create a reference to a field (*field*) in an IPv6 extension header (*name*).
+*offset* is used only for *rt0* protocol.
+
+If the *field* property is not given, the expression is to be used as a header
+existence check in a *match* statement with a boolean on the right hand side.
+
+=== TCP OPTION
+[verse]
+*{ "tcp option": {
+ "name":* 'STRING'*,
+ "field":* 'STRING'
+*}}*
+
+Create a reference to a field (*field*) of a TCP option header (*name*).
+
+If the *field* property is not given, the expression is to be used as a TCP option
+existence check in a *match* statement with a boolean on the right hand side.
+
+=== SCTP CHUNK
+[verse]
+*{ "sctp chunk": {
+ "name":* 'STRING'*,
+ "field":* 'STRING'
+*}}*
+
+Create a reference to a field (*field*) of an SCTP chunk (*name*).
+
+If the *field* property is not given, the expression is to be used as an SCTP
+chunk existence check in a *match* statement with a boolean on the right hand
+side.
+
+=== DCCP OPTION
+[verse]
+*{ "dccp option": {
+ "type":* 'NUMBER'*
+*}}*
+
+Create a reference to a DCCP option (*type*).
+
+The expression is to be used as a DCCP option existence check in a *match*
+statement with a boolean on the right hand side.
+
+=== META
+[verse]
+____
+*{ "meta": {
+ "key":* 'META_KEY'
+*}}*
+
+'META_KEY' := *"length"* | *"protocol"* | *"priority"* | *"random"* | *"mark"* |
+ *"iif"* | *"iifname"* | *"iiftype"* | *"oif"* | *"oifname"* |
+ *"oiftype"* | *"skuid"* | *"skgid"* | *"nftrace"* |
+ *"rtclassid"* | *"ibriport"* | *"obriport"* | *"ibridgename"* |
+ *"obridgename"* | *"pkttype"* | *"cpu"* | *"iifgroup"* |
+ *"oifgroup"* | *"cgroup"* | *"nfproto"* | *"l4proto"* |
+ *"secpath"*
+____
+
+Create a reference to packet meta data.
+
+=== RT
+[verse]
+____
+*{ "rt": {
+ "key":* 'RT_KEY'*,
+ "family":* 'RT_FAMILY'
+*}}*
+
+'RT_KEY' := *"classid"* | *"nexthop"* | *"mtu"*
+'RT_FAMILY' := *"ip"* | *"ip6"*
+____
+
+Create a reference to packet routing data.
+
+The *family* property is optional and defaults to unspecified.
+
+=== CT
+[verse]
+____
+*{ "ct": {
+ "key":* 'STRING'*,
+ "family":* 'CT_FAMILY'*,
+ "dir":* 'CT_DIRECTION'
+*}}*
+
+'CT_FAMILY' := *"ip"* | *"ip6"*
+'CT_DIRECTION' := *"original"* | *"reply"*
+____
+
+Create a reference to packet conntrack data.
+
+Some CT keys do not support a direction. In this case, *dir* must not be
+given.
+
+=== NUMGEN
+[verse]
+____
+*{ "numgen": {
+ "mode":* 'NG_MODE'*,
+ "mod":* 'NUMBER'*,
+ "offset":* 'NUMBER'
+*}}*
+
+'NG_MODE' := *"inc"* | *"random"*
+____
+
+Create a number generator.
+
+The *offset* property is optional and defaults to 0.
+
+=== HASH
+[verse]
+____
+*{ "jhash": {
+ "mod":* 'NUMBER'*,
+ "offset":* 'NUMBER'*,
+ "expr":* 'EXPRESSION'*,
+ "seed":* 'NUMBER'
+*}}*
+
+*{ "symhash": {
+ "mod":* 'NUMBER'*,
+ "offset":* 'NUMBER'
+*}}*
+____
+
+Hash packet data.
+
+The *offset* and *seed* properties are optional and default to 0.
+
+=== FIB
+[verse]
+____
+*{ "fib": {
+ "result":* 'FIB_RESULT'*,
+ "flags":* 'FIB_FLAGS'
+*}}*
+
+'FIB_RESULT' := *"oif"* | *"oifname"* | *"type"*
+
+'FIB_FLAGS' := 'FIB_FLAG' | *[* 'FIB_FLAG_LIST' *]*
+'FIB_FLAG_LIST' := 'FIB_FLAG' [*,* 'FIB_FLAG_LIST' ]
+'FIB_FLAG' := *"saddr"* | *"daddr"* | *"mark"* | *"iif"* | *"oif"*
+____
+
+Perform kernel Forwarding Information Base lookups.
+
+=== BINARY OPERATION
+[verse]
+*{ "|": [* 'EXPRESSION'*,* 'EXPRESSION' *] }*
+*{ "^": [* 'EXPRESSION'*,* 'EXPRESSION' *] }*
+*{ "&": [* 'EXPRESSION'*,* 'EXPRESSION' *] }*
+*{ "+<<+": [* 'EXPRESSION'*,* 'EXPRESSION' *] }*
+*{ ">>": [* 'EXPRESSION'*,* 'EXPRESSION' *] }*
+
+All binary operations expect an array of exactly two expressions, of which the
+first element denotes the left hand side and the second one the right hand
+side.
+
+=== VERDICT
+[verse]
+*{ "accept": null }*
+*{ "drop": null }*
+*{ "continue": null }*
+*{ "return": null }*
+*{ "jump": { "target":* 'STRING' *}}*
+*{ "goto": { "target":* 'STRING' *}}*
+
+Same as the *verdict* statement, but for use in verdict maps.
+
+*jump* and *goto* verdicts expect a target chain name.
+
+=== ELEM
+[verse]
+*{ "elem": {
+ "val":* 'EXPRESSION'*,
+ "timeout":* 'NUMBER'*,
+ "expires":* 'NUMBER'*,
+ "comment":* 'STRING'
+*}}*
+
+Explicitly set element object, in case *timeout*, *expires* or *comment* are
+desired. Otherwise, it may be replaced by the value of *val*.
+
+=== SOCKET
+[verse]
+____
+*{ "socket": {
+ "key":* 'SOCKET_KEY'
+*}}*
+
+'SOCKET_KEY' := *"transparent"*
+____
+
+Construct a reference to packet's socket.
+
+=== OSF
+[verse]
+____
+*{ "osf": {
+ "key":* 'OSF_KEY'*,
+ "ttl":* 'OSF_TTL'
+*}}*
+
+'OSF_KEY' := *"name"*
+'OSF_TTL' := *"loose"* | *"skip"*
+____
+
+Perform OS fingerprinting. This expression is typically used in the LHS of a *match*
+statement.
+
+*key*::
+ Which part of the fingerprint info to match against. At this point, only
+ the OS name is supported.
+*ttl*::
+ Define how the packet's TTL value is to be matched. This property is
+ optional. If omitted, the TTL value has to match exactly. A value of *loose*
+ accepts TTL values less than the fingerprint one. A value of *skip*
+ omits TTL value comparison entirely.
diff --git a/doc/libnftables.3 b/doc/libnftables.3
new file mode 100644
index 0000000..4778a8e
--- /dev/null
+++ b/doc/libnftables.3
@@ -0,0 +1,393 @@
+'\" t
+.\" Title: libnftables
+.\" Author: Phil Sutter <phil@nwl.cc>
+.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
+.\" Date: 10/11/2023
+.\" Manual: \ \&
+.\" Source: \ \&
+.\" Language: English
+.\"
+.TH "LIBNFTABLES" "3" "10/11/2023" "\ \&" "\ \&"
+.\" -----------------------------------------------------------------
+.\" * Define some portability stuff
+.\" -----------------------------------------------------------------
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.\" http://bugs.debian.org/507673
+.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.\" -----------------------------------------------------------------
+.\" * MAIN CONTENT STARTS HERE *
+.\" -----------------------------------------------------------------
+.SH "NAME"
+libnftables \- nftables frontend library
+.SH "SYNOPSIS"
+.sp
+.nf
+\fB#include <nftables/libnftables\&.h>
+
+struct nft_ctx *nft_ctx_new(uint32_t\fR \fIflags\fR\fB);
+void nft_ctx_free(struct nft_ctx\fR \fI*ctx\fR\fB);
+
+bool nft_ctx_get_dry_run(struct nft_ctx\fR \fI*ctx\fR\fB);
+void nft_ctx_set_dry_run(struct nft_ctx\fR \fI*ctx\fR\fB, bool\fR \fIdry\fR\fB);
+
+unsigned int nft_ctx_input_get_flags(struct nft_ctx\fR \fI*ctx\fR\fB);
+unsigned int nft_ctx_input_set_flags(struct nft_ctx\fR \fI*ctx\fR\fB, unsigned int\fR \fIflags\fR\fB);
+
+unsigned int nft_ctx_output_get_flags(struct nft_ctx\fR \fI*ctx\fR\fB);
+void nft_ctx_output_set_flags(struct nft_ctx\fR \fI*ctx\fR\fB, unsigned int\fR \fIflags\fR\fB);
+
+unsigned int nft_ctx_output_get_debug(struct nft_ctx\fR \fI*ctx\fR\fB);
+void nft_ctx_output_set_debug(struct nft_ctx\fR \fI*ctx\fR\fB, unsigned int\fR \fImask\fR\fB);
+
+FILE *nft_ctx_set_output(struct nft_ctx\fR \fI*ctx\fR\fB, FILE\fR \fI*fp\fR\fB);
+int nft_ctx_buffer_output(struct nft_ctx\fR \fI*ctx\fR\fB);
+int nft_ctx_unbuffer_output(struct nft_ctx\fR \fI*ctx\fR\fB);
+const char *nft_ctx_get_output_buffer(struct nft_ctx\fR \fI*ctx\fR\fB);
+
+FILE *nft_ctx_set_error(struct nft_ctx\fR \fI*ctx\fR\fB, FILE\fR \fI*fp\fR\fB);
+int nft_ctx_buffer_error(struct nft_ctx\fR \fI*ctx\fR\fB);
+int nft_ctx_unbuffer_error(struct nft_ctx\fR \fI*ctx\fR\fB);
+const char *nft_ctx_get_error_buffer(struct nft_ctx\fR \fI*ctx\fR\fB);
+
+int nft_ctx_add_include_path(struct nft_ctx\fR \fI*ctx\fR\fB, const char\fR \fI*path\fR\fB);
+void nft_ctx_clear_include_paths(struct nft_ctx\fR \fI*ctx\fR\fB);
+
+int nft_ctx_add_var(struct nft_ctx\fR \fI*ctx\fR\fB, const char\fR \fI*var\fR\fB);
+void nft_ctx_clear_vars(struct nft_ctx \fR\fB\fI\e*ctx\fR\fR);
+
+int nft_run_cmd_from_buffer(struct nft_ctx* \fI*nft\fR\fB, const char\fR \fI*buf\fR\fB);
+int nft_run_cmd_from_filename(struct nft_ctx\fR \fI*nft\fR\fB,
+ const char\fR \fI*filename\fR\fB);\fR
+
+Link with \fI\-lnftables\fR\&.
+.fi
+.SH "DESCRIPTION"
+.sp
+This library was designed with nftables integration into applications in mind\&. Its API is therefore kept as simple as possible, which somewhat limits its flexibility\&. Due to support for JSON markup of input and output though, convenience in constructing and parsing of input and output data may be achieved by using a third\-party library such as \fBlibjansson\fR\&.
+.sp
+At the very basic level, one has to allocate a new object of type \fBstruct nft_ctx\fR using \fBnft_ctx_new\fR() function, then pass commands via \fBnft_run_cmd_from_buffer\fR() or \fBnft_run_cmd_from_filename\fR() functions\&. By default, any output is written to \fBstdout\fR (or \fBstderr\fR for error messages)\&. These file pointers may be changed using \fBnft_ctx_set_output\fR() and \fBnft_ctx_set_error\fR() functions\&. On top of that, it is possible to have any output buffered by the library for later retrieval as a static buffer\&. See \fBnft_ctx_buffer_output\fR() and \fBnft_ctx_buffer_error\fR() functions for details\&.
+.SS "nft_ctx_new() and nft_ctx_free()"
+.sp
+These functions aid in nft context management\&. In order to make use of the library, at least one context object has to be allocated\&. The context holds temporary data such as caches, library configuration and (if enabled) output and error buffers\&.
+.sp
+The \fBnft_ctx_new\fR() function allocates and returns a new context object\&. The parameter \fIflags\fR is unused at this point and should be set to zero\&. For convenience, the macro \fBNFT_CTX_DEFAULT\fR is defined to that value\&.
+.sp
+The \fBnft_ctx_free\fR() function frees the context object pointed to by \fIctx\fR, including any caches or buffers it may hold\&.
+.SS "nft_ctx_get_dry_run() and nft_ctx_set_dry_run()"
+.sp
+Dry\-run setting controls whether ruleset changes are actually committed on kernel side or not\&. It allows one to check whether a given operation would succeed without making actual changes to the ruleset\&. The default setting is \fBfalse\fR\&.
+.sp
+The \fBnft_ctx_get_dry_run\fR() function returns the dry\-run setting\(cqs value contained in \fIctx\fR\&.
+.sp
+The \fBnft_ctx_set_dry_run\fR() function sets the dry\-run setting in \fIctx\fR to the value of \fIdry\fR\&.
+.SS "nft_ctx_input_get_flags() and nft_ctx_input_set_flags()"
+.sp
+The flags setting controls the input format\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+enum {
+ NFT_CTX_INPUT_NO_DNS = (1 << 0),
+ NFT_CTX_INPUT_JSON = (1 << 1),
+};
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+NFT_CTX_INPUT_NO_DNS
+.RS 4
+Avoid resolving IP addresses with blocking getaddrinfo()\&. In that case, only plain IP addresses are accepted\&.
+.RE
+.sp
+NFT_CTX_INPUT_JSON: When parsing the input, first try to interpret the input as JSON before falling back to the nftables format\&. This behavior is implied when setting the NFT_CTX_OUTPUT_JSON flag\&.
+.sp
+The \fBnft_ctx_input_get_flags\fR() function returns the input flags setting\(cqs value in \fIctx\fR\&.
+.sp
+The \fBnft_ctx_input_set_flags\fR() function sets the input flags setting in \fIctx\fR to the value of \fIval\fR and returns the previous flags\&.
+.SS "nft_ctx_output_get_flags() and nft_ctx_output_set_flags()"
+.sp
+The flags setting controls the output format\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+enum {
+ NFT_CTX_OUTPUT_REVERSEDNS = (1 << 0),
+ NFT_CTX_OUTPUT_SERVICE = (1 << 1),
+ NFT_CTX_OUTPUT_STATELESS = (1 << 2),
+ NFT_CTX_OUTPUT_HANDLE = (1 << 3),
+ NFT_CTX_OUTPUT_JSON = (1 << 4),
+ NFT_CTX_OUTPUT_ECHO = (1 << 5),
+ NFT_CTX_OUTPUT_GUID = (1 << 6),
+ NFT_CTX_OUTPUT_NUMERIC_PROTO = (1 << 7),
+ NFT_CTX_OUTPUT_NUMERIC_PRIO = (1 << 8),
+ NFT_CTX_OUTPUT_NUMERIC_SYMBOL = (1 << 9),
+ NFT_CTX_OUTPUT_NUMERIC_TIME = (1 << 10),
+ NFT_CTX_OUTPUT_NUMERIC_ALL = (NFT_CTX_OUTPUT_NUMERIC_PROTO |
+ NFT_CTX_OUTPUT_NUMERIC_PRIO |
+ NFT_CTX_OUTPUT_NUMERIC_SYMBOL |
+ NFT_CTX_OUTPUT_NUMERIC_TIME),
+ NFT_CTX_OUTPUT_TERSE = (1 << 11),
+};
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+NFT_CTX_OUTPUT_REVERSEDNS
+.RS 4
+Reverse DNS lookups are performed for IP addresses when printing\&. Note that this may add significant delay to
+\fBlist\fR
+commands depending on DNS resolver speed\&.
+.RE
+.PP
+NFT_CTX_OUTPUT_SERVICE
+.RS 4
+Print port numbers as services as described in the /etc/services file\&.
+.RE
+.PP
+NFT_CTX_OUTPUT_STATELESS
+.RS 4
+If stateless output has been requested, then stateful data is not printed\&. Stateful data refers to those objects that carry run\-time data, e\&.g\&. the
+\fBcounter\fR
+statement holds packet and byte counter values, making it stateful\&.
+.RE
+.PP
+NFT_CTX_OUTPUT_HANDLE
+.RS 4
+Upon insertion into the ruleset, some elements are assigned a unique handle for identification purposes\&. For example, when deleting a table or chain, it may be identified either by name or handle\&. Rules on the other hand must be deleted by handle, because there is no other way to uniquely identify them\&. This flag makes ruleset listings include handle values\&.
+.RE
+.PP
+NFT_CTX_OUTPUT_JSON
+.RS 4
+If enabled at compile\-time, libnftables accepts input in JSON format and is able to print output in JSON format as well\&. See
+\fBlibnftables\-json\fR(5) for a description of the supported schema\&. This flag enables JSON output format\&. If the flag is set, the input will first be tried as JSON format, before falling back to nftables format\&. This flag implies NFT_CTX_INPUT_JSON\&.
+.RE
+.PP
+NFT_CTX_OUTPUT_ECHO
+.RS 4
+The echo setting makes libnftables print the changes once they are committed to the kernel, just like a running instance of
+\fBnft monitor\fR
+would\&. Amongst other things, this allows one to retrieve an added rule\(cqs handle atomically\&.
+.RE
+.PP
+NFT_CTX_OUTPUT_GUID
+.RS 4
+Display UID and GID as described in the /etc/passwd and /etc/group files\&.
+.RE
+.PP
+NFT_CTX_OUTPUT_NUMERIC_PROTO
+.RS 4
+Display layer 4 protocol numerically\&.
+.RE
+.PP
+NFT_CTX_OUTPUT_NUMERIC_PRIO
+.RS 4
+Display base chain priority numerically\&.
+.RE
+.PP
+NFT_CTX_OUTPUT_NUMERIC_SYMBOL
+.RS 4
+Display expression datatype as numeric value\&.
+.RE
+.PP
+NFT_CTX_OUTPUT_NUMERIC_TIME
+.RS 4
+Display time, day and hour values in numeric format\&.
+.RE
+.PP
+NFT_CTX_OUTPUT_NUMERIC_ALL
+.RS 4
+Display all numerically\&.
+.RE
+.PP
+NFT_CTX_OUTPUT_TERSE
+.RS 4
+If terse output has been requested, then the contents of sets are not printed\&.
+.RE
+.sp
+The \fBnft_ctx_output_get_flags\fR() function returns the output flags setting\(cqs value in \fIctx\fR\&.
+.sp
+The \fBnft_ctx_output_set_flags\fR() function sets the output flags setting in \fIctx\fR to the value of \fIval\fR\&.
+.SS "nft_ctx_output_get_debug() and nft_ctx_output_set_debug()"
+.sp
+Libnftables supports separate debugging of different parts of its internals\&. To facilitate this, debugging output is controlled via a bit mask\&. The bits are defined as such:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+enum nft_debug_level {
+ NFT_DEBUG_SCANNER = 0x1,
+ NFT_DEBUG_PARSER = 0x2,
+ NFT_DEBUG_EVALUATION = 0x4,
+ NFT_DEBUG_NETLINK = 0x8,
+ NFT_DEBUG_MNL = 0x10,
+ NFT_DEBUG_PROTO_CTX = 0x20,
+ NFT_DEBUG_SEGTREE = 0x40,
+};
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+NFT_DEBUG_SCANNER
+.RS 4
+Print LEX debug output\&.
+.RE
+.PP
+NFT_DEBUG_PARSER
+.RS 4
+Print YACC debug output\&.
+.RE
+.PP
+NFT_DEBUG_EVALUATION
+.RS 4
+Print debug information about evaluation phase\&.
+.RE
+.PP
+NFT_DEBUG_NETLINK
+.RS 4
+Print netlink debug output\&.
+.RE
+.PP
+NFT_DEBUG_MNL
+.RS 4
+Print libmnl debug output\&.
+.RE
+.PP
+NFT_DEBUG_PROTO_CTX
+.RS 4
+Print protocol context debug output\&.
+.RE
+.PP
+NFT_DEBUG_SEGTREE
+.RS 4
+Print segtree (i\&.e\&. interval sets) debug output\&.
+.RE
+.sp
+The \fBnft_ctx_output_get_debug\fR() function returns the debug output setting\(cqs value in \fIctx\fR\&.
+.sp
+The \fBnft_ctx_output_set_debug\fR() function sets the debug output setting in \fIctx\fR to the value of \fImask\fR\&.
+.SS "Controlling library standard and error output"
+.sp
+By default, any output from the library (e\&.g\&., after a \fBlist\fR command) is written to \fIstdout\fR and any error messages are written to \fIstderr\fR\&. To give applications control over them, there are functions to assign custom file pointers as well as having the library buffer what would be written for later retrieval in a static buffer\&. This buffer is guaranteed to be null\-terminated and must not be freed\&. Note that the retrieval functions rewind the buffer position indicator\&. Further library output will probably overwrite the buffer content and potentially render it invalid (due to reallocation)\&.
+.sp
+The \fBnft_ctx_set_output\fR() and \fBnft_ctx_set_error\fR() functions set the output or error file pointer in \fIctx\fR to the value of \fIfp\fR\&. They return the previous value to aid in temporary file pointer overrides\&. On error, these functions return NULL\&. This happens only if \fIfp\fR is NULL or invalid (tested using \fBferror\fR() function)\&.
+.sp
+The \fBnft_ctx_buffer_output\fR() and \fBnft_ctx_buffer_error\fR() functions enable library standard or error output buffering\&. The functions return zero on success, non\-zero otherwise\&. This may happen if the internal call to \fBfopencookie\fR() failed\&.
+.sp
+The \fBnft_ctx_unbuffer_output\fR() and \fBnft_ctx_unbuffer_error\fR() functions disable library standard or error output buffering\&. On failure, the functions return non\-zero which may only happen if buffering was not enabled at the time the function was called\&.
+.sp
+The \fBnft_ctx_get_output_buffer\fR() and \fBnft_ctx_get_error_buffer\fR() functions return a pointer to the buffered output (which may be empty)\&.
+.SS "nft_ctx_add_include_path() and nft_ctx_clear_include_path()"
+.sp
+The \fBinclude\fR command in nftables rulesets allows one to outsource parts of the ruleset into a different file\&. The include path defines where these files are searched for\&. Libnftables allows one to have a list of those paths which are searched in order\&. The default include path list contains a single compile\-time defined entry (typically \fI/etc/\fR)\&.
+.sp
+The \fBnft_ctx_add_include_path\fR() function extends the list of include paths in \fIctx\fR by the one given in \fIpath\fR\&. The function returns zero on success or non\-zero if memory allocation failed\&.
+.sp
+The \fBnft_ctx_clear_include_paths\fR() function removes all include paths, even the built\-in default one\&.
+.SS "nft_ctx_add_var() and nft_ctx_clear_vars()"
+.sp
+The \fBdefine\fR command in nftables ruleset allows one to define variables\&.
+.sp
+The \fBnft_ctx_add_var\fR() function extends the list of variables in \fIctx\fR\&. The variable must be given in the format \fIkey=value\fR\&. The function returns zero on success or non\-zero if the variable is malformed\&.
+.sp
+The \fBnft_ctx_clear_vars\fR() function removes all variables\&.
+.SS "nft_run_cmd_from_buffer() and nft_run_cmd_from_filename()"
+.sp
+These functions perform the actual work of parsing user input into nftables commands and executing them\&.
+.sp
+The \fBnft_run_cmd_from_buffer\fR() function passes the command(s) contained in \fIbuf\fR (which must be null\-terminated) to the library, respecting settings and state in \fInft\fR\&.
+.sp
+The \fBnft_run_cmd_from_filename\fR() function passes the content of \fIfilename\fR to the library, respecting settings and state in \fInft\fR\&.
+.sp
+Both functions return zero on success\&. A non\-zero return code indicates an error while parsing or executing the command\&. This event should be accompanied by an error message written to library error output\&.
+.SH "EXAMPLE"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+#include <stdio\&.h>
+#include <string\&.h>
+#include <nftables/libnftables\&.h>
+
+int main(void)
+{
+ char *list_cmd = "list ruleset";
+ struct nft_ctx *nft;
+ const char *output, *p;
+ char buf[256];
+ int rc = 0;
+
+ nft = nft_ctx_new(NFT_CTX_DEFAULT);
+ if (!nft)
+ return 1;
+
+ while (1) {
+ if (nft_ctx_buffer_output(nft) ||
+ nft_run_cmd_from_buffer(nft, list_cmd)) {
+ rc = 1;
+ break;
+ }
+ output = nft_ctx_get_output_buffer(nft);
+ if (strlen(output)) {
+ printf("\enThis is the current ruleset:\en| ");
+ for (p = output; *(p + 1); p++) {
+ if (*p == \*(Aq\en\*(Aq)
+ printf("\en| ");
+ else
+ putchar(*p);
+ }
+ putchar(\*(Aq\en\*(Aq);
+ } else {
+ printf("\enCurrent ruleset is empty\&.\en");
+ }
+ nft_ctx_unbuffer_output(nft);
+
+ printf("\enEnter command (\*(Aqq\*(Aq to quit): ");
+ fflush(stdout);
+ fgets(buf, 256, stdin);
+ if (strlen(buf))
+ buf[strlen(buf) \- 1] = \*(Aq\e0\*(Aq;
+
+ if (buf[0] == \*(Aqq\*(Aq && buf[1] == \*(Aq\e0\*(Aq)
+ break;
+
+ if (nft_run_cmd_from_buffer(nft, buf)) {
+ rc = 1;
+ break;
+ }
+ }
+
+ nft_ctx_free(nft);
+ return rc;
+}
+.fi
+.if n \{\
+.RE
+.\}
+.SH "SEE ALSO"
+.sp
+\fBlibnftables\-json\fR(5), \fBnft\fR(8)
+.SH "AUTHOR"
+.PP
+\fBPhil Sutter\fR <\&phil@nwl\&.cc\&>
+.RS 4
+Author.
+.RE
diff --git a/doc/libnftables.adoc b/doc/libnftables.adoc
new file mode 100644
index 0000000..2cf78d7
--- /dev/null
+++ b/doc/libnftables.adoc
@@ -0,0 +1,319 @@
+libnftables(3)
+==============
+Phil Sutter <phil@nwl.cc>
+:doctype: manpage
+:compat-mode!:
+
+== NAME
+libnftables - nftables frontend library
+
+== SYNOPSIS
+[verse]
+____
+*#include <nftables/libnftables.h>
+
+struct nft_ctx *nft_ctx_new(uint32_t* 'flags'*);
+void nft_ctx_free(struct nft_ctx* '\*ctx'*);
+
+bool nft_ctx_get_dry_run(struct nft_ctx* '\*ctx'*);
+void nft_ctx_set_dry_run(struct nft_ctx* '\*ctx'*, bool* 'dry'*);
+
+unsigned int nft_ctx_input_get_flags(struct nft_ctx* '\*ctx'*);
+unsigned int nft_ctx_input_set_flags(struct nft_ctx* '\*ctx'*, unsigned int* 'flags'*);
+
+unsigned int nft_ctx_output_get_flags(struct nft_ctx* '\*ctx'*);
+void nft_ctx_output_set_flags(struct nft_ctx* '\*ctx'*, unsigned int* 'flags'*);
+
+unsigned int nft_ctx_output_get_debug(struct nft_ctx* '\*ctx'*);
+void nft_ctx_output_set_debug(struct nft_ctx* '\*ctx'*, unsigned int* 'mask'*);
+
+FILE *nft_ctx_set_output(struct nft_ctx* '\*ctx'*, FILE* '\*fp'*);
+int nft_ctx_buffer_output(struct nft_ctx* '\*ctx'*);
+int nft_ctx_unbuffer_output(struct nft_ctx* '\*ctx'*);
+const char *nft_ctx_get_output_buffer(struct nft_ctx* '\*ctx'*);
+
+FILE *nft_ctx_set_error(struct nft_ctx* '\*ctx'*, FILE* '\*fp'*);
+int nft_ctx_buffer_error(struct nft_ctx* '\*ctx'*);
+int nft_ctx_unbuffer_error(struct nft_ctx* '\*ctx'*);
+const char *nft_ctx_get_error_buffer(struct nft_ctx* '\*ctx'*);
+
+int nft_ctx_add_include_path(struct nft_ctx* '\*ctx'*, const char* '\*path'*);
+void nft_ctx_clear_include_paths(struct nft_ctx* '\*ctx'*);
+
+int nft_ctx_add_var(struct nft_ctx* '\*ctx'*, const char* '\*var'*);
+void nft_ctx_clear_vars(struct nft_ctx '\*ctx'*);
+
+int nft_run_cmd_from_buffer(struct nft_ctx* '\*nft'*, const char* '\*buf'*);
+int nft_run_cmd_from_filename(struct nft_ctx* '\*nft'*,
+ const char* '\*filename'*);*
+
+Link with '-lnftables'.
+____
+
+== DESCRIPTION
+This library was designed with nftables integration into applications in mind.
+Its API is therefore kept as simple as possible, which somewhat limits its flexibility.
+Due to support for JSON markup of input and output though, convenience in constructing and parsing of input and output data may be achieved by using a third-party library such as *libjansson*.
+
+At the very basic level, one has to allocate a new object of type *struct nft_ctx* using *nft_ctx_new*() function, then pass commands via *nft_run_cmd_from_buffer*() or *nft_run_cmd_from_filename*() functions.
+By default, any output is written to *stdout* (or *stderr* for error messages).
+These file pointers may be changed using *nft_ctx_set_output*() and *nft_ctx_set_error*() functions.
+On top of that, it is possible to have any output buffered by the library for later retrieval as a static buffer.
+See *nft_ctx_buffer_output*() and *nft_ctx_buffer_error*() functions for details.
+
+=== nft_ctx_new() and nft_ctx_free()
+These functions aid in nft context management.
+In order to make use of the library, at least one context object has to be allocated.
+The context holds temporary data such as caches, library configuration and (if enabled) output and error buffers.
+
+The *nft_ctx_new*() function allocates and returns a new context object.
+The parameter 'flags' is unused at this point and should be set to zero.
+For convenience, the macro *NFT_CTX_DEFAULT* is defined to that value.
+
+The *nft_ctx_free*() function frees the context object pointed to by 'ctx', including any caches or buffers it may hold.
+
+=== nft_ctx_get_dry_run() and nft_ctx_set_dry_run()
+Dry-run setting controls whether ruleset changes are actually committed on kernel side or not.
+It allows one to check whether a given operation would succeed without making actual changes to the ruleset.
+The default setting is *false*.
+
+The *nft_ctx_get_dry_run*() function returns the dry-run setting's value contained in 'ctx'.
+
+The *nft_ctx_set_dry_run*() function sets the dry-run setting in 'ctx' to the value of 'dry'.
+
+=== nft_ctx_input_get_flags() and nft_ctx_input_set_flags()
+The flags setting controls the input format.
+
+----
+enum {
+ NFT_CTX_INPUT_NO_DNS = (1 << 0),
+ NFT_CTX_INPUT_JSON = (1 << 1),
+};
+----
+
+NFT_CTX_INPUT_NO_DNS::
+ Avoid resolving IP addresses with blocking getaddrinfo(). In that case,
+ only plain IP addresses are accepted.
+
+NFT_CTX_INPUT_JSON:
+ When parsing the input, first try to interpret the input as JSON before
+ falling back to the nftables format. This behavior is implied when setting
+ the NFT_CTX_OUTPUT_JSON flag.
+
+The *nft_ctx_input_get_flags*() function returns the input flags setting's value in 'ctx'.
+
+The *nft_ctx_input_set_flags*() function sets the input flags setting in 'ctx' to the value of 'val'
+and returns the previous flags.
+
+=== nft_ctx_output_get_flags() and nft_ctx_output_set_flags()
+The flags setting controls the output format.
+
+----
+enum {
+ NFT_CTX_OUTPUT_REVERSEDNS = (1 << 0),
+ NFT_CTX_OUTPUT_SERVICE = (1 << 1),
+ NFT_CTX_OUTPUT_STATELESS = (1 << 2),
+ NFT_CTX_OUTPUT_HANDLE = (1 << 3),
+ NFT_CTX_OUTPUT_JSON = (1 << 4),
+ NFT_CTX_OUTPUT_ECHO = (1 << 5),
+ NFT_CTX_OUTPUT_GUID = (1 << 6),
+ NFT_CTX_OUTPUT_NUMERIC_PROTO = (1 << 7),
+ NFT_CTX_OUTPUT_NUMERIC_PRIO = (1 << 8),
+ NFT_CTX_OUTPUT_NUMERIC_SYMBOL = (1 << 9),
+ NFT_CTX_OUTPUT_NUMERIC_TIME = (1 << 10),
+ NFT_CTX_OUTPUT_NUMERIC_ALL = (NFT_CTX_OUTPUT_NUMERIC_PROTO |
+ NFT_CTX_OUTPUT_NUMERIC_PRIO |
+ NFT_CTX_OUTPUT_NUMERIC_SYMBOL |
+ NFT_CTX_OUTPUT_NUMERIC_TIME),
+ NFT_CTX_OUTPUT_TERSE = (1 << 11),
+};
+----
+
+NFT_CTX_OUTPUT_REVERSEDNS::
+ Reverse DNS lookups are performed for IP addresses when printing.
+ Note that this may add significant delay to *list* commands depending on DNS resolver speed.
+NFT_CTX_OUTPUT_SERVICE::
+ Print port numbers as services as described in the /etc/services file.
+NFT_CTX_OUTPUT_STATELESS::
+ If stateless output has been requested, then stateful data is not printed.
+ Stateful data refers to those objects that carry run-time data, e.g. the *counter* statement holds packet and byte counter values, making it stateful.
+NFT_CTX_OUTPUT_HANDLE::
+ Upon insertion into the ruleset, some elements are assigned a unique handle for identification purposes.
+ For example, when deleting a table or chain, it may be identified either by name or handle.
+ Rules on the other hand must be deleted by handle, because there is no other way to uniquely identify them.
+ This flag makes ruleset listings include handle values.
+NFT_CTX_OUTPUT_JSON::
+ If enabled at compile-time, libnftables accepts input in JSON format and is able to print output in JSON format as well.
+ See *libnftables-json*(5) for a description of the supported schema.
+ This flag enables JSON output format. If the flag is set, the input will first be tried as JSON format,
+ before falling back to nftables format. This flag implies NFT_CTX_INPUT_JSON.
+NFT_CTX_OUTPUT_ECHO::
+ The echo setting makes libnftables print the changes once they are committed to the kernel, just like a running instance of *nft monitor* would.
+ Amongst other things, this allows one to retrieve an added rule's handle atomically.
+NFT_CTX_OUTPUT_GUID::
+ Display UID and GID as described in the /etc/passwd and /etc/group files.
+NFT_CTX_OUTPUT_NUMERIC_PROTO::
+ Display layer 4 protocol numerically.
+NFT_CTX_OUTPUT_NUMERIC_PRIO::
+ Display base chain priority numerically.
+NFT_CTX_OUTPUT_NUMERIC_SYMBOL::
+ Display expression datatype as numeric value.
+NFT_CTX_OUTPUT_NUMERIC_TIME::
+ Display time, day and hour values in numeric format.
+NFT_CTX_OUTPUT_NUMERIC_ALL::
+ Display all numerically.
+NFT_CTX_OUTPUT_TERSE::
+ If terse output has been requested, then the contents of sets are not printed.
+
+The *nft_ctx_output_get_flags*() function returns the output flags setting's value in 'ctx'.
+
+The *nft_ctx_output_set_flags*() function sets the output flags setting in 'ctx' to the value of 'val'.
+
+=== nft_ctx_output_get_debug() and nft_ctx_output_set_debug()
+Libnftables supports separate debugging of different parts of its internals.
+To facilitate this, debugging output is controlled via a bit mask.
+The bits are defined as such:
+
+----
+enum nft_debug_level {
+ NFT_DEBUG_SCANNER = 0x1,
+ NFT_DEBUG_PARSER = 0x2,
+ NFT_DEBUG_EVALUATION = 0x4,
+ NFT_DEBUG_NETLINK = 0x8,
+ NFT_DEBUG_MNL = 0x10,
+ NFT_DEBUG_PROTO_CTX = 0x20,
+ NFT_DEBUG_SEGTREE = 0x40,
+};
+----
+
+NFT_DEBUG_SCANNER::
+ Print LEX debug output.
+NFT_DEBUG_PARSER::
+ Print YACC debug output.
+NFT_DEBUG_EVALUATION::
+ Print debug information about evaluation phase.
+NFT_DEBUG_NETLINK::
+ Print netlink debug output.
+NFT_DEBUG_MNL::
+ Print libmnl debug output.
+NFT_DEBUG_PROTO_CTX::
+ Print protocol context debug output.
+NFT_DEBUG_SEGTREE::
+ Print segtree (i.e. interval sets) debug output.
+
+The *nft_ctx_output_get_debug*() function returns the debug output setting's value in 'ctx'.
+
+The *nft_ctx_output_set_debug*() function sets the debug output setting in 'ctx' to the value of 'mask'.
+
+=== Controlling library standard and error output
+By default, any output from the library (e.g., after a *list* command) is written to 'stdout' and any error messages are written to 'stderr'.
+To give applications control over them, there are functions to assign custom file pointers as well as having the library buffer what would be written for later retrieval in a static buffer.
+This buffer is guaranteed to be null-terminated and must not be freed.
+Note that the retrieval functions rewind the buffer position indicator.
+Further library output will probably overwrite the buffer content and potentially render it invalid (due to reallocation).
+
+The *nft_ctx_set_output*() and *nft_ctx_set_error*() functions set the output or error file pointer in 'ctx' to the value of 'fp'.
+They return the previous value to aid in temporary file pointer overrides.
+On error, these functions return NULL.
+This happens only if 'fp' is NULL or invalid (tested using *ferror*() function).
+
+The *nft_ctx_buffer_output*() and *nft_ctx_buffer_error*() functions enable library standard or error output buffering.
+The functions return zero on success, non-zero otherwise.
+This may happen if the internal call to *fopencookie*() failed.
+
+The *nft_ctx_unbuffer_output*() and *nft_ctx_unbuffer_error*() functions disable library standard or error output buffering.
+On failure, the functions return non-zero which may only happen if buffering was not enabled at the time the function was called.
+
+The *nft_ctx_get_output_buffer*() and *nft_ctx_get_error_buffer*() functions return a pointer to the buffered output (which may be empty).
+
+=== nft_ctx_add_include_path() and nft_ctx_clear_include_path()
+The *include* command in nftables rulesets allows one to outsource parts of the ruleset into a different file.
+The include path defines where these files are searched for.
+Libnftables allows one to have a list of those paths which are searched in order.
+The default include path list contains a single compile-time defined entry (typically '/etc/').
+
+The *nft_ctx_add_include_path*() function extends the list of include paths in 'ctx' by the one given in 'path'.
+The function returns zero on success or non-zero if memory allocation failed.
+
+The *nft_ctx_clear_include_paths*() function removes all include paths, even the built-in default one.
+
+=== nft_ctx_add_var() and nft_ctx_clear_vars()
+The *define* command in nftables ruleset allows one to define variables.
+
+The *nft_ctx_add_var*() function extends the list of variables in 'ctx'. The variable must be given in the format 'key=value'.
+The function returns zero on success or non-zero if the variable is malformed.
+
+The *nft_ctx_clear_vars*() function removes all variables.
+
+=== nft_run_cmd_from_buffer() and nft_run_cmd_from_filename()
+These functions perform the actual work of parsing user input into nftables commands and executing them.
+
+The *nft_run_cmd_from_buffer*() function passes the command(s) contained in 'buf' (which must be null-terminated) to the library, respecting settings and state in 'nft'.
+
+The *nft_run_cmd_from_filename*() function passes the content of 'filename' to the library, respecting settings and state in 'nft'.
+
+Both functions return zero on success.
+A non-zero return code indicates an error while parsing or executing the command.
+This event should be accompanied by an error message written to library error output.
+
+== EXAMPLE
+----
+#include <stdio.h>
+#include <string.h>
+#include <nftables/libnftables.h>
+
+int main(void)
+{
+ char *list_cmd = "list ruleset";
+ struct nft_ctx *nft;
+ const char *output, *p;
+ char buf[256];
+ int rc = 0;
+
+ nft = nft_ctx_new(NFT_CTX_DEFAULT);
+ if (!nft)
+ return 1;
+
+ while (1) {
+ if (nft_ctx_buffer_output(nft) ||
+ nft_run_cmd_from_buffer(nft, list_cmd)) {
+ rc = 1;
+ break;
+ }
+ output = nft_ctx_get_output_buffer(nft);
+ if (strlen(output)) {
+ printf("\nThis is the current ruleset:\n| ");
+ for (p = output; *(p + 1); p++) {
+ if (*p == '\n')
+ printf("\n| ");
+ else
+ putchar(*p);
+ }
+ putchar('\n');
+ } else {
+ printf("\nCurrent ruleset is empty.\n");
+ }
+ nft_ctx_unbuffer_output(nft);
+
+ printf("\nEnter command ('q' to quit): ");
+ fflush(stdout);
+ fgets(buf, 256, stdin);
+ if (strlen(buf))
+ buf[strlen(buf) - 1] = '\0';
+
+ if (buf[0] == 'q' && buf[1] == '\0')
+ break;
+
+ if (nft_run_cmd_from_buffer(nft, buf)) {
+ rc = 1;
+ break;
+ }
+ }
+
+ nft_ctx_free(nft);
+ return rc;
+}
+----
+
+== SEE ALSO
+*libnftables-json*(5), *nft*(8)
diff --git a/doc/nft.8 b/doc/nft.8
new file mode 100644
index 0000000..4e914fb
--- /dev/null
+++ b/doc/nft.8
@@ -0,0 +1,9717 @@
+'\" t
+.\" Title: nft
+.\" Author: [see the "AUTHORS" section]
+.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
+.\" Date: 10/11/2023
+.\" Manual: \ \&
+.\" Source: \ \&
+.\" Language: English
+.\"
+.TH "NFT" "8" "10/11/2023" "\ \&" "\ \&"
+.\" -----------------------------------------------------------------
+.\" * Define some portability stuff
+.\" -----------------------------------------------------------------
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.\" http://bugs.debian.org/507673
+.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.\" -----------------------------------------------------------------
+.\" * MAIN CONTENT STARTS HERE *
+.\" -----------------------------------------------------------------
+.SH "NAME"
+nft \- Administration tool of the nftables framework for packet filtering and classification
+.SH "SYNOPSIS"
+.sp
+.nf
+\fBnft\fR [ \fB\-nNscaeSupyjtT\fR ] [ \fB\-I\fR \fIdirectory\fR ] [ \fB\-f\fR \fIfilename\fR | \fB\-i\fR | \fIcmd\fR \&...]
+\fBnft\fR \fB\-h\fR
+\fBnft\fR \fB\-v\fR
+.fi
+.SH "DESCRIPTION"
+.sp
+nft is the command line tool used to set up, maintain and inspect packet filtering and classification rules in the Linux kernel, in the nftables framework\&. The Linux kernel subsystem is known as nf_tables, and \(oqnf\(cq stands for Netfilter\&.
+.SH "OPTIONS"
+.sp
+The command accepts several different options which are documented here in groups for better understanding of their meaning\&. You can get information about options by running \fBnft \-\-help\fR\&.
+.PP
+\fBGeneral options:\fR
+.PP
+\fB\-h\fR, \fB\-\-help\fR
+.RS 4
+Show help message and all options\&.
+.RE
+.PP
+\fB\-v\fR, \fB\-\-version\fR
+.RS 4
+Show version\&.
+.RE
+.PP
+\fB\-V\fR
+.RS 4
+Show long version information, including compile\-time configuration\&.
+.RE
+.PP
+\fBRuleset input handling options that specify to how to load rulesets:\fR
+.PP
+\fB\-f\fR, \fB\-\-file \fR\fB\fIfilename\fR\fR
+.RS 4
+Read input from
+\fIfilename\fR\&. If
+\fIfilename\fR
+is \-, read from stdin\&.
+.RE
+.PP
+\fB\-D\fR, \fB\-\-define \fR\fB\fIname=value\fR\fR
+.RS 4
+Define a variable\&. You can only combine this option with
+\fI\-f\fR\&.
+.RE
+.PP
+\fB\-i\fR, \fB\-\-interactive\fR
+.RS 4
+Read input from an interactive readline CLI\&. You can use quit to exit, or use the EOF marker, normally this is CTRL\-D\&.
+.RE
+.PP
+\fB\-I\fR, \fB\-\-includepath directory\fR
+.RS 4
+Add the directory
+\fIdirectory\fR
+to the list of directories to be searched for included files\&. This option may be specified multiple times\&.
+.RE
+.PP
+\fB\-c\fR, \fB\-\-check\fR
+.RS 4
+Check commands validity without actually applying the changes\&.
+.RE
+.PP
+\fB\-o\fR, \fB\-\-optimize\fR
+.RS 4
+Optimize your ruleset\&. You can combine this option with
+\fI\-c\fR
+to inspect the proposed optimizations\&.
+.RE
+.PP
+\fBRuleset list output formatting that modify the output of the list ruleset command:\fR
+.PP
+\fB\-a\fR, \fB\-\-handle\fR
+.RS 4
+Show object handles in output\&.
+.RE
+.PP
+\fB\-s\fR, \fB\-\-stateless\fR
+.RS 4
+Omit stateful information of rules and stateful objects\&.
+.RE
+.PP
+\fB\-t\fR, \fB\-\-terse\fR
+.RS 4
+Omit contents of sets from output\&.
+.RE
+.PP
+\fB\-S\fR, \fB\-\-service\fR
+.RS 4
+Translate ports to service names as defined by /etc/services\&.
+.RE
+.PP
+\fB\-N\fR, \fB\-\-reversedns\fR
+.RS 4
+Translate IP address to names via reverse DNS lookup\&. This may slow down your listing since it generates network traffic\&.
+.RE
+.PP
+\fB\-u\fR, \fB\-\-guid\fR
+.RS 4
+Translate numeric UID/GID to names as defined by /etc/passwd and /etc/group\&.
+.RE
+.PP
+\fB\-n\fR, \fB\-\-numeric\fR
+.RS 4
+Print fully numerical output\&.
+.RE
+.PP
+\fB\-y\fR, \fB\-\-numeric\-priority\fR
+.RS 4
+Display base chain priority numerically\&.
+.RE
+.PP
+\fB\-p\fR, \fB\-\-numeric\-protocol\fR
+.RS 4
+Display layer 4 protocol numerically\&.
+.RE
+.PP
+\fB\-T\fR, \fB\-\-numeric\-time\fR
+.RS 4
+Show time, day and hour values in numeric format\&.
+.RE
+.PP
+\fBCommand output formatting:\fR
+.PP
+\fB\-e\fR, \fB\-\-echo\fR
+.RS 4
+When inserting items into the ruleset using
+\fBadd\fR,
+\fBinsert\fR
+or
+\fBreplace\fR
+commands, print notifications just like
+\fBnft monitor\fR\&.
+.RE
+.PP
+\fB\-j\fR, \fB\-\-json\fR
+.RS 4
+Format output in JSON\&. See libnftables\-json(5) for a schema description\&.
+.RE
+.PP
+\fB\-d\fR, \fB\-\-debug\fR \fIlevel\fR
+.RS 4
+Enable debugging output\&. The debug level can be any of
+\fBscanner\fR,
+\fBparser\fR,
+\fBeval\fR,
+\fBnetlink\fR,
+\fBmnl\fR,
+\fBproto\-ctx\fR,
+\fBsegtree\fR,
+\fBall\fR\&. You can combine more than one by separating by the
+\fI,\fR
+symbol, for example
+\fI\-d eval,mnl\fR\&.
+.RE
+.SH "INPUT FILE FORMATS"
+.SS "LEXICAL CONVENTIONS"
+.sp
+Input is parsed line\-wise\&. When the last character of a line, just before the newline character, is a non\-quoted backslash (\e), the next line is treated as a continuation\&. Multiple commands on the same line can be separated using a semicolon (;)\&.
+.sp
+A hash sign (#) begins a comment\&. All following characters on the same line are ignored\&.
+.sp
+Identifiers begin with an alphabetic character (a\-z,A\-Z), followed by zero or more alphanumeric characters (a\-z,A\-Z,0\-9) and the characters slash (/), backslash (\e), underscore (_) and dot (\&.)\&. Identifiers using different characters or clashing with a keyword need to be enclosed in double quotes (")\&.
+.SS "INCLUDE FILES"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBinclude\fR \fIfilename\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Other files can be included by using the \fBinclude\fR statement\&. The directories to be searched for include files can be specified using the \fB\-I\fR/\fB\-\-includepath\fR option\&. You can override this behaviour either by prepending \(oq\&./\(cq to your path to force inclusion of files located in the current working directory (i\&.e\&. relative path) or / for file location expressed as an absolute path\&.
+.sp
+If \fB\-I\fR/\fB\-\-includepath\fR is not specified, then nft relies on the default directory that is specified at compile time\&. You can retrieve this default directory via the \fB\-h\fR/\fB\-\-help\fR option\&.
+.sp
+Include statements support the usual shell wildcard symbols (\fB,?,[])\&. Having no matches for an include statement is not an error, if wildcard symbols are used in the include statement\&. This allows having potentially empty include directories for statements like \fR\fB\fBinclude "/etc/firewall/rules/\fR\fR\fB"\fR\&. The wildcard matches are loaded in alphabetical order\&. Files beginning with dot (\&.) are not matched by include statements\&.
+.SS "SYMBOLIC VARIABLES"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBdefine\fR \fIvariable\fR \fB=\fR \fIexpr\fR
+\fBundefine\fR \fIvariable\fR
+\fBredefine\fR \fIvariable\fR \fB=\fR \fIexpr\fR
+\fB$variable\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Symbolic variables can be defined using the \fBdefine\fR statement\&. Variable references are expressions and can be used to initialize other variables\&. The scope of a definition is the current block and all blocks contained within\&. Symbolic variables can be undefined using the \fBundefine\fR statement, and modified using the \fBredefine\fR statement\&.
+.PP
+\fBUsing symbolic variables\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+define int_if1 = eth0
+define int_if2 = eth1
+define int_ifs = { $int_if1, $int_if2 }
+redefine int_if2 = wlan0
+undefine int_if2
+
+filter input iif $int_ifs accept
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SH "ADDRESS FAMILIES"
+.sp
+Address families determine the type of packets which are processed\&. For each address family, the kernel contains so called hooks at specific stages of the packet processing paths, which invoke nftables if rules for these hooks exist\&.
+.TS
+tab(:);
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+\fBip\fR
+T}:T{
+.sp
+IPv4 address family\&.
+T}
+T{
+.sp
+\fBip6\fR
+T}:T{
+.sp
+IPv6 address family\&.
+T}
+T{
+.sp
+\fBinet\fR
+T}:T{
+.sp
+Internet (IPv4/IPv6) address family\&.
+T}
+T{
+.sp
+\fBarp\fR
+T}:T{
+.sp
+ARP address family, handling IPv4 ARP packets\&.
+T}
+T{
+.sp
+\fBbridge\fR
+T}:T{
+.sp
+Bridge address family, handling packets which traverse a bridge device\&.
+T}
+T{
+.sp
+\fBnetdev\fR
+T}:T{
+.sp
+Netdev address family, handling packets on ingress and egress\&.
+T}
+.TE
+.sp 1
+.sp
+All nftables objects exist in address family specific namespaces, therefore all identifiers include an address family\&. If an identifier is specified without an address family, the \fBip\fR family is used by default\&.
+.SS "IPV4/IPV6/INET ADDRESS FAMILIES"
+.sp
+The IPv4/IPv6/Inet address families handle IPv4, IPv6 or both types of packets\&. They contain five hooks at different packet processing stages in the network stack\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&1.\ \&IPv4/IPv6/Inet address family hooks
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Hook
+T}:T{
+Description
+T}
+.T&
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+prerouting
+T}:T{
+.sp
+All packets entering the system are processed by the prerouting hook\&. It is invoked before the routing process and is used for early filtering or changing packet attributes that affect routing\&.
+T}
+T{
+.sp
+input
+T}:T{
+.sp
+Packets delivered to the local system are processed by the input hook\&.
+T}
+T{
+.sp
+forward
+T}:T{
+.sp
+Packets forwarded to a different host are processed by the forward hook\&.
+T}
+T{
+.sp
+output
+T}:T{
+.sp
+Packets sent by local processes are processed by the output hook\&.
+T}
+T{
+.sp
+postrouting
+T}:T{
+.sp
+All packets leaving the system are processed by the postrouting hook\&.
+T}
+T{
+.sp
+ingress
+T}:T{
+.sp
+All packets entering the system are processed by this hook\&. It is invoked before layer 3 protocol handlers, hence before the prerouting hook, and it can be used for filtering and policing\&. Ingress is only available for Inet family (since Linux kernel 5\&.10)\&.
+T}
+.TE
+.sp 1
+.SS "ARP ADDRESS FAMILY"
+.sp
+The ARP address family handles ARP packets received and sent by the system\&. It is commonly used to mangle ARP packets for clustering\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&2.\ \&ARP address family hooks
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Hook
+T}:T{
+Description
+T}
+.T&
+lt lt
+lt lt.
+T{
+.sp
+input
+T}:T{
+.sp
+Packets delivered to the local system are processed by the input hook\&.
+T}
+T{
+.sp
+output
+T}:T{
+.sp
+Packets send by the local system are processed by the output hook\&.
+T}
+.TE
+.sp 1
+.SS "BRIDGE ADDRESS FAMILY"
+.sp
+The bridge address family handles Ethernet packets traversing bridge devices\&.
+.sp
+The list of supported hooks is identical to IPv4/IPv6/Inet address families above\&.
+.SS "NETDEV ADDRESS FAMILY"
+.sp
+The Netdev address family handles packets from the device ingress and egress path\&. This family allows you to filter packets of any ethertype such as ARP, VLAN 802\&.1q, VLAN 802\&.1ad (Q\-in\-Q) as well as IPv4 and IPv6 packets\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&3.\ \&Netdev address family hooks
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Hook
+T}:T{
+Description
+T}
+.T&
+lt lt
+lt lt.
+T{
+.sp
+ingress
+T}:T{
+.sp
+All packets entering the system are processed by this hook\&. It is invoked after the network taps (ie\&. \fBtcpdump\fR), right after \fBtc\fR ingress and before layer 3 protocol handlers, it can be used for early filtering and policing\&.
+T}
+T{
+.sp
+egress
+T}:T{
+.sp
+All packets leaving the system are processed by this hook\&. It is invoked after layer 3 protocol handlers and before \fBtc\fR egress\&. It can be used for late filtering and policing\&.
+T}
+.TE
+.sp 1
+.sp
+Tunneled packets (such as \fBvxlan\fR) are processed by netdev family hooks both in decapsulated and encapsulated (tunneled) form\&. So a packet can be filtered on the overlay network as well as on the underlying network\&.
+.sp
+Note that the order of netfilter and \fBtc\fR is mirrored on ingress versus egress\&. This ensures symmetry for NAT and other packet mangling\&.
+.sp
+Ingress packets which are redirected out some other interface are only processed by netfilter on egress if they have passed through netfilter ingress processing before\&. Thus, ingress packets which are redirected by \fBtc\fR are not subjected to netfilter\&. But they are if they are redirected by \fBnetfilter\fR on ingress\&. Conceptually, tc and netfilter can be thought of as layers, with netfilter layered above tc: If the packet hasn\(cqt been passed up from the tc layer to the netfilter layer, it\(cqs not subjected to netfilter on egress\&.
+.SH "RULESET"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+{\fBlist\fR | \fBflush\fR} \fBruleset\fR [\fIfamily\fR]
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The \fBruleset\fR keyword is used to identify the whole set of tables, chains, etc\&. currently in place in kernel\&. The following \fBruleset\fR commands exist:
+.TS
+tab(:);
+lt lt
+lt lt.
+T{
+.sp
+\fBlist\fR
+T}:T{
+.sp
+Print the ruleset in human\-readable format\&.
+T}
+T{
+.sp
+\fBflush\fR
+T}:T{
+.sp
+Clear the whole ruleset\&. Note that, unlike iptables, this will remove all tables and whatever they contain, effectively leading to an empty ruleset \- no packet filtering will happen anymore, so the kernel accepts any valid packet it receives\&.
+T}
+.TE
+.sp 1
+.sp
+It is possible to limit \fBlist\fR and \fBflush\fR to a specific address family only\&. For a list of valid family names, see the section called \(lqADDRESS FAMILIES\(rq above\&.
+.sp
+By design, \fBlist ruleset\fR command output may be used as input to \fBnft \-f\fR\&. Effectively, this is the nft\-equivalent of \fBiptables\-save\fR and \fBiptables\-restore\fR\&.
+.SH "TABLES"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+{\fBadd\fR | \fBcreate\fR} \fBtable\fR [\fIfamily\fR] \fItable\fR [ {\fBcomment\fR \fIcomment\fR \fB;\fR\fI} \fR\fI\fB{ flags\fR\fR\fI \*(Aqflags\fR \fB; }\fR]
+{\fBdelete\fR | \fBdestroy\fR | \fBlist\fR | \fBflush\fR} \fBtable\fR [\fIfamily\fR] \fItable\fR
+\fBlist tables\fR [\fIfamily\fR]
+\fBdelete table\fR [\fIfamily\fR] \fBhandle\fR \fIhandle\fR
+\fBdestroy table\fR [\fIfamily\fR] \fBhandle\fR \fIhandle\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Tables are containers for chains, sets and stateful objects\&. They are identified by their address family and their name\&. The address family must be one of \fBip\fR, \fBip6\fR, \fBinet\fR, \fBarp\fR, \fBbridge\fR, \fBnetdev\fR\&. The \fBinet\fR address family is a dummy family which is used to create hybrid IPv4/IPv6 tables\&. The \fBmeta expression nfproto\fR keyword can be used to test which family (ipv4 or ipv6) context the packet is being processed in\&. When no address family is specified, \fBip\fR is used by default\&. The only difference between add and create is that the former will not return an error if the specified table already exists while \fBcreate\fR will return an error\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&4.\ \&Table flags
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Flag
+T}:T{
+Description
+T}
+.T&
+lt lt.
+T{
+.sp
+dormant
+T}:T{
+.sp
+table is not evaluated any more (base chains are unregistered)\&.
+T}
+.TE
+.sp 1
+.PP
+\fBAdd, change, delete a table\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# start nft in interactive mode
+nft \-\-interactive
+
+# create a new table\&.
+create table inet mytable
+
+# add a new base chain: get input packets
+add chain inet mytable myin { type filter hook input priority filter; }
+
+# add a single counter to the chain
+add rule inet mytable myin counter
+
+# disable the table temporarily \-\- rules are not evaluated anymore
+add table inet mytable { flags dormant; }
+
+# make table active again:
+add table inet mytable
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.TS
+tab(:);
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+\fBadd\fR
+T}:T{
+.sp
+Add a new table for the given family with the given name\&.
+T}
+T{
+.sp
+\fBdelete\fR
+T}:T{
+.sp
+Delete the specified table\&.
+T}
+T{
+.sp
+\fBdestroy\fR
+T}:T{
+.sp
+Delete the specified table, it does not fail if it does not exist\&.
+T}
+T{
+.sp
+\fBlist\fR
+T}:T{
+.sp
+List all chains and rules of the specified table\&.
+T}
+T{
+.sp
+\fBflush\fR
+T}:T{
+.sp
+Flush all chains and rules of the specified table\&.
+T}
+.TE
+.sp 1
+.SH "CHAINS"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+{\fBadd\fR | \fBcreate\fR} \fBchain\fR [\fIfamily\fR] \fItable\fR \fIchain\fR [\fB{ type\fR \fItype\fR \fBhook\fR \fIhook\fR [\fBdevice\fR \fIdevice\fR] \fBpriority\fR \fIpriority\fR \fB;\fR [\fBpolicy\fR \fIpolicy\fR \fB;\fR] [\fBcomment\fR \fIcomment\fR \fB;\fR\fI] \fR\fI\fB}\fR\fR\fI]
+{\fR\fI\fBdelete\fR\fR\fI | \fR\fI\fBdestroy\fR\fR\fI | \fR\fI\fBlist\fR\fR\fI | \fR\fI\fBflush\fR\fR\fI} \fR\fI\fBchain\fR\fR\fI [\*(Aqfamily\fR] \fItable\fR \fIchain\fR
+\fBlist chains\fR [\fIfamily\fR]
+\fBdelete chain\fR [\fIfamily\fR] \fItable\fR \fBhandle\fR \fIhandle\fR
+\fBdestroy chain\fR [\fIfamily\fR] \fItable\fR \fBhandle\fR \fIhandle\fR
+\fBrename chain\fR [\fIfamily\fR] \fItable\fR \fIchain\fR \fInewname\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Chains are containers for rules\&. They exist in two kinds, base chains and regular chains\&. A base chain is an entry point for packets from the networking stack, a regular chain may be used as jump target and is used for better rule organization\&.
+.TS
+tab(:);
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+\fBadd\fR
+T}:T{
+.sp
+Add a new chain in the specified table\&. When a hook and priority value are specified, the chain is created as a base chain and hooked up to the networking stack\&.
+T}
+T{
+.sp
+\fBcreate\fR
+T}:T{
+.sp
+Similar to the \fBadd\fR command, but returns an error if the chain already exists\&.
+T}
+T{
+.sp
+\fBdelete\fR
+T}:T{
+.sp
+Delete the specified chain\&. The chain must not contain any rules or be used as jump target\&.
+T}
+T{
+.sp
+\fBdestroy\fR
+T}:T{
+.sp
+Delete the specified chain, it does not fail if it does not exist\&. The chain must not contain any rules or be used as jump target\&.
+T}
+T{
+.sp
+\fBrename\fR
+T}:T{
+.sp
+Rename the specified chain\&.
+T}
+T{
+.sp
+\fBlist\fR
+T}:T{
+.sp
+List all rules of the specified chain\&.
+T}
+T{
+.sp
+\fBflush\fR
+T}:T{
+.sp
+Flush all rules of the specified chain\&.
+T}
+.TE
+.sp 1
+.sp
+For base chains, \fBtype\fR, \fBhook\fR and \fBpriority\fR parameters are mandatory\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&5.\ \&Supported chain types
+.TS
+allbox tab(:);
+ltB ltB ltB ltB.
+T{
+Type
+T}:T{
+Families
+T}:T{
+Hooks
+T}:T{
+Description
+T}
+.T&
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt.
+T{
+.sp
+filter
+T}:T{
+.sp
+all
+T}:T{
+.sp
+all
+T}:T{
+.sp
+Standard chain type to use in doubt\&.
+T}
+T{
+.sp
+nat
+T}:T{
+.sp
+ip, ip6, inet
+T}:T{
+.sp
+prerouting, input, output, postrouting
+T}:T{
+.sp
+Chains of this type perform Native Address Translation based on conntrack entries\&. Only the first packet of a connection actually traverses this chain \- its rules usually define details of the created conntrack entry (NAT statements for instance)\&.
+T}
+T{
+.sp
+route
+T}:T{
+.sp
+ip, ip6
+T}:T{
+.sp
+output
+T}:T{
+.sp
+If a packet has traversed a chain of this type and is about to be accepted, a new route lookup is performed if relevant parts of the IP header have changed\&. This allows one to e\&.g\&. implement policy routing selectors in nftables\&.
+T}
+.TE
+.sp 1
+.sp
+Apart from the special cases illustrated above (e\&.g\&. \fBnat\fR type not supporting \fBforward\fR hook or \fBroute\fR type only supporting \fBoutput\fR hook), there are three further quirks worth noticing:
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+The netdev family supports merely two combinations, namely
+\fBfilter\fR
+type with
+\fBingress\fR
+hook and
+\fBfilter\fR
+type with
+\fBegress\fR
+hook\&. Base chains in this family also require the
+\fBdevice\fR
+parameter to be present since they exist per interface only\&.
+.RE
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+The arp family supports only the
+\fBinput\fR
+and
+\fBoutput\fR
+hooks, both in chains of type
+\fBfilter\fR\&.
+.RE
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+The inet family also supports the
+\fBingress\fR
+hook (since Linux kernel 5\&.10), to filter IPv4 and IPv6 packet at the same location as the netdev
+\fBingress\fR
+hook\&. This inet hook allows you to share sets and maps between the usual
+\fBprerouting\fR,
+\fBinput\fR,
+\fBforward\fR,
+\fBoutput\fR,
+\fBpostrouting\fR
+and this
+\fBingress\fR
+hook\&.
+.RE
+.sp
+The \fBdevice\fR parameter accepts a network interface name as a string, and is required when adding a base chain that filters traffic on the ingress or egress hooks\&. Any ingress or egress chains will only filter traffic from the interface specified in the \fBdevice\fR parameter\&.
+.sp
+The \fBpriority\fR parameter accepts a signed integer value or a standard priority name which specifies the order in which chains with the same \fBhook\fR value are traversed\&. The ordering is ascending, i\&.e\&. lower priority values have precedence over higher ones\&.
+.sp
+With \fBnat\fR type chains, there\(cqs a lower excluding limit of \-200 for \fBpriority\fR values, because conntrack hooks at this priority and NAT requires it\&.
+.sp
+Standard priority values can be replaced with easily memorizable names\&. Not all names make sense in every family with every hook (see the compatibility matrices below) but their numerical value can still be used for prioritizing chains\&.
+.sp
+These names and values are defined and made available based on what priorities are used by xtables when registering their default chains\&.
+.sp
+Most of the families use the same values, but bridge uses different ones from the others\&. See the following tables that describe the values and compatibility\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&6.\ \&Standard priority names, family and hook compatibility matrix
+.TS
+allbox tab(:);
+ltB ltB ltB ltB.
+T{
+Name
+T}:T{
+Value
+T}:T{
+Families
+T}:T{
+Hooks
+T}
+.T&
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt.
+T{
+.sp
+raw
+T}:T{
+.sp
+\-300
+T}:T{
+.sp
+ip, ip6, inet
+T}:T{
+.sp
+all
+T}
+T{
+.sp
+mangle
+T}:T{
+.sp
+\-150
+T}:T{
+.sp
+ip, ip6, inet
+T}:T{
+.sp
+all
+T}
+T{
+.sp
+dstnat
+T}:T{
+.sp
+\-100
+T}:T{
+.sp
+ip, ip6, inet
+T}:T{
+.sp
+prerouting
+T}
+T{
+.sp
+filter
+T}:T{
+.sp
+0
+T}:T{
+.sp
+ip, ip6, inet, arp, netdev
+T}:T{
+.sp
+all
+T}
+T{
+.sp
+security
+T}:T{
+.sp
+50
+T}:T{
+.sp
+ip, ip6, inet
+T}:T{
+.sp
+all
+T}
+T{
+.sp
+srcnat
+T}:T{
+.sp
+100
+T}:T{
+.sp
+ip, ip6, inet
+T}:T{
+.sp
+postrouting
+T}
+.TE
+.sp 1
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&7.\ \&Standard priority names and hook compatibility for the bridge family
+.TS
+allbox tab(:);
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+Name
+T}:T{
+.sp
+Value
+T}:T{
+.sp
+Hooks
+T}
+T{
+.sp
+dstnat
+T}:T{
+.sp
+\-300
+T}:T{
+.sp
+prerouting
+T}
+T{
+.sp
+filter
+T}:T{
+.sp
+\-200
+T}:T{
+.sp
+all
+T}
+T{
+.sp
+out
+T}:T{
+.sp
+100
+T}:T{
+.sp
+output
+T}
+T{
+.sp
+srcnat
+T}:T{
+.sp
+300
+T}:T{
+.sp
+postrouting
+T}
+.TE
+.sp 1
+.sp
+Basic arithmetic expressions (addition and subtraction) can also be achieved with these standard names to ease relative prioritizing, e\&.g\&. \fBmangle \- 5\fR stands for \fB\-155\fR\&. Values will also be printed like this until the value is not further than 10 from the standard value\&.
+.sp
+Base chains also allow one to set the chain\(cqs \fBpolicy\fR, i\&.e\&. what happens to packets not explicitly accepted or refused in contained rules\&. Supported policy values are \fBaccept\fR (which is the default) or \fBdrop\fR\&.
+.SH "RULES"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+{\fBadd\fR | \fBinsert\fR} \fBrule\fR [\fIfamily\fR] \fItable\fR \fIchain\fR [\fBhandle\fR \fIhandle\fR | \fBindex\fR \fIindex\fR] \fIstatement\fR \&... [\fBcomment\fR \fIcomment\fR]
+\fBreplace rule\fR [\fIfamily\fR] \fItable\fR \fIchain\fR \fBhandle\fR \fIhandle\fR \fIstatement\fR \&... [\fBcomment\fR \fIcomment\fR]
+{\fBdelete\fR | \fBreset\fR} \fBrule\fR [\fIfamily\fR] \fItable\fR \fIchain\fR \fBhandle\fR \fIhandle\fR
+\fBdestroy rule\fR [\fIfamily\fR] \fItable\fR \fIchain\fR \fBhandle\fR \fIhandle\fR
+\fBreset rules\fR [\fIfamily\fR] [\fItable\fR [\fIchain\fR]]
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Rules are added to chains in the given table\&. If the family is not specified, the ip family is used\&. Rules are constructed from two kinds of components according to a set of grammatical rules: expressions and statements\&.
+.sp
+The add and insert commands support an optional location specifier, which is either a \fIhandle\fR or the \fIindex\fR (starting at zero) of an existing rule\&. Internally, rule locations are always identified by \fIhandle\fR and the translation from \fIindex\fR happens in userspace\&. This has two potential implications in case a concurrent ruleset change happens after the translation was done: The effective rule index might change if a rule was inserted or deleted before the referred one\&. If the referred rule was deleted, the command is rejected by the kernel just as if an invalid \fIhandle\fR was given\&.
+.sp
+A \fIcomment\fR is a single word or a double\-quoted (") multi\-word string which can be used to make notes regarding the actual rule\&. \fBNote:\fR If you use bash for adding rules, you have to escape the quotation marks, e\&.g\&. \e"enable ssh for servers\e"\&.
+.TS
+tab(:);
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+\fBadd\fR
+T}:T{
+.sp
+Add a new rule described by the list of statements\&. The rule is appended to the given chain unless a location is specified, in which case the rule is inserted after the specified rule\&.
+T}
+T{
+.sp
+\fBinsert\fR
+T}:T{
+.sp
+Same as \fBadd\fR except the rule is inserted at the beginning of the chain or before the specified rule\&.
+T}
+T{
+.sp
+\fBreplace\fR
+T}:T{
+.sp
+Similar to \fBadd\fR, but the rule replaces the specified rule\&.
+T}
+T{
+.sp
+\fBdelete\fR
+T}:T{
+.sp
+Delete the specified rule\&.
+T}
+T{
+.sp
+\fBdestroy\fR
+T}:T{
+.sp
+Delete the specified rule, it does not fail if it does not exist\&.
+T}
+T{
+.sp
+\fBreset\fR
+T}:T{
+.sp
+Reset rule\-contained state, e\&.g\&. counter and quota statement values\&.
+T}
+.TE
+.sp 1
+.PP
+\fBadd a rule to ip table output chain\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+nft add rule filter output ip daddr 192\&.168\&.0\&.0/24 accept # \*(Aqip filter\*(Aq is assumed
+# same command, slightly more verbose
+nft add rule ip filter output ip daddr 192\&.168\&.0\&.0/24 accept
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBdelete rule from inet table\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# nft \-a list ruleset
+table inet filter {
+ chain input {
+ type filter hook input priority filter; policy accept;
+ ct state established,related accept # handle 4
+ ip saddr 10\&.1\&.1\&.1 tcp dport ssh accept # handle 5
+ \&.\&.\&.
+# delete the rule with handle 5
+nft delete rule inet filter input handle 5
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SH "SETS"
+.sp
+nftables offers two kinds of set concepts\&. Anonymous sets are sets that have no specific name\&. The set members are enclosed in curly braces, with commas to separate elements when creating the rule the set is used in\&. Once that rule is removed, the set is removed as well\&. They cannot be updated, i\&.e\&. once an anonymous set is declared it cannot be changed anymore except by removing/altering the rule that uses the anonymous set\&.
+.PP
+\fBUsing anonymous sets to accept particular subnets and ports\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+nft add rule filter input ip saddr { 10\&.0\&.0\&.0/8, 192\&.168\&.0\&.0/16 } tcp dport { 22, 443 } accept
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Named sets are sets that need to be defined first before they can be referenced in rules\&. Unlike anonymous sets, elements can be added to or removed from a named set at any time\&. Sets are referenced from rules using an @ prefixed to the sets name\&.
+.PP
+\fBUsing named sets to accept addresses and ports\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+nft add rule filter input ip saddr @allowed_hosts tcp dport @allowed_ports accept
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The sets allowed_hosts and allowed_ports need to be created first\&. The next section describes nft set syntax in more detail\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBadd set\fR [\fIfamily\fR] \fItable\fR \fIset\fR \fB{ type\fR \fItype\fR | \fBtypeof\fR \fIexpression\fR \fB;\fR [\fBflags\fR \fIflags\fR \fB;\fR] [\fBtimeout\fR \fItimeout\fR \fB;\fR] [\fBgc\-interval\fR \fIgc\-interval\fR \fB;\fR] [\fBelements = {\fR \fIelement\fR[\fB,\fR \&...] \fB} ;\fR] [\fBsize\fR \fIsize\fR \fB;\fR] [\fBcomment\fR \fIcomment\fR \fB;\fR\fI] [\fR\fI\fBpolicy\fR\fR\fI \*(Aqpolicy\fR \fB;\fR] [\fBauto\-merge ;\fR] \fB}\fR
+{\fBdelete\fR | \fBdestroy\fR | \fBlist\fR | \fBflush\fR | \fBreset\fR } \fBset\fR [\fIfamily\fR] \fItable\fR \fIset\fR
+\fBlist sets\fR [\fIfamily\fR]
+\fBdelete set\fR [\fIfamily\fR] \fItable\fR \fBhandle\fR \fIhandle\fR
+{\fBadd\fR | \fBdelete\fR | \fBdestroy\fR } \fBelement\fR [\fIfamily\fR] \fItable\fR \fIset\fR \fB{\fR \fIelement\fR[\fB,\fR \&...] \fB}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Sets are element containers of a user\-defined data type, they are uniquely identified by a user\-defined name and attached to tables\&. Their behaviour can be tuned with the flags that can be specified at set creation time\&.
+.TS
+tab(:);
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+\fBadd\fR
+T}:T{
+.sp
+Add a new set in the specified table\&. See the Set specification table below for more information about how to specify properties of a set\&.
+T}
+T{
+.sp
+\fBdelete\fR
+T}:T{
+.sp
+Delete the specified set\&.
+T}
+T{
+.sp
+\fBdestroy\fR
+T}:T{
+.sp
+Delete the specified set, it does not fail if it does not exist\&.
+T}
+T{
+.sp
+\fBlist\fR
+T}:T{
+.sp
+Display the elements in the specified set\&.
+T}
+T{
+.sp
+\fBflush\fR
+T}:T{
+.sp
+Remove all elements from the specified set\&.
+T}
+T{
+.sp
+\fBreset\fR
+T}:T{
+.sp
+Reset state in all contained elements, e\&.g\&. counter and quota statement values\&.
+T}
+.TE
+.sp 1
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&8.\ \&Set specifications
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+type
+T}:T{
+.sp
+data type of set elements
+T}:T{
+.sp
+string: ipv4_addr, ipv6_addr, ether_addr, inet_proto, inet_service, mark
+T}
+T{
+.sp
+typeof
+T}:T{
+.sp
+data type of set element
+T}:T{
+.sp
+expression to derive the data type from
+T}
+T{
+.sp
+flags
+T}:T{
+.sp
+set flags
+T}:T{
+.sp
+string: constant, dynamic, interval, timeout\&. Used to describe the sets properties\&.
+T}
+T{
+.sp
+timeout
+T}:T{
+.sp
+time an element stays in the set, mandatory if set is added to from the packet path (ruleset)
+T}:T{
+.sp
+string, decimal followed by unit\&. Units are: d, h, m, s
+T}
+T{
+.sp
+gc\-interval
+T}:T{
+.sp
+garbage collection interval, only available when timeout or flag timeout are active
+T}:T{
+.sp
+string, decimal followed by unit\&. Units are: d, h, m, s
+T}
+T{
+.sp
+elements
+T}:T{
+.sp
+elements contained by the set
+T}:T{
+.sp
+set data type
+T}
+T{
+.sp
+size
+T}:T{
+.sp
+maximum number of elements in the set, mandatory if set is added to from the packet path (ruleset)
+T}:T{
+.sp
+unsigned integer (64 bit)
+T}
+T{
+.sp
+policy
+T}:T{
+.sp
+set policy
+T}:T{
+.sp
+string: performance [default], memory
+T}
+T{
+.sp
+auto\-merge
+T}:T{
+.sp
+automatic merge of adjacent/overlapping set elements (only for interval sets)
+T}:T{
+.sp
+T}
+.TE
+.sp 1
+.SH "MAPS"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBadd map\fR [\fIfamily\fR] \fItable\fR \fImap\fR \fB{ type\fR \fItype\fR | \fBtypeof\fR \fIexpression\fR [\fBflags\fR \fIflags\fR \fB;\fR] [\fBelements = {\fR \fIelement\fR[\fB,\fR \&...] \fB} ;\fR] [\fBsize\fR \fIsize\fR \fB;\fR] [\fBcomment\fR \fIcomment\fR \fB;\fR\fI] [\fR\fI\fBpolicy\fR\fR\fI \*(Aqpolicy\fR \fB;\fR] \fB}\fR
+{\fBdelete\fR | \fBdestroy\fR | \fBlist\fR | \fBflush\fR | \fBreset\fR } \fBmap\fR [\fIfamily\fR] \fItable\fR \fImap\fR
+\fBlist maps\fR [\fIfamily\fR]
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Maps store data based on some specific key used as input\&. They are uniquely identified by a user\-defined name and attached to tables\&.
+.TS
+tab(:);
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+\fBadd\fR
+T}:T{
+.sp
+Add a new map in the specified table\&.
+T}
+T{
+.sp
+\fBdelete\fR
+T}:T{
+.sp
+Delete the specified map\&.
+T}
+T{
+.sp
+\fBdestroy\fR
+T}:T{
+.sp
+Delete the specified map, it does not fail if it does not exist\&.
+T}
+T{
+.sp
+\fBlist\fR
+T}:T{
+.sp
+Display the elements in the specified map\&.
+T}
+T{
+.sp
+\fBflush\fR
+T}:T{
+.sp
+Remove all elements from the specified map\&.
+T}
+T{
+.sp
+\fBreset\fR
+T}:T{
+.sp
+Reset state in all contained elements, e\&.g\&. counter and quota statement values\&.
+T}
+.TE
+.sp 1
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&9.\ \&Map specifications
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+type
+T}:T{
+.sp
+data type of map elements
+T}:T{
+.sp
+string: ipv4_addr, ipv6_addr, ether_addr, inet_proto, inet_service, mark, counter, quota\&. Counter and quota can\(cqt be used as keys
+T}
+T{
+.sp
+typeof
+T}:T{
+.sp
+data type of set element
+T}:T{
+.sp
+expression to derive the data type from
+T}
+T{
+.sp
+flags
+T}:T{
+.sp
+map flags
+T}:T{
+.sp
+string, same as set flags
+T}
+T{
+.sp
+elements
+T}:T{
+.sp
+elements contained by the map
+T}:T{
+.sp
+map data type
+T}
+T{
+.sp
+size
+T}:T{
+.sp
+maximum number of elements in the map
+T}:T{
+.sp
+unsigned integer (64 bit)
+T}
+T{
+.sp
+policy
+T}:T{
+.sp
+map policy
+T}:T{
+.sp
+string: performance [default], memory
+T}
+.TE
+.sp 1
+.sp
+Users can specifiy the properties/features that the set/map must support\&. This allows the kernel to pick an optimal internal representation\&. If a required flag is missing, the ruleset might still work, as nftables will auto\-enable features if it can infer this from the ruleset\&. This may not work for all cases, however, so it is recommended to specify all required features in the set/map definition manually\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&10.\ \&Set and Map flags
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Flag
+T}:T{
+Description
+T}
+.T&
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+constant
+T}:T{
+.sp
+Set contents will never change after creation
+T}
+T{
+.sp
+dynamic
+T}:T{
+.sp
+Set must support updates from the packet path with the \fBadd\fR, \fBupdate\fR or \fBdelete\fR keywords\&.
+T}
+T{
+.sp
+interval
+T}:T{
+.sp
+Set must be able to store intervals (ranges)
+T}
+T{
+.sp
+timeout
+T}:T{
+.sp
+Set must support element timeouts (auto\-removal of elements once they expire)\&.
+T}
+.TE
+.sp 1
+.SH "ELEMENTS"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+{\fBadd\fR | \fBcreate\fR | \fBdelete\fR | \fBdestroy\fR | \fBget\fR | \fBreset\fR } \fBelement\fR [\fIfamily\fR] \fItable\fR \fIset\fR \fB{\fR \fIELEMENT\fR[\fB,\fR \&...] \fB}\fR
+
+\fIELEMENT\fR := \fIkey_expression\fR \fIOPTIONS\fR [\fB:\fR \fIvalue_expression\fR]
+\fIOPTIONS\fR := [\fBtimeout\fR \fITIMESPEC\fR] [\fBexpires\fR \fITIMESPEC\fR] [\fBcomment\fR \fIstring\fR]
+\fITIMESPEC\fR := [\fInum\fR\fBd\fR][\fInum\fR\fBh\fR][\fInum\fR\fBm\fR][\fInum\fR[\fBs\fR]]
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Element\-related commands allow one to change contents of named sets and maps\&. \fIkey_expression\fR is typically a value matching the set type\&. \fIvalue_expression\fR is not allowed in sets but mandatory when adding to maps, where it matches the data part in its type definition\&. When deleting from maps, it may be specified but is optional as \fIkey_expression\fR uniquely identifies the element\&.
+.sp
+\fBcreate\fR command is similar to \fBadd\fR with the exception that none of the listed elements may already exist\&.
+.sp
+\fBget\fR command is useful to check if an element is contained in a set which may be non\-trivial in very large and/or interval sets\&. In the latter case, the containing interval is returned instead of just the element itself\&.
+.sp
+\fBreset\fR command resets state attached to the given element(s), e\&.g\&. counter and quota statement values\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&11.\ \&Element options
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Option
+T}:T{
+Description
+T}
+.T&
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+timeout
+T}:T{
+.sp
+timeout value for sets/maps with flag \fBtimeout\fR
+T}
+T{
+.sp
+expires
+T}:T{
+.sp
+the time until given element expires, useful for ruleset replication only
+T}
+T{
+.sp
+comment
+T}:T{
+.sp
+per element comment field
+T}
+.TE
+.sp 1
+.SH "FLOWTABLES"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+{\fBadd\fR | \fBcreate\fR} \fBflowtable\fR [\fIfamily\fR] \fItable\fR \fIflowtable\fR \fB{ hook\fR \fIhook\fR \fBpriority\fR \fIpriority\fR \fB; devices = {\fR \fIdevice\fR[\fB,\fR \&...] \fB} ; }\fR
+\fBlist flowtables\fR [\fIfamily\fR]
+{\fBdelete\fR | \fBdestroy\fR | \fBlist\fR} \fBflowtable\fR [\fIfamily\fR] \fItable\fR \fIflowtable\fR
+\fBdelete\fR \fBflowtable\fR [\fIfamily\fR] \fItable\fR \fBhandle\fR \fIhandle\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Flowtables allow you to accelerate packet forwarding in software\&. Flowtables entries are represented through a tuple that is composed of the input interface, source and destination address, source and destination port; and layer 3/4 protocols\&. Each entry also caches the destination interface and the gateway address \- to update the destination link\-layer address \- to forward packets\&. The ttl and hoplimit fields are also decremented\&. Hence, flowtables provides an alternative path that allow packets to bypass the classic forwarding path\&. Flowtables reside in the ingress hook that is located before the prerouting hook\&. You can select which flows you want to offload through the flow expression from the forward chain\&. Flowtables are identified by their address family and their name\&. The address family must be one of ip, ip6, or inet\&. The inet address family is a dummy family which is used to create hybrid IPv4/IPv6 tables\&. When no address family is specified, ip is used by default\&.
+.sp
+The \fBpriority\fR can be a signed integer or \fBfilter\fR which stands for 0\&. Addition and subtraction can be used to set relative priority, e\&.g\&. filter + 5 equals to 5\&.
+.TS
+tab(:);
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+\fBadd\fR
+T}:T{
+.sp
+Add a new flowtable for the given family with the given name\&.
+T}
+T{
+.sp
+\fBdelete\fR
+T}:T{
+.sp
+Delete the specified flowtable\&.
+T}
+T{
+.sp
+\fBdestroy\fR
+T}:T{
+.sp
+Delete the specified flowtable, it does not fail if it does not exist\&.
+T}
+T{
+.sp
+\fBlist\fR
+T}:T{
+.sp
+List all flowtables\&.
+T}
+.TE
+.sp 1
+.SH "LISTING"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBlist { secmarks | synproxys | flow tables | meters | hooks }\fR [\fIfamily\fR]
+\fBlist { secmarks | synproxys | flow tables | meters | hooks } table\fR [\fIfamily\fR] \fItable\fR
+\fBlist ct { timeout | expectation | helper | helpers } table\fR [\fIfamily\fR] \fItable\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Inspect configured objects\&. \fBlist hooks\fR shows the full hook pipeline, including those registered by kernel modules, such as nf_conntrack\&.
+.SH "STATEFUL OBJECTS"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+{\fBadd\fR | \fBdelete\fR | \fBdestroy\fR | \fBlist\fR | \fBreset\fR} \fBcounter\fR [\fIfamily\fR] \fItable\fR \fIobject\fR
+{\fBadd\fR | \fBdelete\fR | \fBdestroy\fR | \fBlist\fR | \fBreset\fR} \fBquota\fR [\fIfamily\fR] \fItable\fR \fIobject\fR
+{\fBadd\fR | \fBdelete\fR | \fBdestroy\fR | \fBlist\fR} \fBlimit\fR [\fIfamily\fR] \fItable\fR \fIobject\fR
+\fBdelete\fR \fIcounter\fR [\fIfamily\fR] \fItable\fR \fBhandle\fR \fIhandle\fR
+\fBdelete\fR \fIquota\fR [\fIfamily\fR] \fItable\fR \fBhandle\fR \fIhandle\fR
+\fBdelete\fR \fIlimit\fR [\fIfamily\fR] \fItable\fR \fBhandle\fR \fIhandle\fR
+\fBdestroy\fR \fIcounter\fR [\fIfamily\fR] \fItable\fR \fBhandle\fR \fIhandle\fR
+\fBdestroy\fR \fIquota\fR [\fIfamily\fR] \fItable\fR \fBhandle\fR \fIhandle\fR
+\fBdestroy\fR \fIlimit\fR [\fIfamily\fR] \fItable\fR \fBhandle\fR \fIhandle\fR
+\fBlist counters\fR [\fIfamily\fR]
+\fBlist quotas\fR [\fIfamily\fR]
+\fBlist limits\fR [\fIfamily\fR]
+\fBreset counters\fR [\fIfamily\fR]
+\fBreset quotas\fR [\fIfamily\fR]
+\fBreset counters\fR [\fIfamily\fR] \fItable\fR
+\fBreset quotas\fR [\fIfamily\fR] \fItable\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Stateful objects are attached to tables and are identified by a unique name\&. They group stateful information from rules, to reference them in rules the keywords "type name" are used e\&.g\&. "counter name"\&.
+.TS
+tab(:);
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+\fBadd\fR
+T}:T{
+.sp
+Add a new stateful object in the specified table\&.
+T}
+T{
+.sp
+\fBdelete\fR
+T}:T{
+.sp
+Delete the specified object\&.
+T}
+T{
+.sp
+\fBdestroy\fR
+T}:T{
+.sp
+Delete the specified object, it does not fail if it does not exist\&.
+T}
+T{
+.sp
+\fBlist\fR
+T}:T{
+.sp
+Display stateful information the object holds\&.
+T}
+T{
+.sp
+\fBreset\fR
+T}:T{
+.sp
+List\-and\-reset stateful object\&.
+T}
+.TE
+.sp 1
+.SS "CT HELPER"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBadd\fR \fBct helper\fR [\fIfamily\fR] \fItable\fR \fIname\fR \fB{ type\fR \fItype\fR \fBprotocol\fR \fIprotocol\fR \fB;\fR [\fBl3proto\fR \fIfamily\fR \fB;\fR] \fB}\fR
+\fBdelete\fR \fBct helper\fR [\fIfamily\fR] \fItable\fR \fIname\fR
+\fBlist\fR \fBct helpers\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Ct helper is used to define connection tracking helpers that can then be used in combination with the \fBct helper set\fR statement\&. \fItype\fR and \fIprotocol\fR are mandatory, l3proto is derived from the table family by default, i\&.e\&. in the inet table the kernel will try to load both the ipv4 and ipv6 helper backends, if they are supported by the kernel\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&12.\ \&conntrack helper specifications
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+type
+T}:T{
+.sp
+name of helper type
+T}:T{
+.sp
+quoted string (e\&.g\&. "ftp")
+T}
+T{
+.sp
+protocol
+T}:T{
+.sp
+layer 4 protocol of the helper
+T}:T{
+.sp
+string (e\&.g\&. ip)
+T}
+T{
+.sp
+l3proto
+T}:T{
+.sp
+layer 3 protocol of the helper
+T}:T{
+.sp
+address family (e\&.g\&. ip)
+T}
+T{
+.sp
+comment
+T}:T{
+.sp
+per ct helper comment field
+T}:T{
+.sp
+string
+T}
+.TE
+.sp 1
+.PP
+\fBdefining and assigning ftp helper\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+Unlike iptables, helper assignment needs to be performed after the conntrack
+lookup has completed, for example with the default 0 hook priority\&.
+
+table inet myhelpers {
+ ct helper ftp\-standard {
+ type "ftp" protocol tcp
+ }
+ chain prerouting {
+ type filter hook prerouting priority filter;
+ tcp dport 21 ct helper set "ftp\-standard"
+ }
+}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "CT TIMEOUT"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBadd\fR \fBct timeout\fR [\fIfamily\fR] \fItable\fR \fIname\fR \fB{ protocol\fR \fIprotocol\fR \fB; policy = {\fR \fIstate\fR\fB:\fR \fIvalue\fR [\fB,\fR \&...] \fB} ;\fR [\fBl3proto\fR \fIfamily\fR \fB;\fR] \fB}\fR
+\fBdelete\fR \fBct timeout\fR [\fIfamily\fR] \fItable\fR \fIname\fR
+\fBlist\fR \fBct timeouts\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Ct timeout is used to update connection tracking timeout values\&.Timeout policies are assigned with the \fBct timeout set\fR statement\&. \fIprotocol\fR and \fIpolicy\fR are mandatory, l3proto is derived from the table family by default\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&13.\ \&conntrack timeout specifications
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+protocol
+T}:T{
+.sp
+layer 4 protocol of the timeout object
+T}:T{
+.sp
+string (e\&.g\&. ip)
+T}
+T{
+.sp
+state
+T}:T{
+.sp
+connection state name
+T}:T{
+.sp
+string (e\&.g\&. "established")
+T}
+T{
+.sp
+value
+T}:T{
+.sp
+timeout value for connection state
+T}:T{
+.sp
+unsigned integer
+T}
+T{
+.sp
+l3proto
+T}:T{
+.sp
+layer 3 protocol of the timeout object
+T}:T{
+.sp
+address family (e\&.g\&. ip)
+T}
+T{
+.sp
+comment
+T}:T{
+.sp
+per ct timeout comment field
+T}:T{
+.sp
+string
+T}
+.TE
+.sp 1
+.sp
+tcp connection state names that can have a specific timeout value are:
+.sp
+\fIclose\fR, \fIclose_wait\fR, \fIestablished\fR, \fIfin_wait\fR, \fIlast_ack\fR, \fIretrans\fR, \fIsyn_recv\fR, \fIsyn_sent\fR, \fItime_wait\fR and \fIunack\fR\&.
+.sp
+You can use \fIsysctl \-a |grep net\&.netfilter\&.nf_conntrack_tcp_timeout_\fR to view and change the system\-wide defaults\&. \fIct timeout\fR allows for flow\-specific settings, without changing the global timeouts\&.
+.sp
+For example, tcp port 53 could have much lower settings than other traffic\&.
+.sp
+udp state names that can have a specific timeout value are \fIreplied\fR and \fIunreplied\fR\&.
+.PP
+\fBdefining and assigning ct timeout policy\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+table ip filter {
+ ct timeout customtimeout {
+ protocol tcp;
+ l3proto ip
+ policy = { established: 2m, close: 20s }
+ }
+
+ chain output {
+ type filter hook output priority filter; policy accept;
+ ct timeout set "customtimeout"
+ }
+}
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBtesting the updated timeout policy\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+% conntrack \-E
+
+It should display:
+
+[UPDATE] tcp 6 120 ESTABLISHED src=172\&.16\&.19\&.128 dst=172\&.16\&.19\&.1
+sport=22 dport=41360 [UNREPLIED] src=172\&.16\&.19\&.1 dst=172\&.16\&.19\&.128
+sport=41360 dport=22
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "CT EXPECTATION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBadd\fR \fBct expectation\fR [\fIfamily\fR] \fItable\fR \fIname\fR \fB{ protocol\fR \fIprotocol\fR \fB; dport\fR \fIdport\fR \fB; timeout\fR \fItimeout\fR \fB; size\fR \fIsize\fR \fB; [*l3proto\fR \fIfamily\fR \fB;\fR] \fB}\fR
+\fBdelete\fR \fBct expectation\fR [\fIfamily\fR] \fItable\fR \fIname\fR
+\fBlist\fR \fBct expectations\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Ct expectation is used to create connection expectations\&. Expectations are assigned with the \fBct expectation set\fR statement\&. \fIprotocol\fR, \fIdport\fR, \fItimeout\fR and \fIsize\fR are mandatory, l3proto is derived from the table family by default\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&14.\ \&conntrack expectation specifications
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+protocol
+T}:T{
+.sp
+layer 4 protocol of the expectation object
+T}:T{
+.sp
+string (e\&.g\&. ip)
+T}
+T{
+.sp
+dport
+T}:T{
+.sp
+destination port of expected connection
+T}:T{
+.sp
+unsigned integer
+T}
+T{
+.sp
+timeout
+T}:T{
+.sp
+timeout value for expectation
+T}:T{
+.sp
+unsigned integer
+T}
+T{
+.sp
+size
+T}:T{
+.sp
+size value for expectation
+T}:T{
+.sp
+unsigned integer
+T}
+T{
+.sp
+l3proto
+T}:T{
+.sp
+layer 3 protocol of the expectation object
+T}:T{
+.sp
+address family (e\&.g\&. ip)
+T}
+T{
+.sp
+comment
+T}:T{
+.sp
+per ct expectation comment field
+T}:T{
+.sp
+string
+T}
+.TE
+.sp 1
+.PP
+\fBdefining and assigning ct expectation policy\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+table ip filter {
+ ct expectation expect {
+ protocol udp
+ dport 9876
+ timeout 2m
+ size 8
+ l3proto ip
+ }
+
+ chain input {
+ type filter hook input priority filter; policy accept;
+ ct expectation set "expect"
+ }
+}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "COUNTER"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBadd\fR \fBcounter\fR [\fIfamily\fR] \fItable\fR \fIname\fR [\fB{\fR [ \fBpackets\fR \fIpackets\fR \fBbytes\fR \fIbytes\fR \fI;\fR ] [ \fBcomment\fR \fIcomment\fR \fI;\fR \fB}\fR]
+\fBdelete\fR \fBcounter\fR [\fIfamily\fR] \fItable\fR \fIname\fR
+\fBlist\fR \fBcounters\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&15.\ \&Counter specifications
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+packets
+T}:T{
+.sp
+initial count of packets
+T}:T{
+.sp
+unsigned integer (64 bit)
+T}
+T{
+.sp
+bytes
+T}:T{
+.sp
+initial count of bytes
+T}:T{
+.sp
+unsigned integer (64 bit)
+T}
+T{
+.sp
+comment
+T}:T{
+.sp
+per counter comment field
+T}:T{
+.sp
+string
+T}
+.TE
+.sp 1
+.PP
+\fBUsing named counters\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+nft add counter filter http
+nft add rule filter input tcp dport 80 counter name \e"http\e"
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBUsing named counters with maps\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+nft add counter filter http
+nft add counter filter https
+nft add rule filter input counter name tcp dport map { 80 : \e"http\e", 443 : \e"https\e" }
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "QUOTA"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBadd\fR \fBquota\fR [\fIfamily\fR] \fItable\fR \fIname\fR \fB{\fR [\fBover\fR|\fBuntil\fR] \fIbytes\fR \fIBYTE_UNIT\fR [ \fBused\fR \fIbytes\fR \fIBYTE_UNIT\fR ] \fI;\fR [ \fBcomment\fR \fIcomment\fR \fI;\fR ] \fB}\fR
+BYTE_UNIT := bytes | kbytes | mbytes
+\fBdelete\fR \fBquota\fR [\fIfamily\fR] \fItable\fR \fIname\fR
+\fBlist\fR \fBquotas\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&16.\ \&Quota specifications
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+quota
+T}:T{
+.sp
+quota limit, used as the quota name
+T}:T{
+.sp
+Two arguments, unsigned integer (64 bit) and string: bytes, kbytes, mbytes\&. "over" and "until" go before these arguments
+T}
+T{
+.sp
+used
+T}:T{
+.sp
+initial value of used quota
+T}:T{
+.sp
+Two arguments, unsigned integer (64 bit) and string: bytes, kbytes, mbytes
+T}
+T{
+.sp
+comment
+T}:T{
+.sp
+per quota comment field
+T}:T{
+.sp
+string
+T}
+.TE
+.sp 1
+.PP
+\fBUsing named quotas\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+nft add quota filter user123 { over 20 mbytes }
+nft add rule filter input ip saddr 192\&.168\&.10\&.123 quota name \e"user123\e"
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBUsing named quotas with maps\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+nft add quota filter user123 { over 20 mbytes }
+nft add quota filter user124 { over 20 mbytes }
+nft add rule filter input quota name ip saddr map { 192\&.168\&.10\&.123 : \e"user123\e", 192\&.168\&.10\&.124 : \e"user124\e" }
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SH "EXPRESSIONS"
+.sp
+Expressions represent values, either constants like network addresses, port numbers, etc\&., or data gathered from the packet during ruleset evaluation\&. Expressions can be combined using binary, logical, relational and other types of expressions to form complex or relational (match) expressions\&. They are also used as arguments to certain types of operations, like NAT, packet marking etc\&.
+.sp
+Each expression has a data type, which determines the size, parsing and representation of symbolic values and type compatibility with other expressions\&.
+.SS "DESCRIBE COMMAND"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBdescribe\fR \fIexpression\fR | \fIdata type\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The \fBdescribe\fR command shows information about the type of an expression and its data type\&. A data type may also be given, in which nft will display more information about the type\&.
+.PP
+\fBThe describe command\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+$ nft describe tcp flags
+payload expression, datatype tcp_flag (TCP flag) (basetype bitmask, integer), 8 bits
+
+predefined symbolic constants:
+fin 0x01
+syn 0x02
+rst 0x04
+psh 0x08
+ack 0x10
+urg 0x20
+ecn 0x40
+cwr 0x80
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SH "DATA TYPES"
+.sp
+Data types determine the size, parsing and representation of symbolic values and type compatibility of expressions\&. A number of global data types exist, in addition some expression types define further data types specific to the expression type\&. Most data types have a fixed size, some however may have a dynamic size, f\&.i\&. the string type\&. Some types also have predefined symbolic constants\&. Those can be listed using the nft \fBdescribe\fR command:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+$ nft describe ct_state
+datatype ct_state (conntrack state) (basetype bitmask, integer), 32 bits
+
+pre\-defined symbolic constants (in hexadecimal):
+invalid 0x00000001
+new \&.\&.\&.
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Types may be derived from lower order types, f\&.i\&. the IPv4 address type is derived from the integer type, meaning an IPv4 address can also be specified as an integer value\&.
+.sp
+In certain contexts (set and map definitions), it is necessary to explicitly specify a data type\&. Each type has a name which is used for this\&.
+.SS "INTEGER TYPE"
+.TS
+allbox tab(:);
+ltB ltB ltB ltB.
+T{
+Name
+T}:T{
+Keyword
+T}:T{
+Size
+T}:T{
+Base type
+T}
+.T&
+lt lt lt lt.
+T{
+.sp
+Integer
+T}:T{
+.sp
+integer
+T}:T{
+.sp
+variable
+T}:T{
+.sp
+\-
+T}
+.TE
+.sp 1
+.sp
+The integer type is used for numeric values\&. It may be specified as a decimal, hexadecimal or octal number\&. The integer type does not have a fixed size, its size is determined by the expression for which it is used\&.
+.SS "BITMASK TYPE"
+.TS
+allbox tab(:);
+ltB ltB ltB ltB.
+T{
+Name
+T}:T{
+Keyword
+T}:T{
+Size
+T}:T{
+Base type
+T}
+.T&
+lt lt lt lt.
+T{
+.sp
+Bitmask
+T}:T{
+.sp
+bitmask
+T}:T{
+.sp
+variable
+T}:T{
+.sp
+integer
+T}
+.TE
+.sp 1
+.sp
+The bitmask type (\fBbitmask\fR) is used for bitmasks\&.
+.SS "STRING TYPE"
+.TS
+allbox tab(:);
+ltB ltB ltB ltB.
+T{
+Name
+T}:T{
+Keyword
+T}:T{
+Size
+T}:T{
+Base type
+T}
+.T&
+lt lt lt lt.
+T{
+.sp
+String
+T}:T{
+.sp
+string
+T}:T{
+.sp
+variable
+T}:T{
+.sp
+\-
+T}
+.TE
+.sp 1
+.sp
+The string type is used for character strings\&. A string begins with an alphabetic character (a\-zA\-Z) followed by zero or more alphanumeric characters or the characters /, \-, _ and \&.\&. In addition, anything enclosed in double quotes (") is recognized as a string\&.
+.PP
+\fBString specification\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# Interface name
+filter input iifname eth0
+
+# Weird interface name
+filter input iifname "(eth0)"
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "LINK LAYER ADDRESS TYPE"
+.TS
+allbox tab(:);
+ltB ltB ltB ltB.
+T{
+Name
+T}:T{
+Keyword
+T}:T{
+Size
+T}:T{
+Base type
+T}
+.T&
+lt lt lt lt.
+T{
+.sp
+Link layer address
+T}:T{
+.sp
+lladdr
+T}:T{
+.sp
+variable
+T}:T{
+.sp
+integer
+T}
+.TE
+.sp 1
+.sp
+The link layer address type is used for link layer addresses\&. Link layer addresses are specified as a variable amount of groups of two hexadecimal digits separated using colons (:)\&.
+.PP
+\fBLink layer address specification\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# Ethernet destination MAC address
+filter input ether daddr 20:c9:d0:43:12:d9
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "IPV4 ADDRESS TYPE"
+.TS
+allbox tab(:);
+ltB ltB ltB ltB.
+T{
+Name
+T}:T{
+Keyword
+T}:T{
+Size
+T}:T{
+Base type
+T}
+.T&
+lt lt lt lt.
+T{
+.sp
+IPV4 address
+T}:T{
+.sp
+ipv4_addr
+T}:T{
+.sp
+32 bit
+T}:T{
+.sp
+integer
+T}
+.TE
+.sp 1
+.sp
+The IPv4 address type is used for IPv4 addresses\&. Addresses are specified in either dotted decimal, dotted hexadecimal, dotted octal, decimal, hexadecimal, octal notation or as a host name\&. A host name will be resolved using the standard system resolver\&.
+.PP
+\fBIPv4 address specification\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# dotted decimal notation
+filter output ip daddr 127\&.0\&.0\&.1
+
+# host name
+filter output ip daddr localhost
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "IPV6 ADDRESS TYPE"
+.TS
+allbox tab(:);
+ltB ltB ltB ltB.
+T{
+Name
+T}:T{
+Keyword
+T}:T{
+Size
+T}:T{
+Base type
+T}
+.T&
+lt lt lt lt.
+T{
+.sp
+IPv6 address
+T}:T{
+.sp
+ipv6_addr
+T}:T{
+.sp
+128 bit
+T}:T{
+.sp
+integer
+T}
+.TE
+.sp 1
+.sp
+The IPv6 address type is used for IPv6 addresses\&. Addresses are specified as a host name or as hexadecimal halfwords separated by colons\&. Addresses might be enclosed in square brackets ("[]") to differentiate them from port numbers\&.
+.PP
+\fBIPv6 address specification\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# abbreviated loopback address
+filter output ip6 daddr ::1
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBIPv6 address specification with bracket notation\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# without [] the port number (22) would be parsed as part of the
+# ipv6 address
+ip6 nat prerouting tcp dport 2222 dnat to [1ce::d0]:22
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "BOOLEAN TYPE"
+.TS
+allbox tab(:);
+ltB ltB ltB ltB.
+T{
+Name
+T}:T{
+Keyword
+T}:T{
+Size
+T}:T{
+Base type
+T}
+.T&
+lt lt lt lt.
+T{
+.sp
+Boolean
+T}:T{
+.sp
+boolean
+T}:T{
+.sp
+1 bit
+T}:T{
+.sp
+integer
+T}
+.TE
+.sp 1
+.sp
+The boolean type is a syntactical helper type in userspace\&. Its use is in the right\-hand side of a (typically implicit) relational expression to change the expression on the left\-hand side into a boolean check (usually for existence)\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&17.\ \&The following keywords will automatically resolve into a boolean type with given value
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Keyword
+T}:T{
+Value
+T}
+.T&
+lt lt
+lt lt.
+T{
+.sp
+exists
+T}:T{
+.sp
+1
+T}
+T{
+.sp
+missing
+T}:T{
+.sp
+0
+T}
+.TE
+.sp 1
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&18.\ \&expressions support a boolean comparison
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Expression
+T}:T{
+Behaviour
+T}
+.T&
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+fib
+T}:T{
+.sp
+Check route existence\&.
+T}
+T{
+.sp
+exthdr
+T}:T{
+.sp
+Check IPv6 extension header existence\&.
+T}
+T{
+.sp
+tcp option
+T}:T{
+.sp
+Check TCP option header existence\&.
+T}
+.TE
+.sp 1
+.PP
+\fBBoolean specification\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# match if route exists
+filter input fib daddr \&. iif oif exists
+
+# match only non\-fragmented packets in IPv6 traffic
+filter input exthdr frag missing
+
+# match if TCP timestamp option is present
+filter input tcp option timestamp exists
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "ICMP TYPE TYPE"
+.TS
+allbox tab(:);
+ltB ltB ltB ltB.
+T{
+Name
+T}:T{
+Keyword
+T}:T{
+Size
+T}:T{
+Base type
+T}
+.T&
+lt lt lt lt.
+T{
+.sp
+ICMP Type
+T}:T{
+.sp
+icmp_type
+T}:T{
+.sp
+8 bit
+T}:T{
+.sp
+integer
+T}
+.TE
+.sp 1
+.sp
+The ICMP Type type is used to conveniently specify the ICMP header\(cqs type field\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&19.\ \&Keywords may be used when specifying the ICMP type
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Keyword
+T}:T{
+Value
+T}
+.T&
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+echo\-reply
+T}:T{
+.sp
+0
+T}
+T{
+.sp
+destination\-unreachable
+T}:T{
+.sp
+3
+T}
+T{
+.sp
+source\-quench
+T}:T{
+.sp
+4
+T}
+T{
+.sp
+redirect
+T}:T{
+.sp
+5
+T}
+T{
+.sp
+echo\-request
+T}:T{
+.sp
+8
+T}
+T{
+.sp
+router\-advertisement
+T}:T{
+.sp
+9
+T}
+T{
+.sp
+router\-solicitation
+T}:T{
+.sp
+10
+T}
+T{
+.sp
+time\-exceeded
+T}:T{
+.sp
+11
+T}
+T{
+.sp
+parameter\-problem
+T}:T{
+.sp
+12
+T}
+T{
+.sp
+timestamp\-request
+T}:T{
+.sp
+13
+T}
+T{
+.sp
+timestamp\-reply
+T}:T{
+.sp
+14
+T}
+T{
+.sp
+info\-request
+T}:T{
+.sp
+15
+T}
+T{
+.sp
+info\-reply
+T}:T{
+.sp
+16
+T}
+T{
+.sp
+address\-mask\-request
+T}:T{
+.sp
+17
+T}
+T{
+.sp
+address\-mask\-reply
+T}:T{
+.sp
+18
+T}
+.TE
+.sp 1
+.PP
+\fBICMP Type specification\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# match ping packets
+filter output icmp type { echo\-request, echo\-reply }
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "ICMP CODE TYPE"
+.TS
+allbox tab(:);
+ltB ltB ltB ltB.
+T{
+Name
+T}:T{
+Keyword
+T}:T{
+Size
+T}:T{
+Base type
+T}
+.T&
+lt lt lt lt.
+T{
+.sp
+ICMP Code
+T}:T{
+.sp
+icmp_code
+T}:T{
+.sp
+8 bit
+T}:T{
+.sp
+integer
+T}
+.TE
+.sp 1
+.sp
+The ICMP Code type is used to conveniently specify the ICMP header\(cqs code field\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&20.\ \&Keywords may be used when specifying the ICMP code
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Keyword
+T}:T{
+Value
+T}
+.T&
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+net\-unreachable
+T}:T{
+.sp
+0
+T}
+T{
+.sp
+host\-unreachable
+T}:T{
+.sp
+1
+T}
+T{
+.sp
+prot\-unreachable
+T}:T{
+.sp
+2
+T}
+T{
+.sp
+port\-unreachable
+T}:T{
+.sp
+3
+T}
+T{
+.sp
+frag\-needed
+T}:T{
+.sp
+4
+T}
+T{
+.sp
+net\-prohibited
+T}:T{
+.sp
+9
+T}
+T{
+.sp
+host\-prohibited
+T}:T{
+.sp
+10
+T}
+T{
+.sp
+admin\-prohibited
+T}:T{
+.sp
+13
+T}
+.TE
+.sp 1
+.SS "ICMPV6 TYPE TYPE"
+.TS
+allbox tab(:);
+ltB ltB ltB ltB.
+T{
+Name
+T}:T{
+Keyword
+T}:T{
+Size
+T}:T{
+Base type
+T}
+.T&
+lt lt lt lt.
+T{
+.sp
+ICMPv6 Type
+T}:T{
+.sp
+icmpx_code
+T}:T{
+.sp
+8 bit
+T}:T{
+.sp
+integer
+T}
+.TE
+.sp 1
+.sp
+The ICMPv6 Type type is used to conveniently specify the ICMPv6 header\(cqs type field\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&21.\ \&keywords may be used when specifying the ICMPv6 type:
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Keyword
+T}:T{
+Value
+T}
+.T&
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+destination\-unreachable
+T}:T{
+.sp
+1
+T}
+T{
+.sp
+packet\-too\-big
+T}:T{
+.sp
+2
+T}
+T{
+.sp
+time\-exceeded
+T}:T{
+.sp
+3
+T}
+T{
+.sp
+parameter\-problem
+T}:T{
+.sp
+4
+T}
+T{
+.sp
+echo\-request
+T}:T{
+.sp
+128
+T}
+T{
+.sp
+echo\-reply
+T}:T{
+.sp
+129
+T}
+T{
+.sp
+mld\-listener\-query
+T}:T{
+.sp
+130
+T}
+T{
+.sp
+mld\-listener\-report
+T}:T{
+.sp
+131
+T}
+T{
+.sp
+mld\-listener\-done
+T}:T{
+.sp
+132
+T}
+T{
+.sp
+mld\-listener\-reduction
+T}:T{
+.sp
+132
+T}
+T{
+.sp
+nd\-router\-solicit
+T}:T{
+.sp
+133
+T}
+T{
+.sp
+nd\-router\-advert
+T}:T{
+.sp
+134
+T}
+T{
+.sp
+nd\-neighbor\-solicit
+T}:T{
+.sp
+135
+T}
+T{
+.sp
+nd\-neighbor\-advert
+T}:T{
+.sp
+136
+T}
+T{
+.sp
+nd\-redirect
+T}:T{
+.sp
+137
+T}
+T{
+.sp
+router\-renumbering
+T}:T{
+.sp
+138
+T}
+T{
+.sp
+ind\-neighbor\-solicit
+T}:T{
+.sp
+141
+T}
+T{
+.sp
+ind\-neighbor\-advert
+T}:T{
+.sp
+142
+T}
+T{
+.sp
+mld2\-listener\-report
+T}:T{
+.sp
+143
+T}
+.TE
+.sp 1
+.PP
+\fBICMPv6 Type specification\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# match ICMPv6 ping packets
+filter output icmpv6 type { echo\-request, echo\-reply }
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "ICMPV6 CODE TYPE"
+.TS
+allbox tab(:);
+ltB ltB ltB ltB.
+T{
+Name
+T}:T{
+Keyword
+T}:T{
+Size
+T}:T{
+Base type
+T}
+.T&
+lt lt lt lt.
+T{
+.sp
+ICMPv6 Code
+T}:T{
+.sp
+icmpv6_code
+T}:T{
+.sp
+8 bit
+T}:T{
+.sp
+integer
+T}
+.TE
+.sp 1
+.sp
+The ICMPv6 Code type is used to conveniently specify the ICMPv6 header\(cqs code field\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&22.\ \&keywords may be used when specifying the ICMPv6 code
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Keyword
+T}:T{
+Value
+T}
+.T&
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+no\-route
+T}:T{
+.sp
+0
+T}
+T{
+.sp
+admin\-prohibited
+T}:T{
+.sp
+1
+T}
+T{
+.sp
+addr\-unreachable
+T}:T{
+.sp
+3
+T}
+T{
+.sp
+port\-unreachable
+T}:T{
+.sp
+4
+T}
+T{
+.sp
+policy\-fail
+T}:T{
+.sp
+5
+T}
+T{
+.sp
+reject\-route
+T}:T{
+.sp
+6
+T}
+.TE
+.sp 1
+.SS "ICMPVX CODE TYPE"
+.TS
+allbox tab(:);
+ltB ltB ltB ltB.
+T{
+Name
+T}:T{
+Keyword
+T}:T{
+Size
+T}:T{
+Base type
+T}
+.T&
+lt lt lt lt.
+T{
+.sp
+ICMPvX Code
+T}:T{
+.sp
+icmpv6_type
+T}:T{
+.sp
+8 bit
+T}:T{
+.sp
+integer
+T}
+.TE
+.sp 1
+.sp
+The ICMPvX Code type abstraction is a set of values which overlap between ICMP and ICMPv6 Code types to be used from the inet family\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&23.\ \&keywords may be used when specifying the ICMPvX code
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Keyword
+T}:T{
+Value
+T}
+.T&
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+no\-route
+T}:T{
+.sp
+0
+T}
+T{
+.sp
+port\-unreachable
+T}:T{
+.sp
+1
+T}
+T{
+.sp
+host\-unreachable
+T}:T{
+.sp
+2
+T}
+T{
+.sp
+admin\-prohibited
+T}:T{
+.sp
+3
+T}
+.TE
+.sp 1
+.SS "CONNTRACK TYPES"
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&24.\ \&overview of types used in ct expression and statement
+.TS
+allbox tab(:);
+ltB ltB ltB ltB.
+T{
+Name
+T}:T{
+Keyword
+T}:T{
+Size
+T}:T{
+Base type
+T}
+.T&
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt.
+T{
+.sp
+conntrack state
+T}:T{
+.sp
+ct_state
+T}:T{
+.sp
+4 byte
+T}:T{
+.sp
+bitmask
+T}
+T{
+.sp
+conntrack direction
+T}:T{
+.sp
+ct_dir
+T}:T{
+.sp
+8 bit
+T}:T{
+.sp
+integer
+T}
+T{
+.sp
+conntrack status
+T}:T{
+.sp
+ct_status
+T}:T{
+.sp
+4 byte
+T}:T{
+.sp
+bitmask
+T}
+T{
+.sp
+conntrack event bits
+T}:T{
+.sp
+ct_event
+T}:T{
+.sp
+4 byte
+T}:T{
+.sp
+bitmask
+T}
+T{
+.sp
+conntrack label
+T}:T{
+.sp
+ct_label
+T}:T{
+.sp
+128 bit
+T}:T{
+.sp
+bitmask
+T}
+.TE
+.sp 1
+.sp
+For each of the types above, keywords are available for convenience:
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&25.\ \&conntrack state (ct_state)
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Keyword
+T}:T{
+Value
+T}
+.T&
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+invalid
+T}:T{
+.sp
+1
+T}
+T{
+.sp
+established
+T}:T{
+.sp
+2
+T}
+T{
+.sp
+related
+T}:T{
+.sp
+4
+T}
+T{
+.sp
+new
+T}:T{
+.sp
+8
+T}
+T{
+.sp
+untracked
+T}:T{
+.sp
+64
+T}
+.TE
+.sp 1
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&26.\ \&conntrack direction (ct_dir)
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Keyword
+T}:T{
+Value
+T}
+.T&
+lt lt
+lt lt.
+T{
+.sp
+original
+T}:T{
+.sp
+0
+T}
+T{
+.sp
+reply
+T}:T{
+.sp
+1
+T}
+.TE
+.sp 1
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&27.\ \&conntrack status (ct_status)
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Keyword
+T}:T{
+Value
+T}
+.T&
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+expected
+T}:T{
+.sp
+1
+T}
+T{
+.sp
+seen\-reply
+T}:T{
+.sp
+2
+T}
+T{
+.sp
+assured
+T}:T{
+.sp
+4
+T}
+T{
+.sp
+confirmed
+T}:T{
+.sp
+8
+T}
+T{
+.sp
+snat
+T}:T{
+.sp
+16
+T}
+T{
+.sp
+dnat
+T}:T{
+.sp
+32
+T}
+T{
+.sp
+dying
+T}:T{
+.sp
+512
+T}
+.TE
+.sp 1
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&28.\ \&conntrack event bits (ct_event)
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Keyword
+T}:T{
+Value
+T}
+.T&
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+new
+T}:T{
+.sp
+1
+T}
+T{
+.sp
+related
+T}:T{
+.sp
+2
+T}
+T{
+.sp
+destroy
+T}:T{
+.sp
+4
+T}
+T{
+.sp
+reply
+T}:T{
+.sp
+8
+T}
+T{
+.sp
+assured
+T}:T{
+.sp
+16
+T}
+T{
+.sp
+protoinfo
+T}:T{
+.sp
+32
+T}
+T{
+.sp
+helper
+T}:T{
+.sp
+64
+T}
+T{
+.sp
+mark
+T}:T{
+.sp
+128
+T}
+T{
+.sp
+seqadj
+T}:T{
+.sp
+256
+T}
+T{
+.sp
+secmark
+T}:T{
+.sp
+512
+T}
+T{
+.sp
+label
+T}:T{
+.sp
+1024
+T}
+.TE
+.sp 1
+.sp
+Possible keywords for conntrack label type (ct_label) are read at runtime from /etc/connlabel\&.conf\&.
+.SS "DCCP PKTTYPE TYPE"
+.TS
+allbox tab(:);
+ltB ltB ltB ltB.
+T{
+Name
+T}:T{
+Keyword
+T}:T{
+Size
+T}:T{
+Base type
+T}
+.T&
+lt lt lt lt.
+T{
+.sp
+DCCP packet type
+T}:T{
+.sp
+dccp_pkttype
+T}:T{
+.sp
+4 bit
+T}:T{
+.sp
+integer
+T}
+.TE
+.sp 1
+.sp
+The DCCP packet type abstracts the different legal values of the respective four bit field in the DCCP header, as stated by RFC4340\&. Note that possible values 10\-15 are considered reserved and therefore not allowed to be used\&. In iptables\*(Aq \fBdccp\fR match, these values are aliased \fIINVALID\fR\&. With nftables, one may simply match on the numeric value range, i\&.e\&. \fB10\-15\fR\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&29.\ \&keywords may be used when specifying the DCCP packet type
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Keyword
+T}:T{
+Value
+T}
+.T&
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+request
+T}:T{
+.sp
+0
+T}
+T{
+.sp
+response
+T}:T{
+.sp
+1
+T}
+T{
+.sp
+data
+T}:T{
+.sp
+2
+T}
+T{
+.sp
+ack
+T}:T{
+.sp
+3
+T}
+T{
+.sp
+dataack
+T}:T{
+.sp
+4
+T}
+T{
+.sp
+closereq
+T}:T{
+.sp
+5
+T}
+T{
+.sp
+close
+T}:T{
+.sp
+6
+T}
+T{
+.sp
+reset
+T}:T{
+.sp
+7
+T}
+T{
+.sp
+sync
+T}:T{
+.sp
+8
+T}
+T{
+.sp
+syncack
+T}:T{
+.sp
+9
+T}
+.TE
+.sp 1
+.SH "PRIMARY EXPRESSIONS"
+.sp
+The lowest order expression is a primary expression, representing either a constant or a single datum from a packet\(cqs payload, meta data or a stateful module\&.
+.SS "META EXPRESSIONS"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBmeta\fR {\fBlength\fR | \fBnfproto\fR | \fBl4proto\fR | \fBprotocol\fR | \fBpriority\fR}
+[\fBmeta\fR] {\fBmark\fR | \fBiif\fR | \fBiifname\fR | \fBiiftype\fR | \fBoif\fR | \fBoifname\fR | \fBoiftype\fR | \fBskuid\fR | \fBskgid\fR | \fBnftrace\fR | \fBrtclassid\fR | \fBibrname\fR | \fBobrname\fR | \fBpkttype\fR | \fBcpu\fR | \fBiifgroup\fR | \fBoifgroup\fR | \fBcgroup\fR | \fBrandom\fR | \fBipsec\fR | \fBiifkind\fR | \fBoifkind\fR | \fBtime\fR | \fBhour\fR | \fBday\fR }
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+A meta expression refers to meta data associated with a packet\&.
+.sp
+There are two types of meta expressions: unqualified and qualified meta expressions\&. Qualified meta expressions require the meta keyword before the meta key, unqualified meta expressions can be specified by using the meta key directly or as qualified meta expressions\&. Meta l4proto is useful to match a particular transport protocol that is part of either an IPv4 or IPv6 packet\&. It will also skip any IPv6 extension headers present in an IPv6 packet\&.
+.sp
+meta iif, oif, iifname and oifname are used to match the interface a packet arrived on or is about to be sent out on\&.
+.sp
+iif and oif are used to match on the interface index, whereas iifname and oifname are used to match on the interface name\&. This is not the same \(em assuming the rule
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+filter input meta iif "foo"
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Then this rule can only be added if the interface "foo" exists\&. Also, the rule will continue to match even if the interface "foo" is renamed to "bar"\&.
+.sp
+This is because internally the interface index is used\&. In case of dynamically created interfaces, such as tun/tap or dialup interfaces (ppp for example), it might be better to use iifname or oifname instead\&.
+.sp
+In these cases, the name is used so the interface doesn\(cqt have to exist to add such a rule, it will stop matching if the interface gets renamed and it will match again in case interface gets deleted and later a new interface with the same name is created\&.
+.sp
+Like with iptables, wildcard matching on interface name prefixes is available for \fBiifname\fR and \fBoifname\fR matches by appending an asterisk (*) character\&. Note however that unlike iptables, nftables does not accept interface names consisting of the wildcard character only \- users are supposed to just skip those always matching expressions\&. In order to match on literal asterisk character, one may escape it using backslash (\e)\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&30.\ \&Meta expression types
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+length
+T}:T{
+.sp
+Length of the packet in bytes
+T}:T{
+.sp
+integer (32\-bit)
+T}
+T{
+.sp
+nfproto
+T}:T{
+.sp
+real hook protocol family, useful only in inet table
+T}:T{
+.sp
+integer (32 bit)
+T}
+T{
+.sp
+l4proto
+T}:T{
+.sp
+layer 4 protocol, skips ipv6 extension headers
+T}:T{
+.sp
+integer (8 bit)
+T}
+T{
+.sp
+protocol
+T}:T{
+.sp
+EtherType protocol value
+T}:T{
+.sp
+ether_type
+T}
+T{
+.sp
+priority
+T}:T{
+.sp
+TC packet priority
+T}:T{
+.sp
+tc_handle
+T}
+T{
+.sp
+mark
+T}:T{
+.sp
+Packet mark
+T}:T{
+.sp
+mark
+T}
+T{
+.sp
+iif
+T}:T{
+.sp
+Input interface index
+T}:T{
+.sp
+iface_index
+T}
+T{
+.sp
+iifname
+T}:T{
+.sp
+Input interface name
+T}:T{
+.sp
+ifname
+T}
+T{
+.sp
+iiftype
+T}:T{
+.sp
+Input interface type
+T}:T{
+.sp
+iface_type
+T}
+T{
+.sp
+oif
+T}:T{
+.sp
+Output interface index
+T}:T{
+.sp
+iface_index
+T}
+T{
+.sp
+oifname
+T}:T{
+.sp
+Output interface name
+T}:T{
+.sp
+ifname
+T}
+T{
+.sp
+oiftype
+T}:T{
+.sp
+Output interface hardware type
+T}:T{
+.sp
+iface_type
+T}
+T{
+.sp
+sdif
+T}:T{
+.sp
+Slave device input interface index
+T}:T{
+.sp
+iface_index
+T}
+T{
+.sp
+sdifname
+T}:T{
+.sp
+Slave device interface name
+T}:T{
+.sp
+ifname
+T}
+T{
+.sp
+skuid
+T}:T{
+.sp
+UID associated with originating socket
+T}:T{
+.sp
+uid
+T}
+T{
+.sp
+skgid
+T}:T{
+.sp
+GID associated with originating socket
+T}:T{
+.sp
+gid
+T}
+T{
+.sp
+rtclassid
+T}:T{
+.sp
+Routing realm
+T}:T{
+.sp
+realm
+T}
+T{
+.sp
+ibrname
+T}:T{
+.sp
+Input bridge interface name
+T}:T{
+.sp
+ifname
+T}
+T{
+.sp
+obrname
+T}:T{
+.sp
+Output bridge interface name
+T}:T{
+.sp
+ifname
+T}
+T{
+.sp
+pkttype
+T}:T{
+.sp
+packet type
+T}:T{
+.sp
+pkt_type
+T}
+T{
+.sp
+cpu
+T}:T{
+.sp
+cpu number processing the packet
+T}:T{
+.sp
+integer (32 bit)
+T}
+T{
+.sp
+iifgroup
+T}:T{
+.sp
+incoming device group
+T}:T{
+.sp
+devgroup
+T}
+T{
+.sp
+oifgroup
+T}:T{
+.sp
+outgoing device group
+T}:T{
+.sp
+devgroup
+T}
+T{
+.sp
+cgroup
+T}:T{
+.sp
+control group id
+T}:T{
+.sp
+integer (32 bit)
+T}
+T{
+.sp
+random
+T}:T{
+.sp
+pseudo\-random number
+T}:T{
+.sp
+integer (32 bit)
+T}
+T{
+.sp
+ipsec
+T}:T{
+.sp
+true if packet was ipsec encrypted
+T}:T{
+.sp
+boolean (1 bit)
+T}
+T{
+.sp
+iifkind
+T}:T{
+.sp
+Input interface kind
+T}:T{
+.sp
+T}
+T{
+.sp
+oifkind
+T}:T{
+.sp
+Output interface kind
+T}:T{
+.sp
+T}
+T{
+.sp
+time
+T}:T{
+.sp
+Absolute time of packet reception
+T}:T{
+.sp
+Integer (32 bit) or string
+T}
+T{
+.sp
+day
+T}:T{
+.sp
+Day of week
+T}:T{
+.sp
+Integer (8 bit) or string
+T}
+T{
+.sp
+hour
+T}:T{
+.sp
+Hour of day
+T}:T{
+.sp
+String
+T}
+.TE
+.sp 1
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&31.\ \&Meta expression specific types
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Type
+T}:T{
+Description
+T}
+.T&
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+iface_index
+T}:T{
+.sp
+Interface index (32 bit number)\&. Can be specified numerically or as name of an existing interface\&.
+T}
+T{
+.sp
+ifname
+T}:T{
+.sp
+Interface name (16 byte string)\&. Does not have to exist\&.
+T}
+T{
+.sp
+iface_type
+T}:T{
+.sp
+Interface type (16 bit number)\&.
+T}
+T{
+.sp
+uid
+T}:T{
+.sp
+User ID (32 bit number)\&. Can be specified numerically or as user name\&.
+T}
+T{
+.sp
+gid
+T}:T{
+.sp
+Group ID (32 bit number)\&. Can be specified numerically or as group name\&.
+T}
+T{
+.sp
+realm
+T}:T{
+.sp
+Routing Realm (32 bit number)\&. Can be specified numerically or as symbolic name defined in /etc/iproute2/rt_realms\&.
+T}
+T{
+.sp
+devgroup_type
+T}:T{
+.sp
+Device group (32 bit number)\&. Can be specified numerically or as symbolic name defined in /etc/iproute2/group\&.
+T}
+T{
+.sp
+pkt_type
+T}:T{
+.sp
+Packet type: \fBhost\fR (addressed to local host), \fBbroadcast\fR (to all), \fBmulticast\fR (to group), \fBother\fR (addressed to another host)\&.
+T}
+T{
+.sp
+ifkind
+T}:T{
+.sp
+Interface kind (16 byte string)\&. See TYPES in ip\-link(8) for a list\&.
+T}
+T{
+.sp
+time
+T}:T{
+.sp
+Either an integer or a date in ISO format\&. For example: "2019\-06\-06 17:00"\&. Hour and seconds are optional and can be omitted if desired\&. If omitted, midnight will be assumed\&. The following three would be equivalent: "2019\-06\-06", "2019\-06\-06 00:00" and "2019\-06\-06 00:00:00"\&. When an integer is given, it is assumed to be a UNIX timestamp\&.
+T}
+T{
+.sp
+day
+T}:T{
+.sp
+Either a day of week ("Monday", "Tuesday", etc\&.), or an integer between 0 and 6\&. Strings are matched case\-insensitively, and a full match is not expected (e\&.g\&. "Mon" would match "Monday")\&. When an integer is given, 0 is Sunday and 6 is Saturday\&.
+T}
+T{
+.sp
+hour
+T}:T{
+.sp
+A string representing an hour in 24\-hour format\&. Seconds can optionally be specified\&. For example, 17:00 and 17:00:00 would be equivalent\&.
+T}
+.TE
+.sp 1
+.PP
+\fBUsing meta expressions\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# qualified meta expression
+filter output meta oif eth0
+filter forward meta iifkind { "tun", "veth" }
+
+# unqualified meta expression
+filter output oif eth0
+
+# incoming packet was subject to ipsec processing
+raw prerouting meta ipsec exists accept
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "SOCKET EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBsocket\fR {\fBtransparent\fR | \fBmark\fR | \fBwildcard\fR}
+\fBsocket\fR \fBcgroupv2\fR \fBlevel\fR \fINUM\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Socket expression can be used to search for an existing open TCP/UDP socket and its attributes that can be associated with a packet\&. It looks for an established or non\-zero bound listening socket (possibly with a non\-local address)\&. You can also use it to match on the socket cgroupv2 at a given ancestor level, e\&.g\&. if the socket belongs to cgroupv2 \fIa/b\fR, ancestor level 1 checks for a matching on cgroup \fIa\fR and ancestor level 2 checks for a matching on cgroup \fIb\fR\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&32.\ \&Available socket attributes
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Name
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+transparent
+T}:T{
+.sp
+Value of the IP_TRANSPARENT socket option in the found socket\&. It can be 0 or 1\&.
+T}:T{
+.sp
+boolean (1 bit)
+T}
+T{
+.sp
+mark
+T}:T{
+.sp
+Value of the socket mark (SOL_SOCKET, SO_MARK)\&.
+T}:T{
+.sp
+mark
+T}
+T{
+.sp
+wildcard
+T}:T{
+.sp
+Indicates whether the socket is wildcard\-bound (e\&.g\&. 0\&.0\&.0\&.0 or ::0)\&.
+T}:T{
+.sp
+boolean (1 bit)
+T}
+T{
+.sp
+cgroupv2
+T}:T{
+.sp
+cgroup version 2 for this socket (path from /sys/fs/cgroup)
+T}:T{
+.sp
+cgroupv2
+T}
+.TE
+.sp 1
+.PP
+\fBUsing socket expression\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# Mark packets that correspond to a transparent socket\&. "socket wildcard 0"
+# means that zero\-bound listener sockets are NOT matched (which is usually
+# exactly what you want)\&.
+table inet x {
+ chain y {
+ type filter hook prerouting priority mangle; policy accept;
+ socket transparent 1 socket wildcard 0 mark set 0x00000001 accept
+ }
+}
+
+# Trace packets that corresponds to a socket with a mark value of 15
+table inet x {
+ chain y {
+ type filter hook prerouting priority mangle; policy accept;
+ socket mark 0x0000000f nftrace set 1
+ }
+}
+
+# Set packet mark to socket mark
+table inet x {
+ chain y {
+ type filter hook prerouting priority mangle; policy accept;
+ tcp dport 8080 mark set socket mark
+ }
+}
+
+# Count packets for cgroupv2 "user\&.slice" at level 1
+table inet x {
+ chain y {
+ type filter hook input priority filter; policy accept;
+ socket cgroupv2 level 1 "user\&.slice" counter
+ }
+}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "OSF EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBosf\fR [\fBttl\fR {\fBloose\fR | \fBskip\fR}] {\fBname\fR | \fBversion\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The osf expression does passive operating system fingerprinting\&. This expression compares some data (Window Size, MSS, options and their order, DF, and others) from packets with the SYN bit set\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&33.\ \&Available osf attributes
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Name
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+ttl
+T}:T{
+.sp
+Do TTL checks on the packet to determine the operating system\&.
+T}:T{
+.sp
+string
+T}
+T{
+.sp
+version
+T}:T{
+.sp
+Do OS version checks on the packet\&.
+T}:T{
+.sp
+T}
+T{
+.sp
+name
+T}:T{
+.sp
+Name of the OS signature to match\&. All signatures can be found at pf\&.os file\&. Use "unknown" for OS signatures that the expression could not detect\&.
+T}:T{
+.sp
+string
+T}
+.TE
+.sp 1
+.PP
+\fBAvailable ttl values\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+If no TTL attribute is passed, make a true IP header and fingerprint TTL true comparison\&. This generally works for LANs\&.
+
+* loose: Check if the IP header\*(Aqs TTL is less than the fingerprint one\&. Works for globally\-routable addresses\&.
+* skip: Do not compare the TTL at all\&.
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBUsing osf expression\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# Accept packets that match the "Linux" OS genre signature without comparing TTL\&.
+table inet x {
+ chain y {
+ type filter hook input priority filter; policy accept;
+ osf ttl skip name "Linux"
+ }
+}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "FIB EXPRESSIONS"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBfib\fR {\fBsaddr\fR | \fBdaddr\fR | \fBmark\fR | \fBiif\fR | \fBoif\fR} [\fB\&.\fR \&...] {\fBoif\fR | \fBoifname\fR | \fBtype\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+A fib expression queries the fib (forwarding information base) to obtain information such as the output interface index a particular address would use\&. The input is a tuple of elements that is used as input to the fib lookup functions\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&34.\ \&fib expression specific types
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+oif
+T}:T{
+.sp
+Output interface index
+T}:T{
+.sp
+integer (32 bit)
+T}
+T{
+.sp
+oifname
+T}:T{
+.sp
+Output interface name
+T}:T{
+.sp
+string
+T}
+T{
+.sp
+type
+T}:T{
+.sp
+Address type
+T}:T{
+.sp
+fib_addrtype
+T}
+.TE
+.sp 1
+.sp
+Use \fBnft\fR \fBdescribe\fR \fBfib_addrtype\fR to get a list of all address types\&.
+.PP
+\fBUsing fib expressions\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# drop packets without a reverse path
+filter prerouting fib saddr \&. iif oif missing drop
+
+In this example, \*(Aqsaddr \&. iif\*(Aq looks up routing information based on the source address and the input interface\&.
+oif picks the output interface index from the routing information\&.
+If no route was found for the source address/input interface combination, the output interface index is zero\&.
+In case the input interface is specified as part of the input key, the output interface index is always the same as the input interface index or zero\&.
+If only \*(Aqsaddr oif\*(Aq is given, then oif can be any interface index or zero\&.
+
+# drop packets to address not configured on incoming interface
+filter prerouting fib daddr \&. iif type != { local, broadcast, multicast } drop
+
+# perform lookup in a specific \*(Aqblackhole\*(Aq table (0xdead, needs ip appropriate ip rule)
+filter prerouting meta mark set 0xdead fib daddr \&. mark type vmap { blackhole : drop, prohibit : jump prohibited, unreachable : drop }
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "ROUTING EXPRESSIONS"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBrt\fR [\fBip\fR | \fBip6\fR] {\fBclassid\fR | \fBnexthop\fR | \fBmtu\fR | \fBipsec\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+A routing expression refers to routing data associated with a packet\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&35.\ \&Routing expression types
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+classid
+T}:T{
+.sp
+Routing realm
+T}:T{
+.sp
+realm
+T}
+T{
+.sp
+nexthop
+T}:T{
+.sp
+Routing nexthop
+T}:T{
+.sp
+ipv4_addr/ipv6_addr
+T}
+T{
+.sp
+mtu
+T}:T{
+.sp
+TCP maximum segment size of route
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+ipsec
+T}:T{
+.sp
+route via ipsec tunnel or transport
+T}:T{
+.sp
+boolean
+T}
+.TE
+.sp 1
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&36.\ \&Routing expression specific types
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Type
+T}:T{
+Description
+T}
+.T&
+lt lt.
+T{
+.sp
+realm
+T}:T{
+.sp
+Routing Realm (32 bit number)\&. Can be specified numerically or as symbolic name defined in /etc/iproute2/rt_realms\&.
+T}
+.TE
+.sp 1
+.PP
+\fBUsing routing expressions\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# IP family independent rt expression
+filter output rt classid 10
+
+# IP family dependent rt expressions
+ip filter output rt nexthop 192\&.168\&.0\&.1
+ip6 filter output rt nexthop fd00::1
+inet filter output rt ip nexthop 192\&.168\&.0\&.1
+inet filter output rt ip6 nexthop fd00::1
+
+# outgoing packet will be encapsulated/encrypted by ipsec
+filter output rt ipsec exists
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "IPSEC EXPRESSIONS"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBipsec\fR {\fBin\fR | \fBout\fR} [ \fBspnum\fR \fINUM\fR ] {\fBreqid\fR | \fBspi\fR}
+\fBipsec\fR {\fBin\fR | \fBout\fR} [ \fBspnum\fR \fINUM\fR ] {\fBip\fR | \fBip6\fR} {\fBsaddr\fR | \fBdaddr\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+An ipsec expression refers to ipsec data associated with a packet\&.
+.sp
+The \fIin\fR or \fIout\fR keyword needs to be used to specify if the expression should examine inbound or outbound policies\&. The \fIin\fR keyword can be used in the prerouting, input and forward hooks\&. The \fIout\fR keyword applies to forward, output and postrouting hooks\&. The optional keyword spnum can be used to match a specific state in a chain, it defaults to 0\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&37.\ \&Ipsec expression types
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+reqid
+T}:T{
+.sp
+Request ID
+T}:T{
+.sp
+integer (32 bit)
+T}
+T{
+.sp
+spi
+T}:T{
+.sp
+Security Parameter Index
+T}:T{
+.sp
+integer (32 bit)
+T}
+T{
+.sp
+saddr
+T}:T{
+.sp
+Source address of the tunnel
+T}:T{
+.sp
+ipv4_addr/ipv6_addr
+T}
+T{
+.sp
+daddr
+T}:T{
+.sp
+Destination address of the tunnel
+T}:T{
+.sp
+ipv4_addr/ipv6_addr
+T}
+.TE
+.sp 1
+.sp
+\fBNote:\fR When using xfrm_interface, this expression is not useable in output hook as the plain packet does not traverse it with IPsec info attached \- use a chain in postrouting hook instead\&.
+.SS "NUMGEN EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBnumgen\fR {\fBinc\fR | \fBrandom\fR} \fBmod\fR \fINUM\fR [ \fBoffset\fR \fINUM\fR ]
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Create a number generator\&. The \fBinc\fR or \fBrandom\fR keywords control its operation mode: In \fBinc\fR mode, the last returned value is simply incremented\&. In \fBrandom\fR mode, a new random number is returned\&. The value after \fBmod\fR keyword specifies an upper boundary (read: modulus) which is not reached by returned numbers\&. The optional \fBoffset\fR allows one to increment the returned value by a fixed offset\&.
+.sp
+A typical use\-case for \fBnumgen\fR is load\-balancing:
+.PP
+\fBUsing numgen expression\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# round\-robin between 192\&.168\&.10\&.100 and 192\&.168\&.20\&.200:
+add rule nat prerouting dnat to numgen inc mod 2 map \e
+ { 0 : 192\&.168\&.10\&.100, 1 : 192\&.168\&.20\&.200 }
+
+# probability\-based with odd bias using intervals:
+add rule nat prerouting dnat to numgen random mod 10 map \e
+ { 0\-2 : 192\&.168\&.10\&.100, 3\-9 : 192\&.168\&.20\&.200 }
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "HASH EXPRESSIONS"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBjhash\fR {\fBip saddr\fR | \fBip6 daddr\fR | \fBtcp dport\fR | \fBudp sport\fR | \fBether saddr\fR} [\fB\&.\fR \&...] \fBmod\fR \fINUM\fR [ \fBseed\fR \fINUM\fR ] [ \fBoffset\fR \fINUM\fR ]
+\fBsymhash\fR \fBmod\fR \fINUM\fR [ \fBoffset\fR \fINUM\fR ]
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Use a hashing function to generate a number\&. The functions available are \fBjhash\fR, known as Jenkins Hash, and \fBsymhash\fR, for Symmetric Hash\&. The \fBjhash\fR requires an expression to determine the parameters of the packet header to apply the hashing, concatenations are possible as well\&. The value after \fBmod\fR keyword specifies an upper boundary (read: modulus) which is not reached by returned numbers\&. The optional \fBseed\fR is used to specify an init value used as seed in the hashing function\&. The optional \fBoffset\fR allows one to increment the returned value by a fixed offset\&.
+.sp
+A typical use\-case for \fBjhash\fR and \fBsymhash\fR is load\-balancing:
+.PP
+\fBUsing hash expressions\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# load balance based on source ip between 2 ip addresses:
+add rule nat prerouting dnat to jhash ip saddr mod 2 map \e
+ { 0 : 192\&.168\&.10\&.100, 1 : 192\&.168\&.20\&.200 }
+
+# symmetric load balancing between 2 ip addresses:
+add rule nat prerouting dnat to symhash mod 2 map \e
+ { 0 : 192\&.168\&.10\&.100, 1 : 192\&.168\&.20\&.200 }
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SH "PAYLOAD EXPRESSIONS"
+.sp
+Payload expressions refer to data from the packet\(cqs payload\&.
+.SS "ETHERNET HEADER EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBether\fR {\fBdaddr\fR | \fBsaddr\fR | \fBtype\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&38.\ \&Ethernet header expression types
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+daddr
+T}:T{
+.sp
+Destination MAC address
+T}:T{
+.sp
+ether_addr
+T}
+T{
+.sp
+saddr
+T}:T{
+.sp
+Source MAC address
+T}:T{
+.sp
+ether_addr
+T}
+T{
+.sp
+type
+T}:T{
+.sp
+EtherType
+T}:T{
+.sp
+ether_type
+T}
+.TE
+.sp 1
+.SS "VLAN HEADER EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBvlan\fR {\fBid\fR | \fBdei\fR | \fBpcp\fR | \fBtype\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The vlan expression is used to match on the vlan header fields\&. This expression will not work in the \fBip\fR, \fBip6\fR and \fBinet\fR families, unless the vlan interface is configured with the \fBreorder_hdr off\fR setting\&. The default is \fBreorder_hdr on\fR which will automatically remove the vlan tag from the packet\&. See ip\-link(8) for more information\&. For these families its easier to match the vlan interface name instead, using the \fBmeta iif\fR or \fBmeta iifname\fR expression\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&39.\ \&VLAN header expression
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+id
+T}:T{
+.sp
+VLAN ID (VID)
+T}:T{
+.sp
+integer (12 bit)
+T}
+T{
+.sp
+dei
+T}:T{
+.sp
+Drop Eligible Indicator
+T}:T{
+.sp
+integer (1 bit)
+T}
+T{
+.sp
+pcp
+T}:T{
+.sp
+Priority code point
+T}:T{
+.sp
+integer (3 bit)
+T}
+T{
+.sp
+type
+T}:T{
+.sp
+EtherType
+T}:T{
+.sp
+ether_type
+T}
+.TE
+.sp 1
+.SS "ARP HEADER EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBarp\fR {\fBhtype\fR | \fBptype\fR | \fBhlen\fR | \fBplen\fR | \fBoperation\fR | \fBsaddr\fR { \fBip\fR | \fBether\fR } | \fBdaddr\fR { \fBip\fR | \fBether\fR }
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&40.\ \&ARP header expression
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+htype
+T}:T{
+.sp
+ARP hardware type
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+ptype
+T}:T{
+.sp
+EtherType
+T}:T{
+.sp
+ether_type
+T}
+T{
+.sp
+hlen
+T}:T{
+.sp
+Hardware address len
+T}:T{
+.sp
+integer (8 bit)
+T}
+T{
+.sp
+plen
+T}:T{
+.sp
+Protocol address len
+T}:T{
+.sp
+integer (8 bit)
+T}
+T{
+.sp
+operation
+T}:T{
+.sp
+Operation
+T}:T{
+.sp
+arp_op
+T}
+T{
+.sp
+saddr ether
+T}:T{
+.sp
+Ethernet sender address
+T}:T{
+.sp
+ether_addr
+T}
+T{
+.sp
+daddr ether
+T}:T{
+.sp
+Ethernet target address
+T}:T{
+.sp
+ether_addr
+T}
+T{
+.sp
+saddr ip
+T}:T{
+.sp
+IPv4 sender address
+T}:T{
+.sp
+ipv4_addr
+T}
+T{
+.sp
+daddr ip
+T}:T{
+.sp
+IPv4 target address
+T}:T{
+.sp
+ipv4_addr
+T}
+.TE
+.sp 1
+.SS "IPV4 HEADER EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBip\fR {\fBversion\fR | \fBhdrlength\fR | \fBdscp\fR | \fBecn\fR | \fBlength\fR | \fBid\fR | \fBfrag\-off\fR | \fBttl\fR | \fBprotocol\fR | \fBchecksum\fR | \fBsaddr\fR | \fBdaddr\fR }
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&41.\ \&IPv4 header expression
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+version
+T}:T{
+.sp
+IP header version (4)
+T}:T{
+.sp
+integer (4 bit)
+T}
+T{
+.sp
+hdrlength
+T}:T{
+.sp
+IP header length including options
+T}:T{
+.sp
+integer (4 bit) FIXME scaling
+T}
+T{
+.sp
+dscp
+T}:T{
+.sp
+Differentiated Services Code Point
+T}:T{
+.sp
+dscp
+T}
+T{
+.sp
+ecn
+T}:T{
+.sp
+Explicit Congestion Notification
+T}:T{
+.sp
+ecn
+T}
+T{
+.sp
+length
+T}:T{
+.sp
+Total packet length
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+id
+T}:T{
+.sp
+IP ID
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+frag\-off
+T}:T{
+.sp
+Fragment offset
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+ttl
+T}:T{
+.sp
+Time to live
+T}:T{
+.sp
+integer (8 bit)
+T}
+T{
+.sp
+protocol
+T}:T{
+.sp
+Upper layer protocol
+T}:T{
+.sp
+inet_proto
+T}
+T{
+.sp
+checksum
+T}:T{
+.sp
+IP header checksum
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+saddr
+T}:T{
+.sp
+Source address
+T}:T{
+.sp
+ipv4_addr
+T}
+T{
+.sp
+daddr
+T}:T{
+.sp
+Destination address
+T}:T{
+.sp
+ipv4_addr
+T}
+.TE
+.sp 1
+.sp
+Careful with matching on \fBip length\fR: If GRO/GSO is enabled, then the Linux kernel might aggregate several packets into one big packet that is larger than MTU\&. Moreover, if GRO/GSO maximum size is larger than 65535 (see man ip\-link(8), specifically gro_ipv6_max_size and gso_ipv6_max_size), then \fBip length\fR might be 0 for such jumbo packets\&. \fBmeta length\fR allows you to match on the packet length including the IP header size\&. If you want to perform heuristics on the \fBip length\fR field, then disable GRO/GSO\&.
+.SS "ICMP HEADER EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBicmp\fR {\fBtype\fR | \fBcode\fR | \fBchecksum\fR | \fBid\fR | \fBsequence\fR | \fBgateway\fR | \fBmtu\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This expression refers to ICMP header fields\&. When using it in \fBinet\fR, \fBbridge\fR or \fBnetdev\fR families, it will cause an implicit dependency on IPv4 to be created\&. To match on unusual cases like ICMP over IPv6, one has to add an explicit \fBmeta protocol ip6\fR match to the rule\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&42.\ \&ICMP header expression
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+type
+T}:T{
+.sp
+ICMP type field
+T}:T{
+.sp
+icmp_type
+T}
+T{
+.sp
+code
+T}:T{
+.sp
+ICMP code field
+T}:T{
+.sp
+integer (8 bit)
+T}
+T{
+.sp
+checksum
+T}:T{
+.sp
+ICMP checksum field
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+id
+T}:T{
+.sp
+ID of echo request/response
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+sequence
+T}:T{
+.sp
+sequence number of echo request/response
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+gateway
+T}:T{
+.sp
+gateway of redirects
+T}:T{
+.sp
+integer (32 bit)
+T}
+T{
+.sp
+mtu
+T}:T{
+.sp
+MTU of path MTU discovery
+T}:T{
+.sp
+integer (16 bit)
+T}
+.TE
+.sp 1
+.SS "IGMP HEADER EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBigmp\fR {\fBtype\fR | \fBmrt\fR | \fBchecksum\fR | \fBgroup\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This expression refers to IGMP header fields\&. When using it in \fBinet\fR, \fBbridge\fR or \fBnetdev\fR families, it will cause an implicit dependency on IPv4 to be created\&. To match on unusual cases like IGMP over IPv6, one has to add an explicit \fBmeta protocol ip6\fR match to the rule\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&43.\ \&IGMP header expression
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+type
+T}:T{
+.sp
+IGMP type field
+T}:T{
+.sp
+igmp_type
+T}
+T{
+.sp
+mrt
+T}:T{
+.sp
+IGMP maximum response time field
+T}:T{
+.sp
+integer (8 bit)
+T}
+T{
+.sp
+checksum
+T}:T{
+.sp
+IGMP checksum field
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+group
+T}:T{
+.sp
+Group address
+T}:T{
+.sp
+integer (32 bit)
+T}
+.TE
+.sp 1
+.SS "IPV6 HEADER EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBip6\fR {\fBversion\fR | \fBdscp\fR | \fBecn\fR | \fBflowlabel\fR | \fBlength\fR | \fBnexthdr\fR | \fBhoplimit\fR | \fBsaddr\fR | \fBdaddr\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This expression refers to the ipv6 header fields\&. Caution when using \fBip6 nexthdr\fR, the value only refers to the next header, i\&.e\&. \fBip6 nexthdr tcp\fR will only match if the ipv6 packet does not contain any extension headers\&. Packets that are fragmented or e\&.g\&. contain a routing extension headers will not be matched\&. Please use \fBmeta l4proto\fR if you wish to match the real transport header and ignore any additional extension headers instead\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&44.\ \&IPv6 header expression
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+version
+T}:T{
+.sp
+IP header version (6)
+T}:T{
+.sp
+integer (4 bit)
+T}
+T{
+.sp
+dscp
+T}:T{
+.sp
+Differentiated Services Code Point
+T}:T{
+.sp
+dscp
+T}
+T{
+.sp
+ecn
+T}:T{
+.sp
+Explicit Congestion Notification
+T}:T{
+.sp
+ecn
+T}
+T{
+.sp
+flowlabel
+T}:T{
+.sp
+Flow label
+T}:T{
+.sp
+integer (20 bit)
+T}
+T{
+.sp
+length
+T}:T{
+.sp
+Payload length
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+nexthdr
+T}:T{
+.sp
+Nexthdr protocol
+T}:T{
+.sp
+inet_proto
+T}
+T{
+.sp
+hoplimit
+T}:T{
+.sp
+Hop limit
+T}:T{
+.sp
+integer (8 bit)
+T}
+T{
+.sp
+saddr
+T}:T{
+.sp
+Source address
+T}:T{
+.sp
+ipv6_addr
+T}
+T{
+.sp
+daddr
+T}:T{
+.sp
+Destination address
+T}:T{
+.sp
+ipv6_addr
+T}
+.TE
+.sp 1
+.sp
+Careful with matching on \fBip6 length\fR: If GRO/GSO is enabled, then the Linux kernel might aggregate several packets into one big packet that is larger than MTU\&. Moreover, if GRO/GSO maximum size is larger than 65535 (see man ip\-link(8), specifically gro_ipv6_max_size and gso_ipv6_max_size), then \fBip6 length\fR might be 0 for such jumbo packets\&. \fBmeta length\fR allows you to match on the packet length including the IP header size\&. If you want to perform heuristics on the \fBip6 length\fR field, then disable GRO/GSO\&.
+.PP
+\fBUsing ip6 header expressions\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# matching if first extension header indicates a fragment
+ip6 nexthdr ipv6\-frag
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "ICMPV6 HEADER EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBicmpv6\fR {\fBtype\fR | \fBcode\fR | \fBchecksum\fR | \fBparameter\-problem\fR | \fBpacket\-too\-big\fR | \fBid\fR | \fBsequence\fR | \fBmax\-delay\fR | \fBtaddr\fR | \fBdaddr\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This expression refers to ICMPv6 header fields\&. When using it in \fBinet\fR, \fBbridge\fR or \fBnetdev\fR families, it will cause an implicit dependency on IPv6 to be created\&. To match on unusual cases like ICMPv6 over IPv4, one has to add an explicit \fBmeta protocol ip\fR match to the rule\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&45.\ \&ICMPv6 header expression
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+type
+T}:T{
+.sp
+ICMPv6 type field
+T}:T{
+.sp
+icmpv6_type
+T}
+T{
+.sp
+code
+T}:T{
+.sp
+ICMPv6 code field
+T}:T{
+.sp
+integer (8 bit)
+T}
+T{
+.sp
+checksum
+T}:T{
+.sp
+ICMPv6 checksum field
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+parameter\-problem
+T}:T{
+.sp
+pointer to problem
+T}:T{
+.sp
+integer (32 bit)
+T}
+T{
+.sp
+packet\-too\-big
+T}:T{
+.sp
+oversized MTU
+T}:T{
+.sp
+integer (32 bit)
+T}
+T{
+.sp
+id
+T}:T{
+.sp
+ID of echo request/response
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+sequence
+T}:T{
+.sp
+sequence number of echo request/response
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+max\-delay
+T}:T{
+.sp
+maximum response delay of MLD queries
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+taddr
+T}:T{
+.sp
+target address of neighbor solicit/advert, redirect or MLD
+T}:T{
+.sp
+ipv6_addr
+T}
+T{
+.sp
+daddr
+T}:T{
+.sp
+destination address of redirect
+T}:T{
+.sp
+ipv6_addr
+T}
+.TE
+.sp 1
+.SS "TCP HEADER EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBtcp\fR {\fBsport\fR | \fBdport\fR | \fBsequence\fR | \fBackseq\fR | \fBdoff\fR | \fBreserved\fR | \fBflags\fR | \fBwindow\fR | \fBchecksum\fR | \fBurgptr\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&46.\ \&TCP header expression
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+sport
+T}:T{
+.sp
+Source port
+T}:T{
+.sp
+inet_service
+T}
+T{
+.sp
+dport
+T}:T{
+.sp
+Destination port
+T}:T{
+.sp
+inet_service
+T}
+T{
+.sp
+sequence
+T}:T{
+.sp
+Sequence number
+T}:T{
+.sp
+integer (32 bit)
+T}
+T{
+.sp
+ackseq
+T}:T{
+.sp
+Acknowledgement number
+T}:T{
+.sp
+integer (32 bit)
+T}
+T{
+.sp
+doff
+T}:T{
+.sp
+Data offset
+T}:T{
+.sp
+integer (4 bit) FIXME scaling
+T}
+T{
+.sp
+reserved
+T}:T{
+.sp
+Reserved area
+T}:T{
+.sp
+integer (4 bit)
+T}
+T{
+.sp
+flags
+T}:T{
+.sp
+TCP flags
+T}:T{
+.sp
+tcp_flag
+T}
+T{
+.sp
+window
+T}:T{
+.sp
+Window
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+checksum
+T}:T{
+.sp
+Checksum
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+urgptr
+T}:T{
+.sp
+Urgent pointer
+T}:T{
+.sp
+integer (16 bit)
+T}
+.TE
+.sp 1
+.SS "UDP HEADER EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBudp\fR {\fBsport\fR | \fBdport\fR | \fBlength\fR | \fBchecksum\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&47.\ \&UDP header expression
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+sport
+T}:T{
+.sp
+Source port
+T}:T{
+.sp
+inet_service
+T}
+T{
+.sp
+dport
+T}:T{
+.sp
+Destination port
+T}:T{
+.sp
+inet_service
+T}
+T{
+.sp
+length
+T}:T{
+.sp
+Total packet length
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+checksum
+T}:T{
+.sp
+Checksum
+T}:T{
+.sp
+integer (16 bit)
+T}
+.TE
+.sp 1
+.SS "UDP\-LITE HEADER EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBudplite\fR {\fBsport\fR | \fBdport\fR | \fBchecksum\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&48.\ \&UDP\-Lite header expression
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+sport
+T}:T{
+.sp
+Source port
+T}:T{
+.sp
+inet_service
+T}
+T{
+.sp
+dport
+T}:T{
+.sp
+Destination port
+T}:T{
+.sp
+inet_service
+T}
+T{
+.sp
+checksum
+T}:T{
+.sp
+Checksum
+T}:T{
+.sp
+integer (16 bit)
+T}
+.TE
+.sp 1
+.SS "SCTP HEADER EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBsctp\fR {\fBsport\fR | \fBdport\fR | \fBvtag\fR | \fBchecksum\fR}
+\fBsctp chunk\fR \fICHUNK\fR [ \fIFIELD\fR ]
+
+\fICHUNK\fR := \fBdata\fR | \fBinit\fR | \fBinit\-ack\fR | \fBsack\fR | \fBheartbeat\fR |
+ \fBheartbeat\-ack\fR | \fBabort\fR | \fBshutdown\fR | \fBshutdown\-ack\fR | \fBerror\fR |
+ \fBcookie\-echo\fR | \fBcookie\-ack\fR | \fBecne\fR | \fBcwr\fR | \fBshutdown\-complete\fR
+ | \fBasconf\-ack\fR | \fBforward\-tsn\fR | \fBasconf\fR
+
+\fIFIELD\fR := \fICOMMON_FIELD\fR | \fIDATA_FIELD\fR | \fIINIT_FIELD\fR | \fIINIT_ACK_FIELD\fR |
+ \fISACK_FIELD\fR | \fISHUTDOWN_FIELD\fR | \fIECNE_FIELD\fR | \fICWR_FIELD\fR |
+ \fIASCONF_ACK_FIELD\fR | \fIFORWARD_TSN_FIELD\fR | \fIASCONF_FIELD\fR
+
+\fICOMMON_FIELD\fR := \fBtype\fR | \fBflags\fR | \fBlength\fR
+\fIDATA_FIELD\fR := \fBtsn\fR | \fBstream\fR | \fBssn\fR | \fBppid\fR
+\fIINIT_FIELD\fR := \fBinit\-tag\fR | \fBa\-rwnd\fR | \fBnum\-outbound\-streams\fR |
+ \fBnum\-inbound\-streams\fR | \fBinitial\-tsn\fR
+\fIINIT_ACK_FIELD\fR := \fIINIT_FIELD\fR
+\fISACK_FIELD\fR := \fBcum\-tsn\-ack\fR | \fBa\-rwnd\fR | \fBnum\-gap\-ack\-blocks\fR |
+ \fBnum\-dup\-tsns\fR
+\fISHUTDOWN_FIELD\fR := \fBcum\-tsn\-ack\fR
+\fIECNE_FIELD\fR := \fBlowest\-tsn\fR
+\fICWR_FIELD\fR := \fBlowest\-tsn\fR
+\fIASCONF_ACK_FIELD\fR := \fBseqno\fR
+\fIFORWARD_TSN_FIELD\fR := \fBnew\-cum\-tsn\fR
+\fIASCONF_FIELD\fR := \fBseqno\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&49.\ \&SCTP header expression
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+sport
+T}:T{
+.sp
+Source port
+T}:T{
+.sp
+inet_service
+T}
+T{
+.sp
+dport
+T}:T{
+.sp
+Destination port
+T}:T{
+.sp
+inet_service
+T}
+T{
+.sp
+vtag
+T}:T{
+.sp
+Verification Tag
+T}:T{
+.sp
+integer (32 bit)
+T}
+T{
+.sp
+checksum
+T}:T{
+.sp
+Checksum
+T}:T{
+.sp
+integer (32 bit)
+T}
+T{
+.sp
+chunk
+T}:T{
+.sp
+Search chunk in packet
+T}:T{
+.sp
+without \fIFIELD\fR, boolean indicating existence
+T}
+.TE
+.sp 1
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&50.\ \&SCTP chunk fields
+.TS
+allbox tab(:);
+ltB ltB ltB ltB.
+T{
+Name
+T}:T{
+Width in bits
+T}:T{
+Chunk
+T}:T{
+Notes
+T}
+.T&
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt
+lt lt lt lt.
+T{
+.sp
+type
+T}:T{
+.sp
+8
+T}:T{
+.sp
+all
+T}:T{
+.sp
+not useful, defined by chunk type
+T}
+T{
+.sp
+flags
+T}:T{
+.sp
+8
+T}:T{
+.sp
+all
+T}:T{
+.sp
+semantics defined on per\-chunk basis
+T}
+T{
+.sp
+length
+T}:T{
+.sp
+16
+T}:T{
+.sp
+all
+T}:T{
+.sp
+length of this chunk in bytes excluding padding
+T}
+T{
+.sp
+tsn
+T}:T{
+.sp
+32
+T}:T{
+.sp
+data
+T}:T{
+.sp
+transmission sequence number
+T}
+T{
+.sp
+stream
+T}:T{
+.sp
+16
+T}:T{
+.sp
+data
+T}:T{
+.sp
+stream identifier
+T}
+T{
+.sp
+ssn
+T}:T{
+.sp
+16
+T}:T{
+.sp
+data
+T}:T{
+.sp
+stream sequence number
+T}
+T{
+.sp
+ppid
+T}:T{
+.sp
+32
+T}:T{
+.sp
+data
+T}:T{
+.sp
+payload protocol identifier
+T}
+T{
+.sp
+init\-tag
+T}:T{
+.sp
+32
+T}:T{
+.sp
+init, init\-ack
+T}:T{
+.sp
+initiate tag
+T}
+T{
+.sp
+a\-rwnd
+T}:T{
+.sp
+32
+T}:T{
+.sp
+init, init\-ack, sack
+T}:T{
+.sp
+advertised receiver window credit
+T}
+T{
+.sp
+num\-outbound\-streams
+T}:T{
+.sp
+16
+T}:T{
+.sp
+init, init\-ack
+T}:T{
+.sp
+number of outbound streams
+T}
+T{
+.sp
+num\-inbound\-streams
+T}:T{
+.sp
+16
+T}:T{
+.sp
+init, init\-ack
+T}:T{
+.sp
+number of inbound streams
+T}
+T{
+.sp
+initial\-tsn
+T}:T{
+.sp
+32
+T}:T{
+.sp
+init, init\-ack
+T}:T{
+.sp
+initial transmit sequence number
+T}
+T{
+.sp
+cum\-tsn\-ack
+T}:T{
+.sp
+32
+T}:T{
+.sp
+sack, shutdown
+T}:T{
+.sp
+cumulative transmission sequence number acknowledged
+T}
+T{
+.sp
+num\-gap\-ack\-blocks
+T}:T{
+.sp
+16
+T}:T{
+.sp
+sack
+T}:T{
+.sp
+number of Gap Ack Blocks included
+T}
+T{
+.sp
+num\-dup\-tsns
+T}:T{
+.sp
+16
+T}:T{
+.sp
+sack
+T}:T{
+.sp
+number of duplicate transmission sequence numbers received
+T}
+T{
+.sp
+lowest\-tsn
+T}:T{
+.sp
+32
+T}:T{
+.sp
+ecne, cwr
+T}:T{
+.sp
+lowest transmission sequence number
+T}
+T{
+.sp
+seqno
+T}:T{
+.sp
+32
+T}:T{
+.sp
+asconf\-ack, asconf
+T}:T{
+.sp
+sequence number
+T}
+T{
+.sp
+new\-cum\-tsn
+T}:T{
+.sp
+32
+T}:T{
+.sp
+forward\-tsn
+T}:T{
+.sp
+new cumulative transmission sequence number
+T}
+.TE
+.sp 1
+.SS "DCCP HEADER EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBdccp\fR {\fBsport\fR | \fBdport\fR | \fBtype\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&51.\ \&DCCP header expression
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+sport
+T}:T{
+.sp
+Source port
+T}:T{
+.sp
+inet_service
+T}
+T{
+.sp
+dport
+T}:T{
+.sp
+Destination port
+T}:T{
+.sp
+inet_service
+T}
+T{
+.sp
+type
+T}:T{
+.sp
+Packet type
+T}:T{
+.sp
+dccp_pkttype
+T}
+.TE
+.sp 1
+.SS "AUTHENTICATION HEADER EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBah\fR {\fBnexthdr\fR | \fBhdrlength\fR | \fBreserved\fR | \fBspi\fR | \fBsequence\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&52.\ \&AH header expression
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+nexthdr
+T}:T{
+.sp
+Next header protocol
+T}:T{
+.sp
+inet_proto
+T}
+T{
+.sp
+hdrlength
+T}:T{
+.sp
+AH Header length
+T}:T{
+.sp
+integer (8 bit)
+T}
+T{
+.sp
+reserved
+T}:T{
+.sp
+Reserved area
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+spi
+T}:T{
+.sp
+Security Parameter Index
+T}:T{
+.sp
+integer (32 bit)
+T}
+T{
+.sp
+sequence
+T}:T{
+.sp
+Sequence number
+T}:T{
+.sp
+integer (32 bit)
+T}
+.TE
+.sp 1
+.SS "ENCRYPTED SECURITY PAYLOAD HEADER EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBesp\fR {\fBspi\fR | \fBsequence\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&53.\ \&ESP header expression
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt.
+T{
+.sp
+spi
+T}:T{
+.sp
+Security Parameter Index
+T}:T{
+.sp
+integer (32 bit)
+T}
+T{
+.sp
+sequence
+T}:T{
+.sp
+Sequence number
+T}:T{
+.sp
+integer (32 bit)
+T}
+.TE
+.sp 1
+.SS "IPCOMP HEADER EXPRESSION"
+.sp
+\fBcomp\fR {\fBnexthdr\fR | \fBflags\fR | \fBcpi\fR}
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&54.\ \&IPComp header expression
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+nexthdr
+T}:T{
+.sp
+Next header protocol
+T}:T{
+.sp
+inet_proto
+T}
+T{
+.sp
+flags
+T}:T{
+.sp
+Flags
+T}:T{
+.sp
+bitmask
+T}
+T{
+.sp
+cpi
+T}:T{
+.sp
+compression Parameter Index
+T}:T{
+.sp
+integer (16 bit)
+T}
+.TE
+.sp 1
+.SS "GRE HEADER EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBgre\fR {\fBflags\fR | \fBversion\fR | \fBprotocol\fR}
+\fBgre\fR \fBip\fR {\fBversion\fR | \fBhdrlength\fR | \fBdscp\fR | \fBecn\fR | \fBlength\fR | \fBid\fR | \fBfrag\-off\fR | \fBttl\fR | \fBprotocol\fR | \fBchecksum\fR | \fBsaddr\fR | \fBdaddr\fR }
+\fBgre\fR \fBip6\fR {\fBversion\fR | \fBdscp\fR | \fBecn\fR | \fBflowlabel\fR | \fBlength\fR | \fBnexthdr\fR | \fBhoplimit\fR | \fBsaddr\fR | \fBdaddr\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The gre expression is used to match on the gre header fields\&. This expression also allows to match on the IPv4 or IPv6 packet within the gre header\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&55.\ \&GRE header expression
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+flags
+T}:T{
+.sp
+checksum, routing, key, sequence and strict source route flags
+T}:T{
+.sp
+integer (5 bit)
+T}
+T{
+.sp
+version
+T}:T{
+.sp
+gre version field, 0 for GRE and 1 for PPTP
+T}:T{
+.sp
+integer (3 bit)
+T}
+T{
+.sp
+protocol
+T}:T{
+.sp
+EtherType of encapsulated packet
+T}:T{
+.sp
+integer (16 bit)
+T}
+.TE
+.sp 1
+.PP
+\fBMatching inner IPv4 destination address encapsulated in gre\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+netdev filter ingress gre ip daddr 9\&.9\&.9\&.9 counter
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "GENEVE HEADER EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBgeneve\fR {\fBvni\fR | \fBflags\fR}
+\fBgeneve\fR \fBether\fR {\fBdaddr\fR | \fBsaddr\fR | \fBtype\fR}
+\fBgeneve\fR \fBvlan\fR {\fBid\fR | \fBdei\fR | \fBpcp\fR | \fBtype\fR}
+\fBgeneve\fR \fBip\fR {\fBversion\fR | \fBhdrlength\fR | \fBdscp\fR | \fBecn\fR | \fBlength\fR | \fBid\fR | \fBfrag\-off\fR | \fBttl\fR | \fBprotocol\fR | \fBchecksum\fR | \fBsaddr\fR | \fBdaddr\fR }
+\fBgeneve\fR \fBip6\fR {\fBversion\fR | \fBdscp\fR | \fBecn\fR | \fBflowlabel\fR | \fBlength\fR | \fBnexthdr\fR | \fBhoplimit\fR | \fBsaddr\fR | \fBdaddr\fR}
+\fBgeneve\fR \fBtcp\fR {\fBsport\fR | \fBdport\fR | \fBsequence\fR | \fBackseq\fR | \fBdoff\fR | \fBreserved\fR | \fBflags\fR | \fBwindow\fR | \fBchecksum\fR | \fBurgptr\fR}
+\fBgeneve\fR \fBudp\fR {\fBsport\fR | \fBdport\fR | \fBlength\fR | \fBchecksum\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The geneve expression is used to match on the geneve header fields\&. The geneve header encapsulates a ethernet frame within a \fBudp\fR packet\&. This expression requires that you restrict the matching to \fBudp\fR packets (usually at port 6081 according to IANA\-assigned ports)\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&56.\ \&GENEVE header expression
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt.
+T{
+.sp
+protocol
+T}:T{
+.sp
+EtherType of encapsulated packet
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+vni
+T}:T{
+.sp
+Virtual Network ID (VNI)
+T}:T{
+.sp
+integer (24 bit)
+T}
+.TE
+.sp 1
+.PP
+\fBMatching inner TCP destination port encapsulated in geneve\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+netdev filter ingress udp dport 4789 geneve tcp dport 80 counter
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "GRETAP HEADER EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBgretap\fR {\fBvni\fR | \fBflags\fR}
+\fBgretap\fR \fBether\fR {\fBdaddr\fR | \fBsaddr\fR | \fBtype\fR}
+\fBgretap\fR \fBvlan\fR {\fBid\fR | \fBdei\fR | \fBpcp\fR | \fBtype\fR}
+\fBgretap\fR \fBip\fR {\fBversion\fR | \fBhdrlength\fR | \fBdscp\fR | \fBecn\fR | \fBlength\fR | \fBid\fR | \fBfrag\-off\fR | \fBttl\fR | \fBprotocol\fR | \fBchecksum\fR | \fBsaddr\fR | \fBdaddr\fR }
+\fBgretap\fR \fBip6\fR {\fBversion\fR | \fBdscp\fR | \fBecn\fR | \fBflowlabel\fR | \fBlength\fR | \fBnexthdr\fR | \fBhoplimit\fR | \fBsaddr\fR | \fBdaddr\fR}
+\fBgretap\fR \fBtcp\fR {\fBsport\fR | \fBdport\fR | \fBsequence\fR | \fBackseq\fR | \fBdoff\fR | \fBreserved\fR | \fBflags\fR | \fBwindow\fR | \fBchecksum\fR | \fBurgptr\fR}
+\fBgretap\fR \fBudp\fR {\fBsport\fR | \fBdport\fR | \fBlength\fR | \fBchecksum\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The gretap expression is used to match on the encapsulated ethernet frame within the gre header\&. Use the \fBgre\fR expression to match on the \fBgre\fR header fields\&.
+.PP
+\fBMatching inner TCP destination port encapsulated in gretap\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+netdev filter ingress gretap tcp dport 80 counter
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "VXLAN HEADER EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBvxlan\fR {\fBvni\fR | \fBflags\fR}
+\fBvxlan\fR \fBether\fR {\fBdaddr\fR | \fBsaddr\fR | \fBtype\fR}
+\fBvxlan\fR \fBvlan\fR {\fBid\fR | \fBdei\fR | \fBpcp\fR | \fBtype\fR}
+\fBvxlan\fR \fBip\fR {\fBversion\fR | \fBhdrlength\fR | \fBdscp\fR | \fBecn\fR | \fBlength\fR | \fBid\fR | \fBfrag\-off\fR | \fBttl\fR | \fBprotocol\fR | \fBchecksum\fR | \fBsaddr\fR | \fBdaddr\fR }
+\fBvxlan\fR \fBip6\fR {\fBversion\fR | \fBdscp\fR | \fBecn\fR | \fBflowlabel\fR | \fBlength\fR | \fBnexthdr\fR | \fBhoplimit\fR | \fBsaddr\fR | \fBdaddr\fR}
+\fBvxlan\fR \fBtcp\fR {\fBsport\fR | \fBdport\fR | \fBsequence\fR | \fBackseq\fR | \fBdoff\fR | \fBreserved\fR | \fBflags\fR | \fBwindow\fR | \fBchecksum\fR | \fBurgptr\fR}
+\fBvxlan\fR \fBudp\fR {\fBsport\fR | \fBdport\fR | \fBlength\fR | \fBchecksum\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The vxlan expression is used to match on the vxlan header fields\&. The vxlan header encapsulates a ethernet frame within a \fBudp\fR packet\&. This expression requires that you restrict the matching to \fBudp\fR packets (usually at port 4789 according to IANA\-assigned ports)\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&57.\ \&VXLAN header expression
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt.
+T{
+.sp
+flags
+T}:T{
+.sp
+vxlan flags
+T}:T{
+.sp
+integer (8 bit)
+T}
+T{
+.sp
+vni
+T}:T{
+.sp
+Virtual Network ID (VNI)
+T}:T{
+.sp
+integer (24 bit)
+T}
+.TE
+.sp 1
+.PP
+\fBMatching inner TCP destination port encapsulated in vxlan\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+netdev filter ingress udp dport 4789 vxlan tcp dport 80 counter
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "ARP HEADER EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBarp\fR {\fBhtype\fR | \fBptype\fR | \fBhlen\fR | \fBplen\fR | \fBoperation\fR | \fBsaddr\fR { \fBip\fR | \fBether\fR } | \fBdaddr\fR { \fBip\fR | \fBether\fR }
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&58.\ \&ARP header expression
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+htype
+T}:T{
+.sp
+ARP hardware type
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+ptype
+T}:T{
+.sp
+EtherType
+T}:T{
+.sp
+ether_type
+T}
+T{
+.sp
+hlen
+T}:T{
+.sp
+Hardware address len
+T}:T{
+.sp
+integer (8 bit)
+T}
+T{
+.sp
+plen
+T}:T{
+.sp
+Protocol address len
+T}:T{
+.sp
+integer (8 bit)
+T}
+T{
+.sp
+operation
+T}:T{
+.sp
+Operation
+T}:T{
+.sp
+arp_op
+T}
+T{
+.sp
+saddr ether
+T}:T{
+.sp
+Ethernet sender address
+T}:T{
+.sp
+ether_addr
+T}
+T{
+.sp
+daddr ether
+T}:T{
+.sp
+Ethernet target address
+T}:T{
+.sp
+ether_addr
+T}
+T{
+.sp
+saddr ip
+T}:T{
+.sp
+IPv4 sender address
+T}:T{
+.sp
+ipv4_addr
+T}
+T{
+.sp
+daddr ip
+T}:T{
+.sp
+IPv4 target address
+T}:T{
+.sp
+ipv4_addr
+T}
+.TE
+.sp 1
+.SS "RAW PAYLOAD EXPRESSION"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fB@\fR\fIbase\fR\fB,\fR\fIoffset\fR\fB,\fR\fIlength\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The raw payload expression instructs to load \fIlength\fR bits starting at \fIoffset\fR bits\&. Bit 0 refers to the very first bit \(em in the C programming language, this corresponds to the topmost bit, i\&.e\&. 0x80 in case of an octet\&. They are useful to match headers that do not have a human\-readable template expression yet\&. Note that nft will not add dependencies for Raw payload expressions\&. If you e\&.g\&. want to match protocol fields of a transport header with protocol number 5, you need to manually exclude packets that have a different transport header, for instance by using \fBmeta l4proto 5\fR before the raw expression\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&59.\ \&Supported payload protocol bases
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Base
+T}:T{
+Description
+T}
+.T&
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+ll
+T}:T{
+.sp
+Link layer, for example the Ethernet header
+T}
+T{
+.sp
+nh
+T}:T{
+.sp
+Network header, for example IPv4 or IPv6
+T}
+T{
+.sp
+th
+T}:T{
+.sp
+Transport Header, for example TCP
+T}
+T{
+.sp
+ih
+T}:T{
+.sp
+Inner Header / Payload, i\&.e\&. after the L4 transport level header
+T}
+.TE
+.sp 1
+.PP
+\fBMatching destination port of both UDP and TCP\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+inet filter input meta l4proto {tcp, udp} @th,16,16 { 53, 80 }
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The above can also be written as
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+inet filter input meta l4proto {tcp, udp} th dport { 53, 80 }
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+it is more convenient, but like the raw expression notation no dependencies are created or checked\&. It is the users responsibility to restrict matching to those header types that have a notion of ports\&. Otherwise, rules using raw expressions will errnously match unrelated packets, e\&.g\&. mis\-interpreting ESP packets SPI field as a port\&.
+.PP
+\fBRewrite arp packet target hardware address if target protocol address matches a given address\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+input meta iifname enp2s0 arp ptype 0x0800 arp htype 1 arp hlen 6 arp plen 4 @nh,192,32 0xc0a88f10 @nh,144,48 set 0x112233445566 accept
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "EXTENSION HEADER EXPRESSIONS"
+.sp
+Extension header expressions refer to data from variable\-sized protocol headers, such as IPv6 extension headers, TCP options and IPv4 options\&.
+.sp
+nftables currently supports matching (finding) a given ipv6 extension header, TCP option or IPv4 option\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBhbh\fR {\fBnexthdr\fR | \fBhdrlength\fR}
+\fBfrag\fR {\fBnexthdr\fR | \fBfrag\-off\fR | \fBmore\-fragments\fR | \fBid\fR}
+\fBrt\fR {\fBnexthdr\fR | \fBhdrlength\fR | \fBtype\fR | \fBseg\-left\fR}
+\fBdst\fR {\fBnexthdr\fR | \fBhdrlength\fR}
+\fBmh\fR {\fBnexthdr\fR | \fBhdrlength\fR | \fBchecksum\fR | \fBtype\fR}
+\fBsrh\fR {\fBflags\fR | \fBtag\fR | \fBsid\fR | \fBseg\-left\fR}
+\fBtcp option\fR {\fBeol\fR | \fBnop\fR | \fBmaxseg\fR | \fBwindow\fR | \fBsack\-perm\fR | \fBsack\fR | \fBsack0\fR | \fBsack1\fR | \fBsack2\fR | \fBsack3\fR | \fBtimestamp\fR} \fItcp_option_field\fR
+\fBip option\fR { lsrr | ra | rr | ssrr } \fIip_option_field\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The following syntaxes are valid only in a relational expression with boolean type on right\-hand side for checking header existence only:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBexthdr\fR {\fBhbh\fR | \fBfrag\fR | \fBrt\fR | \fBdst\fR | \fBmh\fR}
+\fBtcp option\fR {\fBeol\fR | \fBnop\fR | \fBmaxseg\fR | \fBwindow\fR | \fBsack\-perm\fR | \fBsack\fR | \fBsack0\fR | \fBsack1\fR | \fBsack2\fR | \fBsack3\fR | \fBtimestamp\fR}
+\fBip option\fR { lsrr | ra | rr | ssrr }
+\fBdccp option\fR \fIdccp_option_type\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&60.\ \&IPv6 extension headers
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}
+.T&
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+hbh
+T}:T{
+.sp
+Hop by Hop
+T}
+T{
+.sp
+rt
+T}:T{
+.sp
+Routing Header
+T}
+T{
+.sp
+frag
+T}:T{
+.sp
+Fragmentation header
+T}
+T{
+.sp
+dst
+T}:T{
+.sp
+dst options
+T}
+T{
+.sp
+mh
+T}:T{
+.sp
+Mobility Header
+T}
+T{
+.sp
+srh
+T}:T{
+.sp
+Segment Routing Header
+T}
+.TE
+.sp 1
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&61.\ \&TCP Options
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+TCP option fields
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+eol
+T}:T{
+.sp
+End if option list
+T}:T{
+.sp
+\-
+T}
+T{
+.sp
+nop
+T}:T{
+.sp
+1 Byte TCP Nop padding option
+T}:T{
+.sp
+\-
+T}
+T{
+.sp
+maxseg
+T}:T{
+.sp
+TCP Maximum Segment Size
+T}:T{
+.sp
+length, size
+T}
+T{
+.sp
+window
+T}:T{
+.sp
+TCP Window Scaling
+T}:T{
+.sp
+length, count
+T}
+T{
+.sp
+sack\-perm
+T}:T{
+.sp
+TCP SACK permitted
+T}:T{
+.sp
+length
+T}
+T{
+.sp
+sack
+T}:T{
+.sp
+TCP Selective Acknowledgement (alias of block 0)
+T}:T{
+.sp
+length, left, right
+T}
+T{
+.sp
+sack0
+T}:T{
+.sp
+TCP Selective Acknowledgement (block 0)
+T}:T{
+.sp
+length, left, right
+T}
+T{
+.sp
+sack1
+T}:T{
+.sp
+TCP Selective Acknowledgement (block 1)
+T}:T{
+.sp
+length, left, right
+T}
+T{
+.sp
+sack2
+T}:T{
+.sp
+TCP Selective Acknowledgement (block 2)
+T}:T{
+.sp
+length, left, right
+T}
+T{
+.sp
+sack3
+T}:T{
+.sp
+TCP Selective Acknowledgement (block 3)
+T}:T{
+.sp
+length, left, right
+T}
+T{
+.sp
+timestamp
+T}:T{
+.sp
+TCP Timestamps
+T}:T{
+.sp
+length, tsval, tsecr
+T}
+.TE
+.sp 1
+.sp
+TCP option matching also supports raw expression syntax to access arbitrary options:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBtcp option\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBtcp option\fR \fB@\fR\fInumber\fR\fB,\fR\fIoffset\fR\fB,\fR\fIlength\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&62.\ \&IP Options
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+IP option fields
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+lsrr
+T}:T{
+.sp
+Loose Source Route
+T}:T{
+.sp
+type, length, ptr, addr
+T}
+T{
+.sp
+ra
+T}:T{
+.sp
+Router Alert
+T}:T{
+.sp
+type, length, value
+T}
+T{
+.sp
+rr
+T}:T{
+.sp
+Record Route
+T}:T{
+.sp
+type, length, ptr, addr
+T}
+T{
+.sp
+ssrr
+T}:T{
+.sp
+Strict Source Route
+T}:T{
+.sp
+type, length, ptr, addr
+T}
+.TE
+.sp 1
+.PP
+\fBfinding TCP options\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+filter input tcp option sack\-perm exists counter
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBmatching TCP options\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+filter input tcp option maxseg size lt 536
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBmatching IPv6 exthdr\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+ip6 filter input frag more\-fragments 1 counter
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBfinding IP option\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+filter input ip option lsrr exists counter
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBfinding DCCP option\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+filter input dccp option 40 exists counter
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "CONNTRACK EXPRESSIONS"
+.sp
+Conntrack expressions refer to meta data of the connection tracking entry associated with a packet\&.
+.sp
+There are three types of conntrack expressions\&. Some conntrack expressions require the flow direction before the conntrack key, others must be used directly because they are direction agnostic\&. The \fBpackets\fR, \fBbytes\fR and \fBavgpkt\fR keywords can be used with or without a direction\&. If the direction is omitted, the sum of the original and the reply direction is returned\&. The same is true for the \fBzone\fR, if a direction is given, the zone is only matched if the zone id is tied to the given direction\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBct\fR {\fBstate\fR | \fBdirection\fR | \fBstatus\fR | \fBmark\fR | \fBexpiration\fR | \fBhelper\fR | \fBlabel\fR | \fBcount\fR | \fBid\fR}
+\fBct\fR [\fBoriginal\fR | \fBreply\fR] {\fBl3proto\fR | \fBprotocol\fR | \fBbytes\fR | \fBpackets\fR | \fBavgpkt\fR | \fBzone\fR}
+\fBct\fR {\fBoriginal\fR | \fBreply\fR} {\fBproto\-src\fR | \fBproto\-dst\fR}
+\fBct\fR {\fBoriginal\fR | \fBreply\fR} {\fBip\fR | \fBip6\fR} {\fBsaddr\fR | \fBdaddr\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The conntrack\-specific types in this table are described in the sub\-section CONNTRACK TYPES above\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&63.\ \&Conntrack expressions
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+state
+T}:T{
+.sp
+State of the connection
+T}:T{
+.sp
+ct_state
+T}
+T{
+.sp
+direction
+T}:T{
+.sp
+Direction of the packet relative to the connection
+T}:T{
+.sp
+ct_dir
+T}
+T{
+.sp
+status
+T}:T{
+.sp
+Status of the connection
+T}:T{
+.sp
+ct_status
+T}
+T{
+.sp
+mark
+T}:T{
+.sp
+Connection mark
+T}:T{
+.sp
+mark
+T}
+T{
+.sp
+expiration
+T}:T{
+.sp
+Connection expiration time
+T}:T{
+.sp
+time
+T}
+T{
+.sp
+helper
+T}:T{
+.sp
+Helper associated with the connection
+T}:T{
+.sp
+string
+T}
+T{
+.sp
+label
+T}:T{
+.sp
+Connection tracking label bit or symbolic name defined in connlabel\&.conf in the nftables include path
+T}:T{
+.sp
+ct_label
+T}
+T{
+.sp
+l3proto
+T}:T{
+.sp
+Layer 3 protocol of the connection
+T}:T{
+.sp
+nf_proto
+T}
+T{
+.sp
+saddr
+T}:T{
+.sp
+Source address of the connection for the given direction
+T}:T{
+.sp
+ipv4_addr/ipv6_addr
+T}
+T{
+.sp
+daddr
+T}:T{
+.sp
+Destination address of the connection for the given direction
+T}:T{
+.sp
+ipv4_addr/ipv6_addr
+T}
+T{
+.sp
+protocol
+T}:T{
+.sp
+Layer 4 protocol of the connection for the given direction
+T}:T{
+.sp
+inet_proto
+T}
+T{
+.sp
+proto\-src
+T}:T{
+.sp
+Layer 4 protocol source for the given direction
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+proto\-dst
+T}:T{
+.sp
+Layer 4 protocol destination for the given direction
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+packets
+T}:T{
+.sp
+packet count seen in the given direction or sum of original and reply
+T}:T{
+.sp
+integer (64 bit)
+T}
+T{
+.sp
+bytes
+T}:T{
+.sp
+byte count seen, see description for \fBpackets\fR keyword
+T}:T{
+.sp
+integer (64 bit)
+T}
+T{
+.sp
+avgpkt
+T}:T{
+.sp
+average bytes per packet, see description for \fBpackets\fR keyword
+T}:T{
+.sp
+integer (64 bit)
+T}
+T{
+.sp
+zone
+T}:T{
+.sp
+conntrack zone
+T}:T{
+.sp
+integer (16 bit)
+T}
+T{
+.sp
+count
+T}:T{
+.sp
+number of current connections
+T}:T{
+.sp
+integer (32 bit)
+T}
+T{
+.sp
+id
+T}:T{
+.sp
+Connection id
+T}:T{
+.sp
+ct_id
+T}
+.TE
+.sp 1
+.PP
+\fBrestrict the number of parallel connections to a server\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+nft add set filter ssh_flood \*(Aq{ type ipv4_addr; flags dynamic; }\*(Aq
+nft add rule filter input tcp dport 22 add @ssh_flood \*(Aq{ ip saddr ct count over 2 }\*(Aq reject
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SH "STATEMENTS"
+.sp
+Statements represent actions to be performed\&. They can alter control flow (return, jump to a different chain, accept or drop the packet) or can perform actions, such as logging, rejecting a packet, etc\&.
+.sp
+Statements exist in two kinds\&. Terminal statements unconditionally terminate evaluation of the current rule, non\-terminal statements either only conditionally or never terminate evaluation of the current rule, in other words, they are passive from the ruleset evaluation perspective\&. There can be an arbitrary amount of non\-terminal statements in a rule, but only a single terminal statement as the final statement\&.
+.SS "VERDICT STATEMENT"
+.sp
+The verdict statement alters control flow in the ruleset and issues policy decisions for packets\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+{\fBaccept\fR | \fBdrop\fR | \fBqueue\fR | \fBcontinue\fR | \fBreturn\fR}
+{\fBjump\fR | \fBgoto\fR} \fIchain\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+\fBaccept\fR and \fBdrop\fR are absolute verdicts \(em they terminate ruleset evaluation immediately\&.
+.TS
+tab(:);
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+\fBaccept\fR
+T}:T{
+.sp
+Terminate ruleset evaluation and accept the packet\&. The packet can still be dropped later by another hook, for instance accept in the forward hook still allows one to drop the packet later in the postrouting hook, or another forward base chain that has a higher priority number and is evaluated afterwards in the processing pipeline\&.
+T}
+T{
+.sp
+\fBdrop\fR
+T}:T{
+.sp
+Terminate ruleset evaluation and drop the packet\&. The drop occurs instantly, no further chains or hooks are evaluated\&. It is not possible to accept the packet in a later chain again, as those are not evaluated anymore for the packet\&.
+T}
+T{
+.sp
+\fBqueue\fR
+T}:T{
+.sp
+Terminate ruleset evaluation and queue the packet to userspace\&. Userspace must provide a drop or accept verdict\&. In case of accept, processing resumes with the next base chain hook, not the rule following the queue verdict\&.
+T}
+T{
+.sp
+\fBcontinue\fR
+T}:T{
+.sp
+Continue ruleset evaluation with the next rule\&. This is the default behaviour in case a rule issues no verdict\&.
+T}
+T{
+.sp
+\fBreturn\fR
+T}:T{
+.sp
+Return from the current chain and continue evaluation at the next rule in the last chain\&. If issued in a base chain, it is equivalent to the base chain policy\&.
+T}
+T{
+.sp
+\fBjump\fR \fIchain\fR
+T}:T{
+.sp
+Continue evaluation at the first rule in \fIchain\fR\&. The current position in the ruleset is pushed to a call stack and evaluation will continue there when the new chain is entirely evaluated or a \fBreturn\fR verdict is issued\&. In case an absolute verdict is issued by a rule in the chain, ruleset evaluation terminates immediately and the specific action is taken\&.
+T}
+T{
+.sp
+\fBgoto\fR \fIchain\fR
+T}:T{
+.sp
+Similar to \fBjump\fR, but the current position is not pushed to the call stack, meaning that after the new chain evaluation will continue at the last chain instead of the one containing the goto statement\&.
+T}
+.TE
+.sp 1
+.PP
+\fBUsing verdict statements\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# process packets from eth0 and the internal network in from_lan
+# chain, drop all packets from eth0 with different source addresses\&.
+
+filter input iif eth0 ip saddr 192\&.168\&.0\&.0/24 jump from_lan
+filter input iif eth0 drop
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "PAYLOAD STATEMENT"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fIpayload_expression\fR \fBset\fR \fIvalue\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The payload statement alters packet content\&. It can be used for example to set ip DSCP (diffserv) header field or ipv6 flow labels\&.
+.PP
+\fBroute some packets instead of bridging\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# redirect tcp:http from 192\&.160\&.0\&.0/16 to local machine for routing instead of bridging
+# assumes 00:11:22:33:44:55 is local MAC address\&.
+bridge input meta iif eth0 ip saddr 192\&.168\&.0\&.0/16 tcp dport 80 meta pkttype set unicast ether daddr set 00:11:22:33:44:55
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBSet IPv4 DSCP header field\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+ip forward ip dscp set 42
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "EXTENSION HEADER STATEMENT"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fIextension_header_expression\fR \fBset\fR \fIvalue\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The extension header statement alters packet content in variable\-sized headers\&. This can currently be used to alter the TCP Maximum segment size of packets, similar to the TCPMSS target in iptables\&.
+.PP
+\fBchange tcp mss\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+tcp flags syn tcp option maxseg size set 1360
+# set a size based on route information:
+tcp flags syn tcp option maxseg size set rt mtu
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+You can also remove tcp options via reset keyword\&.
+.PP
+\fBremove tcp option\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+tcp flags syn reset tcp option sack\-perm
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "LOG STATEMENT"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBlog\fR [\fBprefix\fR \fIquoted_string\fR] [\fBlevel\fR \fIsyslog\-level\fR] [\fBflags\fR \fIlog\-flags\fR]
+\fBlog\fR \fBgroup\fR \fInflog_group\fR [\fBprefix\fR \fIquoted_string\fR] [\fBqueue\-threshold\fR \fIvalue\fR] [\fBsnaplen\fR \fIsize\fR]
+\fBlog level audit\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The log statement enables logging of matching packets\&. When this statement is used from a rule, the Linux kernel will print some information on all matching packets, such as header fields, via the kernel log (where it can be read with dmesg(1) or read in the syslog)\&.
+.sp
+In the second form of invocation (if \fInflog_group\fR is specified), the Linux kernel will pass the packet to nfnetlink_log which will send the log through a netlink socket to the specified group\&. One userspace process may subscribe to the group to receive the logs, see man(8) ulogd for the Netfilter userspace log daemon and libnetfilter_log documentation for details in case you would like to develop a custom program to digest your logs\&.
+.sp
+In the third form of invocation (if level audit is specified), the Linux kernel writes a message into the audit buffer suitably formatted for reading with auditd\&. Therefore no further formatting options (such as prefix or flags) are allowed in this mode\&.
+.sp
+This is a non\-terminating statement, so the rule evaluation continues after the packet is logged\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&64.\ \&log statement options
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+prefix
+T}:T{
+.sp
+Log message prefix
+T}:T{
+.sp
+quoted string
+T}
+T{
+.sp
+level
+T}:T{
+.sp
+Syslog level of logging
+T}:T{
+.sp
+string: emerg, alert, crit, err, warn [default], notice, info, debug, audit
+T}
+T{
+.sp
+group
+T}:T{
+.sp
+NFLOG group to send messages to
+T}:T{
+.sp
+unsigned integer (16 bit)
+T}
+T{
+.sp
+snaplen
+T}:T{
+.sp
+Length of packet payload to include in netlink message
+T}:T{
+.sp
+unsigned integer (32 bit)
+T}
+T{
+.sp
+queue\-threshold
+T}:T{
+.sp
+Number of packets to queue inside the kernel before sending them to userspace
+T}:T{
+.sp
+unsigned integer (32 bit)
+T}
+.TE
+.sp 1
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&65.\ \&log\-flags
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Flag
+T}:T{
+Description
+T}
+.T&
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+tcp sequence
+T}:T{
+.sp
+Log TCP sequence numbers\&.
+T}
+T{
+.sp
+tcp options
+T}:T{
+.sp
+Log options from the TCP packet header\&.
+T}
+T{
+.sp
+ip options
+T}:T{
+.sp
+Log options from the IP/IPv6 packet header\&.
+T}
+T{
+.sp
+skuid
+T}:T{
+.sp
+Log the userid of the process which generated the packet\&.
+T}
+T{
+.sp
+ether
+T}:T{
+.sp
+Decode MAC addresses and protocol\&.
+T}
+T{
+.sp
+all
+T}:T{
+.sp
+Enable all log flags listed above\&.
+T}
+.TE
+.sp 1
+.PP
+\fBUsing log statement\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# log the UID which generated the packet and ip options
+ip filter output log flags skuid flags ip options
+
+# log the tcp sequence numbers and tcp options from the TCP packet
+ip filter output log flags tcp sequence,options
+
+# enable all supported log flags
+ip6 filter output log flags all
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "REJECT STATEMENT"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBreject\fR [ \fBwith\fR \fIREJECT_WITH\fR ]
+
+\fIREJECT_WITH\fR := \fBicmp\fR \fIicmp_code\fR |
+ \fBicmpv6\fR \fIicmpv6_code\fR |
+ \fBicmpx\fR \fIicmpx_code\fR |
+ \fBtcp reset\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+A reject statement is used to send back an error packet in response to the matched packet otherwise it is equivalent to drop so it is a terminating statement, ending rule traversal\&. This statement is only valid in base chains using the \fBinput\fR, \fBforward\fR or \fBoutput\fR hooks, and user\-defined chains which are only called from those chains\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&66.\ \&different ICMP reject variants are meant for use in different table families
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Variant
+T}:T{
+Family
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+icmp
+T}:T{
+.sp
+ip
+T}:T{
+.sp
+icmp_code
+T}
+T{
+.sp
+icmpv6
+T}:T{
+.sp
+ip6
+T}:T{
+.sp
+icmpv6_code
+T}
+T{
+.sp
+icmpx
+T}:T{
+.sp
+inet
+T}:T{
+.sp
+icmpx_code
+T}
+.TE
+.sp 1
+.sp
+For a description of the different types and a list of supported keywords refer to DATA TYPES section above\&. The common default reject value is \fBport\-unreachable\fR\&.
+.sp
+Note that in bridge family, reject statement is only allowed in base chains which hook into input or prerouting\&.
+.SS "COUNTER STATEMENT"
+.sp
+A counter statement sets the hit count of packets along with the number of bytes\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBcounter\fR \fBpackets\fR \fInumber\fR \fBbytes\fR \fInumber\fR
+\fBcounter\fR { \fBpackets\fR \fInumber\fR | \fBbytes\fR \fInumber\fR }
+.fi
+.if n \{\
+.RE
+.\}
+.SS "CONNTRACK STATEMENT"
+.sp
+The conntrack statement can be used to set the conntrack mark and conntrack labels\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBct\fR {\fBmark\fR | \fBevent\fR | \fBlabel\fR | \fBzone\fR} \fBset\fR \fIvalue\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The ct statement sets meta data associated with a connection\&. The zone id has to be assigned before a conntrack lookup takes place, i\&.e\&. this has to be done in prerouting and possibly output (if locally generated packets need to be placed in a distinct zone), with a hook priority of \fBraw\fR (\-300)\&.
+.sp
+Unlike iptables, where the helper assignment happens in the raw table, the helper needs to be assigned after a conntrack entry has been found, i\&.e\&. it will not work when used with hook priorities equal or before \-200\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&67.\ \&Conntrack statement types
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Value
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+event
+T}:T{
+.sp
+conntrack event bits
+T}:T{
+.sp
+bitmask, integer (32 bit)
+T}
+T{
+.sp
+helper
+T}:T{
+.sp
+name of ct helper object to assign to the connection
+T}:T{
+.sp
+quoted string
+T}
+T{
+.sp
+mark
+T}:T{
+.sp
+Connection tracking mark
+T}:T{
+.sp
+mark
+T}
+T{
+.sp
+label
+T}:T{
+.sp
+Connection tracking label
+T}:T{
+.sp
+label
+T}
+T{
+.sp
+zone
+T}:T{
+.sp
+conntrack zone
+T}:T{
+.sp
+integer (16 bit)
+T}
+.TE
+.sp 1
+.PP
+\fBsave packet nfmark in conntrack\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+ct mark set meta mark
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBset zone mapped via interface\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+table inet raw {
+ chain prerouting {
+ type filter hook prerouting priority raw;
+ ct zone set iif map { "eth1" : 1, "veth1" : 2 }
+ }
+ chain output {
+ type filter hook output priority raw;
+ ct zone set oif map { "eth1" : 1, "veth1" : 2 }
+ }
+}
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBrestrict events reported by ctnetlink\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+ct event set new,related,destroy
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "NOTRACK STATEMENT"
+.sp
+The notrack statement allows one to disable connection tracking for certain packets\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBnotrack\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Note that for this statement to be effective, it has to be applied to packets before a conntrack lookup happens\&. Therefore, it needs to sit in a chain with either prerouting or output hook and a hook priority of \-300 (\fBraw\fR) or less\&.
+.sp
+See SYNPROXY STATEMENT for an example usage\&.
+.SS "META STATEMENT"
+.sp
+A meta statement sets the value of a meta expression\&. The existing meta fields are: priority, mark, pkttype, nftrace\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBmeta\fR {\fBmark\fR | \fBpriority\fR | \fBpkttype\fR | \fBnftrace\fR | \fBbroute\fR} \fBset\fR \fIvalue\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+A meta statement sets meta data associated with a packet\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&68.\ \&Meta statement types
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Keyword
+T}:T{
+Description
+T}:T{
+Value
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+priority
+T}:T{
+.sp
+TC packet priority
+T}:T{
+.sp
+tc_handle
+T}
+T{
+.sp
+mark
+T}:T{
+.sp
+Packet mark
+T}:T{
+.sp
+mark
+T}
+T{
+.sp
+pkttype
+T}:T{
+.sp
+packet type
+T}:T{
+.sp
+pkt_type
+T}
+T{
+.sp
+nftrace
+T}:T{
+.sp
+ruleset packet tracing on/off\&. Use \fBmonitor trace\fR command to watch traces
+T}:T{
+.sp
+0, 1
+T}
+T{
+.sp
+broute
+T}:T{
+.sp
+broute on/off\&. packets are routed instead of being bridged
+T}:T{
+.sp
+0, 1
+T}
+.TE
+.sp 1
+.SS "LIMIT STATEMENT"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBlimit rate\fR [\fBover\fR] \fIpacket_number\fR \fB/\fR \fITIME_UNIT\fR [\fBburst\fR \fIpacket_number\fR \fBpackets\fR]
+\fBlimit rate\fR [\fBover\fR] \fIbyte_number\fR \fIBYTE_UNIT\fR \fB/\fR \fITIME_UNIT\fR [\fBburst\fR \fIbyte_number\fR \fIBYTE_UNIT\fR]
+
+\fITIME_UNIT\fR := \fBsecond\fR | \fBminute\fR | \fBhour\fR | \fBday\fR
+\fIBYTE_UNIT\fR := \fBbytes\fR | \fBkbytes\fR | \fBmbytes\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+A limit statement matches at a limited rate using a token bucket filter\&. A rule using this statement will match until this limit is reached\&. It can be used in combination with the log statement to give limited logging\&. The optional \fBover\fR keyword makes it match over the specified rate\&.
+.sp
+The \fBburst\fR value influences the bucket size, i\&.e\&. jitter tolerance\&. With packet\-based \fBlimit\fR, the bucket holds exactly \fBburst\fR packets, by default five\&. If you specify packet \fBburst\fR, it must be a non\-zero value\&. With byte\-based \fBlimit\fR, the bucket\(cqs minimum size is the given rate\(cqs byte value and the \fBburst\fR value adds to that, by default zero bytes\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&69.\ \&limit statement values
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Value
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt.
+T{
+.sp
+packet_number
+T}:T{
+.sp
+Number of packets
+T}:T{
+.sp
+unsigned integer (32 bit)
+T}
+T{
+.sp
+byte_number
+T}:T{
+.sp
+Number of bytes
+T}:T{
+.sp
+unsigned integer (32 bit)
+T}
+.TE
+.sp 1
+.SS "NAT STATEMENTS"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBsnat\fR [[\fBip\fR | \fBip6\fR] [ \fBprefix\fR ] \fBto\fR] \fIADDR_SPEC\fR [\fB:\fR\fIPORT_SPEC\fR] [\fIFLAGS\fR]
+\fBdnat\fR [[\fBip\fR | \fBip6\fR] [ \fBprefix\fR ] \fBto\fR] \fIADDR_SPEC\fR [\fB:\fR\fIPORT_SPEC\fR] [\fIFLAGS\fR]
+\fBmasquerade\fR [\fBto :\fR\fIPORT_SPEC\fR] [\fIFLAGS\fR]
+\fBredirect\fR [\fBto :\fR\fIPORT_SPEC\fR] [\fIFLAGS\fR]
+
+\fIADDR_SPEC\fR := \fIaddress\fR | \fIaddress\fR \fB\-\fR \fIaddress\fR
+\fIPORT_SPEC\fR := \fIport\fR | \fIport\fR \fB\-\fR \fIport\fR
+
+\fIFLAGS\fR := \fIFLAG\fR [\fB,\fR \fIFLAGS\fR]
+\fIFLAG\fR := \fBpersistent\fR | \fBrandom\fR | \fBfully\-random\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The nat statements are only valid from nat chain types\&.
+.sp
+The \fBsnat\fR and \fBmasquerade\fR statements specify that the source address of the packet should be modified\&. While \fBsnat\fR is only valid in the postrouting and input chains, \fBmasquerade\fR makes sense only in postrouting\&. The dnat and redirect statements are only valid in the prerouting and output chains, they specify that the destination address of the packet should be modified\&. You can use non\-base chains which are called from base chains of nat chain type too\&. All future packets in this connection will also be mangled, and rules should cease being examined\&.
+.sp
+The \fBmasquerade\fR statement is a special form of snat which always uses the outgoing interface\(cqs IP address to translate to\&. It is particularly useful on gateways with dynamic (public) IP addresses\&.
+.sp
+The \fBredirect\fR statement is a special form of dnat which always translates the destination address to the local host\(cqs one\&. It comes in handy if one only wants to alter the destination port of incoming traffic on different interfaces\&.
+.sp
+When used in the inet family (available with kernel 5\&.2), the dnat and snat statements require the use of the ip and ip6 keyword in case an address is provided, see the examples below\&.
+.sp
+Before kernel 4\&.18 nat statements require both prerouting and postrouting base chains to be present since otherwise packets on the return path won\(cqt be seen by netfilter and therefore no reverse translation will take place\&.
+.sp
+The optional \fBprefix\fR keyword allows to map to map \fBn\fR source addresses to \fBn\fR destination addresses\&. See \fIAdvanced NAT examples\fR below\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&70.\ \&NAT statement values
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Expression
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt.
+T{
+.sp
+address
+T}:T{
+.sp
+Specifies that the source/destination address of the packet should be modified\&. You may specify a mapping to relate a list of tuples composed of arbitrary expression key with address value\&.
+T}:T{
+.sp
+ipv4_addr, ipv6_addr, e\&.g\&. abcd::1234, or you can use a mapping, e\&.g\&. meta mark map { 10 : 192\&.168\&.1\&.2, 20 : 192\&.168\&.1\&.3 }
+T}
+T{
+.sp
+port
+T}:T{
+.sp
+Specifies that the source/destination port of the packet should be modified\&.
+T}:T{
+.sp
+port number (16 bit)
+T}
+.TE
+.sp 1
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&71.\ \&NAT statement flags
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Flag
+T}:T{
+Description
+T}
+.T&
+lt lt
+lt lt
+lt lt.
+T{
+.sp
+persistent
+T}:T{
+.sp
+Gives a client the same source\-/destination\-address for each connection\&.
+T}
+T{
+.sp
+random
+T}:T{
+.sp
+In kernel 5\&.0 and newer this is the same as fully\-random\&. In earlier kernels the port mapping will be randomized using a seeded MD5 hash mix using source and destination address and destination port\&.
+T}
+T{
+.sp
+fully\-random
+T}:T{
+.sp
+If used then port mapping is generated based on a 32\-bit pseudo\-random algorithm\&.
+T}
+.TE
+.sp 1
+.PP
+\fBUsing NAT statements\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# create a suitable table/chain setup for all further examples
+add table nat
+add chain nat prerouting { type nat hook prerouting priority dstnat; }
+add chain nat postrouting { type nat hook postrouting priority srcnat; }
+
+# translate source addresses of all packets leaving via eth0 to address 1\&.2\&.3\&.4
+add rule nat postrouting oif eth0 snat to 1\&.2\&.3\&.4
+
+# redirect all traffic entering via eth0 to destination address 192\&.168\&.1\&.120
+add rule nat prerouting iif eth0 dnat to 192\&.168\&.1\&.120
+
+# translate source addresses of all packets leaving via eth0 to whatever
+# locally generated packets would use as source to reach the same destination
+add rule nat postrouting oif eth0 masquerade
+
+# redirect incoming TCP traffic for port 22 to port 2222
+add rule nat prerouting tcp dport 22 redirect to :2222
+
+# inet family:
+# handle ip dnat:
+add rule inet nat prerouting dnat ip to 10\&.0\&.2\&.99
+# handle ip6 dnat:
+add rule inet nat prerouting dnat ip6 to fe80::dead
+# this masquerades both ipv4 and ipv6:
+add rule inet nat postrouting meta oif ppp0 masquerade
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBAdvanced NAT examples\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# map prefixes in one network to that of another, e\&.g\&. 10\&.141\&.11\&.4 is mangled to 192\&.168\&.2\&.4,
+# 10\&.141\&.11\&.5 is mangled to 192\&.168\&.2\&.5 and so on\&.
+add rule nat postrouting snat ip prefix to ip saddr map { 10\&.141\&.11\&.0/24 : 192\&.168\&.2\&.0/24 }
+
+# map a source address, source port combination to a pool of destination addresses and ports:
+add rule nat postrouting dnat to ip saddr \&. tcp dport map { 192\&.168\&.1\&.2 \&. 80 : 10\&.141\&.10\&.2\-10\&.141\&.10\&.5 \&. 8888\-8999 }
+
+# The above example generates the following NAT expression:
+#
+# [ nat dnat ip addr_min reg 1 addr_max reg 10 proto_min reg 9 proto_max reg 11 ]
+#
+# which expects to obtain the following tuple:
+# IP address (min), source port (min), IP address (max), source port (max)
+# to be obtained from the map\&. The given addresses and ports are inclusive\&.
+
+# This also works with named maps and in combination with both concatenations and ranges:
+table ip nat {
+ map ipportmap {
+ typeof ip saddr : interval ip daddr \&. tcp dport
+ flags interval
+ elements = { 192\&.168\&.1\&.2 : 10\&.141\&.10\&.1\-10\&.141\&.10\&.3 \&. 8888\-8999, 192\&.168\&.2\&.0/24 : 10\&.141\&.11\&.5\-10\&.141\&.11\&.20 \&. 8888\-8999 }
+ }
+
+ chain prerouting {
+ type nat hook prerouting priority dstnat; policy accept;
+ ip protocol tcp dnat ip to ip saddr map @ipportmap
+ }
+}
+
+@ipportmap maps network prefixes to a range of hosts and ports\&.
+The new destination is taken from the range provided by the map element\&.
+Same for the destination port\&.
+
+Note the use of the "interval" keyword in the typeof description\&.
+This is required so nftables knows that it has to ask for twice the
+amount of storage for each key\-value pair in the map\&.
+
+": ipv4_addr \&. inet_service" would allow associating one address and one port
+with each key\&. But for this case, for each key, two addresses and two ports
+(The minimum and maximum values for both) have to be stored\&.
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "TPROXY STATEMENT"
+.sp
+Tproxy redirects the packet to a local socket without changing the packet header in any way\&. If any of the arguments is missing the data of the incoming packet is used as parameter\&. Tproxy matching requires another rule that ensures the presence of transport protocol header is specified\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBtproxy to\fR \fIaddress\fR\fB:\fR\fIport\fR
+\fBtproxy to\fR {\fIaddress\fR | \fB:\fR\fIport\fR}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This syntax can be used in \fBip/ip6\fR tables where network layer protocol is obvious\&. Either IP address or port can be specified, but at least one of them is necessary\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBtproxy\fR {\fBip\fR | \fBip6\fR} \fBto\fR \fIaddress\fR[\fB:\fR\fIport\fR]
+\fBtproxy to :\fR\fIport\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This syntax can be used in \fBinet\fR tables\&. The \fBip/ip6\fR parameter defines the family the rule will match\&. The \fBaddress\fR parameter must be of this family\&. When only \fBport\fR is defined, the address family should not be specified\&. In this case the rule will match for both families\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&72.\ \&tproxy attributes
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Name
+T}:T{
+Description
+T}
+.T&
+lt lt
+lt lt.
+T{
+.sp
+address
+T}:T{
+.sp
+IP address the listening socket with IP_TRANSPARENT option is bound to\&.
+T}
+T{
+.sp
+port
+T}:T{
+.sp
+Port the listening socket with IP_TRANSPARENT option is bound to\&.
+T}
+.TE
+.sp 1
+.PP
+\fBExample ruleset for tproxy statement\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+table ip x {
+ chain y {
+ type filter hook prerouting priority mangle; policy accept;
+ tcp dport ntp tproxy to 1\&.1\&.1\&.1
+ udp dport ssh tproxy to :2222
+ }
+}
+table ip6 x {
+ chain y {
+ type filter hook prerouting priority mangle; policy accept;
+ tcp dport ntp tproxy to [dead::beef]
+ udp dport ssh tproxy to :2222
+ }
+}
+table inet x {
+ chain y {
+ type filter hook prerouting priority mangle; policy accept;
+ tcp dport 321 tproxy to :ssh
+ tcp dport 99 tproxy ip to 1\&.1\&.1\&.1:999
+ udp dport 155 tproxy ip6 to [dead::beef]:smux
+ }
+}
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "SYNPROXY STATEMENT"
+.sp
+This statement will process TCP three\-way\-handshake parallel in netfilter context to protect either local or backend system\&. This statement requires connection tracking because sequence numbers need to be translated\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBsynproxy\fR [\fBmss\fR \fImss_value\fR] [\fBwscale\fR \fIwscale_value\fR] [\fISYNPROXY_FLAGS\fR]
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&73.\ \&synproxy statement attributes
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Name
+T}:T{
+Description
+T}
+.T&
+lt lt
+lt lt.
+T{
+.sp
+mss
+T}:T{
+.sp
+Maximum segment size announced to clients\&. This must match the backend\&.
+T}
+T{
+.sp
+wscale
+T}:T{
+.sp
+Window scale announced to clients\&. This must match the backend\&.
+T}
+.TE
+.sp 1
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&74.\ \&synproxy statement flags
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Flag
+T}:T{
+Description
+T}
+.T&
+lt lt
+lt lt.
+T{
+.sp
+sack\-perm
+T}:T{
+.sp
+Pass client selective acknowledgement option to backend (will be disabled if not present)\&.
+T}
+T{
+.sp
+timestamp
+T}:T{
+.sp
+Pass client timestamp option to backend (will be disabled if not present, also needed for selective acknowledgement and window scaling)\&.
+T}
+.TE
+.sp 1
+.PP
+\fBExample ruleset for synproxy statement\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+Determine tcp options used by backend, from an external system
+
+ tcpdump \-pni eth0 \-c 1 \*(Aqtcp[tcpflags] == (tcp\-syn|tcp\-ack)\*(Aq
+ port 80 &
+ telnet 192\&.0\&.2\&.42 80
+ 18:57:24\&.693307 IP 192\&.0\&.2\&.42\&.80 > 192\&.0\&.2\&.43\&.48757:
+ Flags [S\&.], seq 360414582, ack 788841994, win 14480,
+ options [mss 1460,sackOK,
+ TS val 1409056151 ecr 9690221,
+ nop,wscale 9],
+ length 0
+
+Switch tcp_loose mode off, so conntrack will mark out\-of\-flow packets as state INVALID\&.
+
+ echo 0 > /proc/sys/net/netfilter/nf_conntrack_tcp_loose
+
+Make SYN packets untracked\&.
+
+ table ip x {
+ chain y {
+ type filter hook prerouting priority raw; policy accept;
+ tcp flags syn notrack
+ }
+ }
+
+Catch UNTRACKED (SYN packets) and INVALID (3WHS ACK packets) states and send
+them to SYNPROXY\&. This rule will respond to SYN packets with SYN+ACK
+syncookies, create ESTABLISHED for valid client response (3WHS ACK packets) and
+drop incorrect cookies\&. Flags combinations not expected during 3WHS will not
+match and continue (e\&.g\&. SYN+FIN, SYN+ACK)\&. Finally, drop invalid packets, this
+will be out\-of\-flow packets that were not matched by SYNPROXY\&.
+
+ table ip x {
+ chain z {
+ type filter hook input priority filter; policy accept;
+ ct state invalid, untracked synproxy mss 1460 wscale 9 timestamp sack\-perm
+ ct state invalid drop
+ }
+ }
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "FLOW STATEMENT"
+.sp
+A flow statement allows us to select what flows you want to accelerate forwarding through layer 3 network stack bypass\&. You have to specify the flowtable name where you want to offload this flow\&.
+.sp
+\fBflow add @\fR\fIflowtable\fR
+.SS "QUEUE STATEMENT"
+.sp
+This statement passes the packet to userspace using the nfnetlink_queue handler\&. The packet is put into the queue identified by its 16\-bit queue number\&. Userspace can inspect and modify the packet if desired\&. Userspace must then drop or re\-inject the packet into the kernel\&. See libnetfilter_queue documentation for details\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBqueue\fR [\fBflags\fR \fIQUEUE_FLAGS\fR] [\fBto\fR \fIqueue_number\fR]
+\fBqueue\fR [\fBflags\fR \fIQUEUE_FLAGS\fR] [\fBto\fR \fIqueue_number_from\fR \- \fIqueue_number_to\fR]
+\fBqueue\fR [\fBflags\fR \fIQUEUE_FLAGS\fR] [\fBto\fR \fIQUEUE_EXPRESSION\fR ]
+
+\fIQUEUE_FLAGS\fR := \fIQUEUE_FLAG\fR [\fB,\fR \fIQUEUE_FLAGS\fR]
+\fIQUEUE_FLAG\fR := \fBbypass\fR | \fBfanout\fR
+\fIQUEUE_EXPRESSION\fR := \fBnumgen\fR | \fBhash\fR | \fBsymhash\fR | \fBMAP STATEMENT\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+QUEUE_EXPRESSION can be used to compute a queue number at run\-time with the hash or numgen expressions\&. It also allows one to use the map statement to assign fixed queue numbers based on external inputs such as the source ip address or interface names\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&75.\ \&queue statement values
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Value
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt
+lt lt lt.
+T{
+.sp
+queue_number
+T}:T{
+.sp
+Sets queue number, default is 0\&.
+T}:T{
+.sp
+unsigned integer (16 bit)
+T}
+T{
+.sp
+queue_number_from
+T}:T{
+.sp
+Sets initial queue in the range, if fanout is used\&.
+T}:T{
+.sp
+unsigned integer (16 bit)
+T}
+T{
+.sp
+queue_number_to
+T}:T{
+.sp
+Sets closing queue in the range, if fanout is used\&.
+T}:T{
+.sp
+unsigned integer (16 bit)
+T}
+.TE
+.sp 1
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&76.\ \&queue statement flags
+.TS
+allbox tab(:);
+ltB ltB.
+T{
+Flag
+T}:T{
+Description
+T}
+.T&
+lt lt
+lt lt.
+T{
+.sp
+bypass
+T}:T{
+.sp
+Let packets go through if userspace application cannot back off\&. Before using this flag, read libnetfilter_queue documentation for performance tuning recommendations\&.
+T}
+T{
+.sp
+fanout
+T}:T{
+.sp
+Distribute packets between several queues\&.
+T}
+.TE
+.sp 1
+.SS "DUP STATEMENT"
+.sp
+The dup statement is used to duplicate a packet and send the copy to a different destination\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBdup to\fR \fIdevice\fR
+\fBdup to\fR \fIaddress\fR \fBdevice\fR \fIdevice\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&77.\ \&Dup statement values
+.TS
+allbox tab(:);
+ltB ltB ltB.
+T{
+Expression
+T}:T{
+Description
+T}:T{
+Type
+T}
+.T&
+lt lt lt
+lt lt lt.
+T{
+.sp
+address
+T}:T{
+.sp
+Specifies that the copy of the packet should be sent to a new gateway\&.
+T}:T{
+.sp
+ipv4_addr, ipv6_addr, e\&.g\&. abcd::1234, or you can use a mapping, e\&.g\&. ip saddr map { 192\&.168\&.1\&.2 : 10\&.1\&.1\&.1 }
+T}
+T{
+.sp
+device
+T}:T{
+.sp
+Specifies that the copy should be transmitted via device\&.
+T}:T{
+.sp
+string
+T}
+.TE
+.sp 1
+.PP
+\fBUsing the dup statement\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# send to machine with ip address 10\&.2\&.3\&.4 on eth0
+ip filter forward dup to 10\&.2\&.3\&.4 device "eth0"
+
+# copy raw frame to another interface
+netdev ingress dup to "eth0"
+dup to "eth0"
+
+# combine with map dst addr to gateways
+dup to ip daddr map { 192\&.168\&.7\&.1 : "eth0", 192\&.168\&.7\&.2 : "eth1" }
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "FWD STATEMENT"
+.sp
+The fwd statement is used to redirect a raw packet to another interface\&. It is only available in the netdev family ingress and egress hooks\&. It is similar to the dup statement except that no copy is made\&.
+.sp
+You can also specify the address of the next hop and the device to forward the packet to\&. This updates the source and destination MAC address of the packet by transmitting it through the neighboring layer\&. This also decrements the ttl field of the IP packet\&. This provides a way to effectively bypass the classical forwarding path, thus skipping the fib (forwarding information base) lookup\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBfwd to\fR \fIdevice\fR
+\fBfwd\fR [\fBip\fR | \fBip6\fR] \fBto\fR \fIaddress\fR \fBdevice\fR \fIdevice\fR
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBUsing the fwd statement\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# redirect raw packet to device
+netdev ingress fwd to "eth0"
+
+# forward packet to next hop 192\&.168\&.200\&.1 via eth0 device
+netdev ingress ether saddr set fwd ip to 192\&.168\&.200\&.1 device "eth0"
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "SET STATEMENT"
+.sp
+The set statement is used to dynamically add or update elements in a set from the packet path\&. The set setname must already exist in the given table and must have been created with one or both of the dynamic and the timeout flags\&. The dynamic flag is required if the set statement expression includes a stateful object\&. The timeout flag is implied if the set is created with a timeout, and is required if the set statement updates elements, rather than adding them\&. Furthermore, these sets should specify both a maximum set size (to prevent memory exhaustion), and their elements should have a timeout (so their number will not grow indefinitely) either from the set definition or from the statement that adds or updates them\&. The set statement can be used to e\&.g\&. create dynamic blacklists\&.
+.sp
+Dynamic updates are also supported with maps\&. In this case, the \fBadd\fR or \fBupdate\fR rule needs to provide both the key and the data element (value), separated via \fI:\fR\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+{\fBadd\fR | \fBupdate\fR} \fB@\fR\fIsetname\fR \fB{\fR \fIexpression\fR [\fBtimeout\fR \fItimeout\fR] [\fBcomment\fR \fIstring\fR] \fB}\fR
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBExample for simple blacklist\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# declare a set, bound to table "filter", in family "ip"\&.
+# Timeout and size are mandatory because we will add elements from packet path\&.
+# Entries will timeout after one minute, after which they might be
+# re\-added if limit condition persists\&.
+nft add set ip filter blackhole \e
+ "{ type ipv4_addr; flags dynamic; timeout 1m; size 65536; }"
+
+# declare a set to store the limit per saddr\&.
+# This must be separate from blackhole since the timeout is different
+nft add set ip filter flood \e
+ "{ type ipv4_addr; flags dynamic; timeout 10s; size 128000; }"
+
+# whitelist internal interface\&.
+nft add rule ip filter input meta iifname "internal" accept
+
+# drop packets coming from blacklisted ip addresses\&.
+nft add rule ip filter input ip saddr @blackhole counter drop
+
+# add source ip addresses to the blacklist if more than 10 tcp connection
+# requests occurred per second and ip address\&.
+nft add rule ip filter input tcp flags syn tcp dport ssh \e
+ add @flood { ip saddr limit rate over 10/second } \e
+ add @blackhole { ip saddr } \e
+ drop
+
+# inspect state of the sets\&.
+nft list set ip filter flood
+nft list set ip filter blackhole
+
+# manually add two addresses to the blackhole\&.
+nft add element filter blackhole { 10\&.2\&.3\&.4, 10\&.23\&.1\&.42 }
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "MAP STATEMENT"
+.sp
+The map statement is used to lookup data based on some specific input key\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fIexpression\fR \fBmap\fR \fB{\fR \fIMAP_ELEMENTS\fR \fB}\fR
+
+\fIMAP_ELEMENTS\fR := \fIMAP_ELEMENT\fR [\fB,\fR \fIMAP_ELEMENTS\fR]
+\fIMAP_ELEMENT\fR := \fIkey\fR \fB:\fR \fIvalue\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The \fIkey\fR is a value returned by \fIexpression\fR\&.
+.PP
+\fBUsing the map statement\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# select DNAT target based on TCP dport:
+# connections to port 80 are redirected to 192\&.168\&.1\&.100,
+# connections to port 8888 are redirected to 192\&.168\&.1\&.101
+nft add rule ip nat prerouting dnat tcp dport map { 80 : 192\&.168\&.1\&.100, 8888 : 192\&.168\&.1\&.101 }
+
+# source address based SNAT:
+# packets from net 192\&.168\&.1\&.0/24 will appear as originating from 10\&.0\&.0\&.1,
+# packets from net 192\&.168\&.2\&.0/24 will appear as originating from 10\&.0\&.0\&.2
+nft add rule ip nat postrouting snat to ip saddr map { 192\&.168\&.1\&.0/24 : 10\&.0\&.0\&.1, 192\&.168\&.2\&.0/24 : 10\&.0\&.0\&.2 }
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "VMAP STATEMENT"
+.sp
+The verdict map (vmap) statement works analogous to the map statement, but contains verdicts as values\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fIexpression\fR \fBvmap\fR \fB{\fR \fIVMAP_ELEMENTS\fR \fB}\fR
+
+\fIVMAP_ELEMENTS\fR := \fIVMAP_ELEMENT\fR [\fB,\fR \fIVMAP_ELEMENTS\fR]
+\fIVMAP_ELEMENT\fR := \fIkey\fR \fB:\fR \fIverdict\fR
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBUsing the vmap statement\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# jump to different chains depending on layer 4 protocol type:
+nft add rule ip filter input ip protocol vmap { tcp : jump tcp\-chain, udp : jump udp\-chain , icmp : jump icmp\-chain }
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SS "XT STATEMENT"
+.sp
+This represents an xt statement from xtables compat interface\&. It is a fallback if translation is not available or not complete\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBxt\fR \fITYPE\fR \fINAME\fR
+
+\fITYPE\fR := \fBmatch\fR | \fBtarget\fR | \fBwatcher\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Seeing this means the ruleset (or parts of it) were created by \fBiptables\-nft\fR and one should use that to manage it\&.
+.sp
+\fBBEWARE:\fR nftables won\(cqt restore these statements\&.
+.SH "ADDITIONAL COMMANDS"
+.sp
+These are some additional commands included in nft\&.
+.SS "MONITOR"
+.sp
+The monitor command allows you to listen to Netlink events produced by the nf_tables subsystem\&. These are either related to creation and deletion of objects or to packets for which \fBmeta nftrace\fR was enabled\&. When they occur, nft will print to stdout the monitored events in either JSON or native nft format\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBmonitor\fR [\fBnew\fR | \fBdestroy\fR] \fIMONITOR_OBJECT\fR
+\fBmonitor\fR \fBtrace\fR
+
+\fIMONITOR_OBJECT\fR := \fBtables\fR | \fBchains\fR | \fBsets\fR | \fBrules\fR | \fBelements\fR | \fBruleset\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+To filter events related to a concrete object, use one of the keywords in \fIMONITOR_OBJECT\fR\&.
+.sp
+To filter events related to a concrete action, use keyword \fBnew\fR or \fBdestroy\fR\&.
+.sp
+The second form of invocation takes no further options and exclusively prints events generated for packets with \fBnftrace\fR enabled\&.
+.sp
+Hit ^C to finish the monitor operation\&.
+.PP
+\fBListen to all events, report in native nft format\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+% nft monitor
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBListen to deleted rules, report in JSON format\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+% nft \-j monitor destroy rules
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBListen to both new and destroyed chains, in native nft format\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+% nft monitor chains
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBListen to ruleset events such as table, chain, rule, set, counters and quotas, in native nft format\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+% nft monitor ruleset
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBTrace incoming packets from host 10.0.0.1\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+% nft add rule filter input ip saddr 10\&.0\&.0\&.1 meta nftrace set 1
+% nft monitor trace
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SH "ERROR REPORTING"
+.sp
+When an error is detected, nft shows the line(s) containing the error, the position of the erroneous parts in the input stream and marks up the erroneous parts using carets (^)\&. If the error results from the combination of two expressions or statements, the part imposing the constraints which are violated is marked using tildes (~)\&.
+.sp
+For errors returned by the kernel, nft cannot detect which parts of the input caused the error and the entire command is marked\&.
+.PP
+\fBError caused by single incorrect expression\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+<cmdline>:1:19\-22: Error: Interface does not exist
+filter output oif eth0
+ ^^^^
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBError caused by invalid combination of two expressions\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+<cmdline>:1:28\-36: Error: Right hand side of relational expression (==) must be constant
+filter output tcp dport == tcp dport
+ ~~ ^^^^^^^^^
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+\fBError returned by the kernel\fR.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+<cmdline>:0:0\-23: Error: Could not process rule: Operation not permitted
+filter output oif wlan0
+^^^^^^^^^^^^^^^^^^^^^^^
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SH "EXIT STATUS"
+.sp
+On success, nft exits with a status of 0\&. Unspecified errors cause it to exit with a status of 1, memory allocation errors with a status of 2, unable to open Netlink socket with 3\&.
+.SH "SEE ALSO"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+libnftables(3), libnftables\-json(5), iptables(8), ip6tables(8), arptables(8), ebtables(8), ip(8), tc(8)
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+There is an official wiki at: https://wiki\&.nftables\&.org
+.SH "AUTHORS"
+.sp
+nftables was written by Patrick McHardy and Pablo Neira Ayuso, among many other contributors from the Netfilter community\&.
+.SH "COPYRIGHT"
+.sp
+Copyright \(co 2008\-2014 Patrick McHardy <kaber@trash\&.net> Copyright \(co 2013\-2018 Pablo Neira Ayuso <pablo@netfilter\&.org>
+.sp
+nftables is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation\&.
+.sp
+This documentation is licensed under the terms of the Creative Commons Attribution\-ShareAlike 4\&.0 license, CC BY\-SA 4\&.0 http://creativecommons\&.org/licenses/by\-sa/4\&.0/\&.
diff --git a/doc/nft.txt b/doc/nft.txt
new file mode 100644
index 0000000..b08e32f
--- /dev/null
+++ b/doc/nft.txt
@@ -0,0 +1,1009 @@
+nft(8)
+======
+
+NAME
+----
+nft - Administration tool of the nftables framework for packet filtering and classification
+
+
+SYNOPSIS
+--------
+[verse]
+*nft* [ *-nNscaeSupyjtT* ] [ *-I* 'directory' ] [ *-f* 'filename' | *-i* | 'cmd' ...]
+*nft* *-h*
+*nft* *-v*
+
+DESCRIPTION
+-----------
+nft is the command line tool used to set up, maintain and inspect packet
+filtering and classification rules in the Linux kernel, in the nftables
+framework. The Linux kernel subsystem is known as nf_tables, and `nf' stands
+for Netfilter.
+
+OPTIONS
+-------
+The command accepts several different options which are documented here in groups for better
+understanding of their meaning. You can get information about options by running *nft --help*.
+
+.General options:
+
+*-h*::
+*--help*::
+ Show help message and all options.
+
+*-v*::
+*--version*::
+ Show version.
+
+*-V*::
+ Show long version information, including compile-time configuration.
+
+.Ruleset input handling options that specify to how to load rulesets:
+
+*-f*::
+*--file 'filename'*::
+ Read input from 'filename'. If 'filename' is -, read from stdin.
+
+*-D*::
+*--define 'name=value'*::
+ Define a variable. You can only combine this option with '-f'.
+
+*-i*::
+*--interactive*::
+ Read input from an interactive readline CLI. You can use quit to exit, or use the EOF marker,
+ normally this is CTRL-D.
+
+*-I*::
+*--includepath directory*::
+ Add the directory 'directory' to the list of directories to be searched for included files. This
+ option may be specified multiple times.
+
+*-c*::
+*--check*::
+ Check commands validity without actually applying the changes.
+
+*-o*::
+*--optimize*::
+ Optimize your ruleset. You can combine this option with '-c' to inspect
+ the proposed optimizations.
+
+.Ruleset list output formatting that modify the output of the list ruleset command:
+
+*-a*::
+*--handle*::
+ Show object handles in output.
+
+*-s*::
+*--stateless*::
+ Omit stateful information of rules and stateful objects.
+
+*-t*::
+*--terse*::
+ Omit contents of sets from output.
+
+*-S*::
+*--service*::
+ Translate ports to service names as defined by /etc/services.
+
+*-N*::
+*--reversedns*::
+ Translate IP address to names via reverse DNS lookup. This may slow down
+ your listing since it generates network traffic.
+
+*-u*::
+*--guid*::
+ Translate numeric UID/GID to names as defined by /etc/passwd and /etc/group.
+
+*-n*::
+*--numeric*::
+ Print fully numerical output.
+
+*-y*::
+*--numeric-priority*::
+ Display base chain priority numerically.
+
+*-p*::
+*--numeric-protocol*::
+ Display layer 4 protocol numerically.
+
+*-T*::
+*--numeric-time*::
+ Show time, day and hour values in numeric format.
+
+.Command output formatting:
+
+*-e*::
+*--echo*::
+ When inserting items into the ruleset using *add*, *insert* or *replace* commands, print notifications
+ just like *nft monitor*.
+
+*-j*::
+*--json*::
+ Format output in JSON. See libnftables-json(5) for a schema description.
+
+*-d*::
+*--debug* 'level'::
+ Enable debugging output. The debug level can be any of *scanner*, *parser*, *eval*,
+ *netlink*, *mnl*, *proto-ctx*, *segtree*, *all*. You can combine more than one by
+ separating by the ',' symbol, for example '-d eval,mnl'.
+
+INPUT FILE FORMATS
+------------------
+LEXICAL CONVENTIONS
+~~~~~~~~~~~~~~~~~~~
+Input is parsed line-wise. When the last character of a line, just before the
+newline character, is a non-quoted backslash (\), the next line is treated as a
+continuation. Multiple commands on the same line can be separated using a
+semicolon (;). +
+
+A hash sign (#) begins a comment. All following characters on the same line are
+ignored. +
+
+Identifiers begin with an alphabetic character (a-z,A-Z), followed by zero or more
+alphanumeric characters (a-z,A-Z,0-9) and the characters slash (/), backslash
+(\), underscore (_) and dot (.). Identifiers using different characters or
+clashing with a keyword need to be enclosed in double quotes (").
+
+INCLUDE FILES
+~~~~~~~~~~~~~
+[verse]
+*include* 'filename'
+
+Other files can be included by using the *include* statement. The directories to
+be searched for include files can be specified using the *-I*/*--includepath*
+option. You can override this behaviour either by prepending `./' to your path
+to force inclusion of files located in the current working directory (i.e.
+relative path) or / for file location expressed as an absolute path. +
+
+If *-I*/*--includepath* is not specified, then nft relies on the default
+directory that is specified at compile time. You can retrieve this default
+directory via the *-h*/*--help* option. +
+
+Include statements support the usual shell wildcard symbols (*,?,[]). Having no
+matches for an include statement is not an error, if wildcard symbols are used
+in the include statement. This allows having potentially empty include
+directories for statements like **include "/etc/firewall/rules/*"**. The wildcard
+matches are loaded in alphabetical order. Files beginning with dot (.) are not
+matched by include statements.
+
+SYMBOLIC VARIABLES
+~~~~~~~~~~~~~~~~~~
+[verse]
+*define* 'variable' *=* 'expr'
+*undefine* 'variable'
+*redefine* 'variable' *=* 'expr'
+*$variable*
+
+Symbolic variables can be defined using the *define* statement. Variable
+references are expressions and can be used to initialize other variables. The scope
+of a definition is the current block and all blocks contained within.
+Symbolic variables can be undefined using the *undefine* statement, and modified
+using the *redefine* statement.
+
+.Using symbolic variables
+---------------------------------------
+define int_if1 = eth0
+define int_if2 = eth1
+define int_ifs = { $int_if1, $int_if2 }
+redefine int_if2 = wlan0
+undefine int_if2
+
+filter input iif $int_ifs accept
+---------------------------------------
+
+[[ADDRESS_FAMILIES]]
+ADDRESS FAMILIES
+----------------
+Address families determine the type of packets which are processed. For each
+address family, the kernel contains so called hooks at specific stages of the
+packet processing paths, which invoke nftables if rules for these hooks exist.
+
+[horizontal]
+*ip*:: IPv4 address family.
+*ip6*:: IPv6 address family.
+*inet*:: Internet (IPv4/IPv6) address family.
+*arp*:: ARP address family, handling IPv4 ARP packets.
+*bridge*:: Bridge address family, handling packets which traverse a bridge device.
+*netdev*:: Netdev address family, handling packets on ingress and egress.
+
+All nftables objects exist in address family specific namespaces, therefore all
+identifiers include an address family. If an identifier is specified without an
+address family, the *ip* family is used by default.
+
+IPV4/IPV6/INET ADDRESS FAMILIES
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The IPv4/IPv6/Inet address families handle IPv4, IPv6 or both types of packets.
+They contain five hooks at different packet processing stages in the network
+stack.
+
+.IPv4/IPv6/Inet address family hooks
+[options="header"]
+|==================
+|Hook | Description
+|prerouting |
+All packets entering the system are processed by the prerouting hook. It is
+invoked before the routing process and is used for early filtering or changing
+packet attributes that affect routing.
+|input |
+Packets delivered to the local system are processed by the input hook.
+|forward |
+Packets forwarded to a different host are processed by the forward hook.
+|output |
+Packets sent by local processes are processed by the output hook.
+|postrouting |
+All packets leaving the system are processed by the postrouting hook.
+|ingress |
+All packets entering the system are processed by this hook. It is invoked before
+layer 3 protocol handlers, hence before the prerouting hook, and it can be used
+for filtering and policing. Ingress is only available for Inet family (since
+Linux kernel 5.10).
+|===================
+
+ARP ADDRESS FAMILY
+~~~~~~~~~~~~~~~~~~
+The ARP address family handles ARP packets received and sent by the system. It
+is commonly used to mangle ARP packets for clustering.
+
+.ARP address family hooks
+[options="header"]
+|=================
+|Hook | Description
+|input |
+Packets delivered to the local system are processed by the input hook.
+|output |
+Packets send by the local system are processed by the output hook.
+|=================
+
+BRIDGE ADDRESS FAMILY
+~~~~~~~~~~~~~~~~~~~~~
+The bridge address family handles Ethernet packets traversing bridge devices.
+
+The list of supported hooks is identical to IPv4/IPv6/Inet address families above.
+
+NETDEV ADDRESS FAMILY
+~~~~~~~~~~~~~~~~~~~~
+The Netdev address family handles packets from the device ingress and egress
+path. This family allows you to filter packets of any ethertype such as ARP,
+VLAN 802.1q, VLAN 802.1ad (Q-in-Q) as well as IPv4 and IPv6 packets.
+
+.Netdev address family hooks
+[options="header"]
+|=================
+|Hook | Description
+|ingress |
+All packets entering the system are processed by this hook. It is invoked after
+the network taps (ie. *tcpdump*), right after *tc* ingress and before layer 3
+protocol handlers, it can be used for early filtering and policing.
+|egress |
+All packets leaving the system are processed by this hook. It is invoked after
+layer 3 protocol handlers and before *tc* egress. It can be used for late
+filtering and policing.
+|=================
+
+Tunneled packets (such as *vxlan*) are processed by netdev family hooks both
+in decapsulated and encapsulated (tunneled) form. So a packet can be filtered
+on the overlay network as well as on the underlying network.
+
+Note that the order of netfilter and *tc* is mirrored on ingress versus egress.
+This ensures symmetry for NAT and other packet mangling.
+
+Ingress packets which are redirected out some other interface are only
+processed by netfilter on egress if they have passed through netfilter ingress
+processing before. Thus, ingress packets which are redirected by *tc* are not
+subjected to netfilter. But they are if they are redirected by *netfilter* on
+ingress. Conceptually, tc and netfilter can be thought of as layers, with
+netfilter layered above tc: If the packet hasn't been passed up from the
+tc layer to the netfilter layer, it's not subjected to netfilter on egress.
+
+RULESET
+-------
+[verse]
+{*list* | *flush*} *ruleset* ['family']
+
+The *ruleset* keyword is used to identify the whole set of tables, chains, etc.
+currently in place in kernel. The following *ruleset* commands exist:
+
+[horizontal]
+*list*:: Print the ruleset in human-readable format.
+
+*flush*:: Clear the whole ruleset. Note that, unlike iptables, this will remove
+all tables and whatever they contain, effectively leading to an empty ruleset -
+no packet filtering will happen anymore, so the kernel accepts any valid packet
+it receives.
+
+It is possible to limit *list* and *flush* to a specific address family only.
+For a list of valid family names, see <<ADDRESS_FAMILIES>> above.
+
+By design, *list ruleset* command output may be used as input to *nft -f*.
+Effectively, this is the nft-equivalent of *iptables-save* and
+*iptables-restore*.
+
+TABLES
+------
+[verse]
+{*add* | *create*} *table* ['family'] 'table' [ {*comment* 'comment' *;*'} *{ flags* 'flags' *; }*]
+{*delete* | *destroy* | *list* | *flush*} *table* ['family'] 'table'
+*list tables* ['family']
+*delete table* ['family'] *handle* 'handle'
+*destroy table* ['family'] *handle* 'handle'
+
+Tables are containers for chains, sets and stateful objects. They are identified
+by their address family and their name. The address family must be one of *ip*,
+*ip6*, *inet*, *arp*, *bridge*, *netdev*. The *inet* address family is a dummy
+family which is used to create hybrid IPv4/IPv6 tables. The *meta expression
+nfproto* keyword can be used to test which family (ipv4 or ipv6) context the
+packet is being processed in. When no address family is specified, *ip* is used
+by default. The only difference between add and create is that the former will
+not return an error if the specified table already exists while *create* will
+return an error.
+
+.Table flags
+[options="header"]
+|=================
+|Flag | Description
+|dormant |
+table is not evaluated any more (base chains are unregistered).
+|=================
+
+.*Add, change, delete a table*
+---------------------------------------
+# start nft in interactive mode
+nft --interactive
+
+# create a new table.
+create table inet mytable
+
+# add a new base chain: get input packets
+add chain inet mytable myin { type filter hook input priority filter; }
+
+# add a single counter to the chain
+add rule inet mytable myin counter
+
+# disable the table temporarily -- rules are not evaluated anymore
+add table inet mytable { flags dormant; }
+
+# make table active again:
+add table inet mytable
+---------------------------------------
+
+[horizontal]
+*add*:: Add a new table for the given family with the given name.
+*delete*:: Delete the specified table.
+*destroy*:: Delete the specified table, it does not fail if it does not exist.
+*list*:: List all chains and rules of the specified table.
+*flush*:: Flush all chains and rules of the specified table.
+
+CHAINS
+------
+[verse]
+{*add* | *create*} *chain* ['family'] 'table' 'chain' [*{ type* 'type' *hook* 'hook' [*device* 'device'] *priority* 'priority' *;* [*policy* 'policy' *;*] [*comment* 'comment' *;*'] *}*]
+{*delete* | *destroy* | *list* | *flush*} *chain* ['family'] 'table' 'chain'
+*list chains* ['family']
+*delete chain* ['family'] 'table' *handle* 'handle'
+*destroy chain* ['family'] 'table' *handle* 'handle'
+*rename chain* ['family'] 'table' 'chain' 'newname'
+
+Chains are containers for rules. They exist in two kinds, base chains and
+regular chains. A base chain is an entry point for packets from the networking
+stack, a regular chain may be used as jump target and is used for better rule
+organization.
+
+[horizontal]
+*add*:: Add a new chain in the specified table. When a hook and priority value
+are specified, the chain is created as a base chain and hooked up to the networking stack.
+*create*:: Similar to the *add* command, but returns an error if the chain already exists.
+*delete*:: Delete the specified chain. The chain must not contain any rules or be used as jump target.
+*destroy*:: Delete the specified chain, it does not fail if it does not exist. The chain must not contain any rules or be used as jump target.
+*rename*:: Rename the specified chain.
+*list*:: List all rules of the specified chain.
+*flush*:: Flush all rules of the specified chain.
+
+For base chains, *type*, *hook* and *priority* parameters are mandatory.
+
+.Supported chain types
+[options="header"]
+|=================
+|Type | Families | Hooks | Description
+|filter | all | all |
+Standard chain type to use in doubt.
+|nat | ip, ip6, inet |
+prerouting, input, output, postrouting |
+Chains of this type perform Native Address Translation based on conntrack
+entries. Only the first packet of a connection actually traverses this chain -
+its rules usually define details of the created conntrack entry (NAT
+statements for instance).
+|route | ip, ip6 | output |
+If a packet has traversed a chain of this type and is about to be accepted, a
+new route lookup is performed if relevant parts of the IP header have changed.
+This allows one to e.g. implement policy routing selectors in nftables.
+|=================
+
+Apart from the special cases illustrated above (e.g. *nat* type not supporting
+*forward* hook or *route* type only supporting *output* hook), there are three
+further quirks worth noticing:
+
+* The netdev family supports merely two combinations, namely *filter* type with
+ *ingress* hook and *filter* type with *egress* hook. Base chains in this
+ family also require the *device* parameter to be present since they exist per
+ interface only.
+* The arp family supports only the *input* and *output* hooks, both in chains of type
+ *filter*.
+* The inet family also supports the *ingress* hook (since Linux kernel 5.10),
+ to filter IPv4 and IPv6 packet at the same location as the netdev *ingress*
+ hook. This inet hook allows you to share sets and maps between the usual
+ *prerouting*, *input*, *forward*, *output*, *postrouting* and this *ingress*
+ hook.
+
+The *device* parameter accepts a network interface name as a string, and is
+required when adding a base chain that filters traffic on the ingress or
+egress hooks. Any ingress or egress chains will only filter traffic from the
+interface specified in the *device* parameter.
+
+The *priority* parameter accepts a signed integer value or a standard priority
+name which specifies the order in which chains with the same *hook* value are
+traversed. The ordering is ascending, i.e. lower priority values have precedence
+over higher ones.
+
+With *nat* type chains, there's a lower excluding limit of -200 for *priority*
+values, because conntrack hooks at this priority and NAT requires it.
+
+Standard priority values can be replaced with easily memorizable names. Not all
+names make sense in every family with every hook (see the compatibility matrices
+below) but their numerical value can still be used for prioritizing chains.
+
+These names and values are defined and made available based on what priorities
+are used by xtables when registering their default chains.
+
+Most of the families use the same values, but bridge uses different ones from
+the others. See the following tables that describe the values and compatibility.
+
+.Standard priority names, family and hook compatibility matrix
+[options="header"]
+|==================
+| Name | Value | Families | Hooks
+| raw | -300 | ip, ip6, inet | all
+| mangle | -150 | ip, ip6, inet | all
+| dstnat | -100 | ip, ip6, inet | prerouting
+| filter | 0 | ip, ip6, inet, arp, netdev | all
+| security | 50 | ip, ip6, inet | all
+| srcnat | 100 | ip, ip6, inet | postrouting
+|===================
+
+.Standard priority names and hook compatibility for the bridge family
+[option="header"]
+|==================
+| Name | Value | Hooks
+| dstnat | -300 | prerouting
+| filter | -200 | all
+| out | 100 | output
+| srcnat | 300 | postrouting
+|==================
+
+Basic arithmetic expressions (addition and subtraction) can also be achieved
+with these standard names to ease relative prioritizing, e.g. *mangle - 5* stands
+for *-155*. Values will also be printed like this until the value is not
+further than 10 from the standard value.
+
+Base chains also allow one to set the chain's *policy*, i.e. what happens to
+packets not explicitly accepted or refused in contained rules. Supported policy
+values are *accept* (which is the default) or *drop*.
+
+RULES
+-----
+[verse]
+{*add* | *insert*} *rule* ['family'] 'table' 'chain' [*handle* 'handle' | *index* 'index'] 'statement' ... [*comment* 'comment']
+*replace rule* ['family'] 'table' 'chain' *handle* 'handle' 'statement' ... [*comment* 'comment']
+{*delete* | *reset*} *rule* ['family'] 'table' 'chain' *handle* 'handle'
+*destroy rule* ['family'] 'table' 'chain' *handle* 'handle'
+*reset rules* ['family'] ['table' ['chain']]
+
+Rules are added to chains in the given table. If the family is not specified, the
+ip family is used. Rules are constructed from two kinds of components according
+to a set of grammatical rules: expressions and statements.
+
+The add and insert commands support an optional location specifier, which is
+either a 'handle' or the 'index' (starting at zero) of an existing rule.
+Internally, rule locations are always identified by 'handle' and the translation
+from 'index' happens in userspace. This has two potential implications in case a
+concurrent ruleset change happens after the translation was done: The effective
+rule index might change if a rule was inserted or deleted before the referred
+one. If the referred rule was deleted, the command is rejected by the kernel
+just as if an invalid 'handle' was given.
+
+A 'comment' is a single word or a double-quoted (") multi-word string which can
+be used to make notes regarding the actual rule. *Note:* If you use bash for
+adding rules, you have to escape the quotation marks, e.g. \"enable ssh for
+servers\".
+
+[horizontal]
+*add*:: Add a new rule described by the list of statements. The
+rule is appended to the given chain unless a location is specified, in which
+case the rule is inserted after the specified rule.
+*insert*:: Same as *add* except the rule is inserted at the
+beginning of the chain or before the specified rule.
+*replace*:: Similar to *add*, but the rule replaces the specified rule.
+*delete*:: Delete the specified rule.
+*destroy*:: Delete the specified rule, it does not fail if it does not exist.
+*reset*:: Reset rule-contained state, e.g. counter and quota statement values.
+
+.*add a rule to ip table output chain*
+-------------
+nft add rule filter output ip daddr 192.168.0.0/24 accept # 'ip filter' is assumed
+# same command, slightly more verbose
+nft add rule ip filter output ip daddr 192.168.0.0/24 accept
+--------------
+
+.*delete rule from inet table*
+-----------------------
+# nft -a list ruleset
+table inet filter {
+ chain input {
+ type filter hook input priority filter; policy accept;
+ ct state established,related accept # handle 4
+ ip saddr 10.1.1.1 tcp dport ssh accept # handle 5
+ ...
+# delete the rule with handle 5
+nft delete rule inet filter input handle 5
+-------------------------
+
+SETS
+----
+nftables offers two kinds of set concepts. Anonymous sets are sets that have no
+specific name. The set members are enclosed in curly braces, with commas to
+separate elements when creating the rule the set is used in. Once that rule is
+removed, the set is removed as well. They cannot be updated, i.e. once an
+anonymous set is declared it cannot be changed anymore except by
+removing/altering the rule that uses the anonymous set.
+
+.*Using anonymous sets to accept particular subnets and ports*
+----------
+nft add rule filter input ip saddr { 10.0.0.0/8, 192.168.0.0/16 } tcp dport { 22, 443 } accept
+----------
+
+Named sets are sets that need to be defined first before they can be referenced
+in rules. Unlike anonymous sets, elements can be added to or removed from a
+named set at any time. Sets are referenced from rules using an @ prefixed to the
+sets name.
+
+.*Using named sets to accept addresses and ports*
+------------------
+nft add rule filter input ip saddr @allowed_hosts tcp dport @allowed_ports accept
+------------------
+
+The sets allowed_hosts and allowed_ports need to be created first. The next
+section describes nft set syntax in more detail.
+
+[verse]
+*add set* ['family'] 'table' 'set' *{ type* 'type' | *typeof* 'expression' *;* [*flags* 'flags' *;*] [*timeout* 'timeout' *;*] [*gc-interval* 'gc-interval' *;*] [*elements = {* 'element'[*,* ...] *} ;*] [*size* 'size' *;*] [*comment* 'comment' *;*'] [*policy* 'policy' *;*] [*auto-merge ;*] *}*
+{*delete* | *destroy* | *list* | *flush* | *reset* } *set* ['family'] 'table' 'set'
+*list sets* ['family']
+*delete set* ['family'] 'table' *handle* 'handle'
+{*add* | *delete* | *destroy* } *element* ['family'] 'table' 'set' *{* 'element'[*,* ...] *}*
+
+Sets are element containers of a user-defined data type, they are uniquely
+identified by a user-defined name and attached to tables. Their behaviour can
+be tuned with the flags that can be specified at set creation time.
+
+[horizontal]
+*add*:: Add a new set in the specified table. See the Set specification table below for more information about how to specify properties of a set.
+*delete*:: Delete the specified set.
+*destroy*:: Delete the specified set, it does not fail if it does not exist.
+*list*:: Display the elements in the specified set.
+*flush*:: Remove all elements from the specified set.
+*reset*:: Reset state in all contained elements, e.g. counter and quota statement values.
+
+.Set specifications
+[options="header"]
+|=================
+|Keyword | Description | Type
+|type |
+data type of set elements |
+string: ipv4_addr, ipv6_addr, ether_addr, inet_proto, inet_service, mark
+|typeof |
+data type of set element |
+expression to derive the data type from
+|flags |
+set flags | string: constant, dynamic, interval, timeout. Used to describe the sets properties.
+|timeout |
+time an element stays in the set, mandatory if set is added to from the packet path (ruleset)|
+string, decimal followed by unit. Units are: d, h, m, s
+|gc-interval |
+garbage collection interval, only available when timeout or flag timeout are
+active |
+string, decimal followed by unit. Units are: d, h, m, s
+|elements |
+elements contained by the set |
+set data type
+|size |
+maximum number of elements in the set, mandatory if set is added to from the packet path (ruleset)|
+unsigned integer (64 bit)
+|policy |
+set policy |
+string: performance [default], memory
+|auto-merge |
+automatic merge of adjacent/overlapping set elements (only for interval sets) |
+|=================
+
+
+MAPS
+-----
+[verse]
+*add map* ['family'] 'table' 'map' *{ type* 'type' | *typeof* 'expression' [*flags* 'flags' *;*] [*elements = {* 'element'[*,* ...] *} ;*] [*size* 'size' *;*] [*comment* 'comment' *;*'] [*policy* 'policy' *;*] *}*
+{*delete* | *destroy* | *list* | *flush* | *reset* } *map* ['family'] 'table' 'map'
+*list maps* ['family']
+
+Maps store data based on some specific key used as input. They are uniquely identified by a user-defined name and attached to tables.
+
+[horizontal]
+*add*:: Add a new map in the specified table.
+*delete*:: Delete the specified map.
+*destroy*:: Delete the specified map, it does not fail if it does not exist.
+*list*:: Display the elements in the specified map.
+*flush*:: Remove all elements from the specified map.
+*reset*:: Reset state in all contained elements, e.g. counter and quota statement values.
+
+.Map specifications
+[options="header"]
+|=================
+|Keyword | Description | Type
+|type |
+data type of map elements |
+string: ipv4_addr, ipv6_addr, ether_addr, inet_proto, inet_service, mark, counter, quota. Counter and quota can't be used as keys
+|typeof |
+data type of set element |
+expression to derive the data type from
+|flags |
+map flags |
+string, same as set flags
+|elements |
+elements contained by the map |
+map data type
+|size |
+maximum number of elements in the map |
+unsigned integer (64 bit)
+| policy |
+map policy |
+string: performance [default], memory
+|=================
+
+Users can specifiy the properties/features that the set/map must support.
+This allows the kernel to pick an optimal internal representation.
+If a required flag is missing, the ruleset might still work, as
+nftables will auto-enable features if it can infer this from the ruleset.
+This may not work for all cases, however, so it is recommended to
+specify all required features in the set/map definition manually.
+
+.Set and Map flags
+[options="header"]
+|=================
+|Flag | Description
+|constant | Set contents will never change after creation
+|dynamic | Set must support updates from the packet path with the *add*, *update* or *delete* keywords.
+|interval | Set must be able to store intervals (ranges)
+|timeout | Set must support element timeouts (auto-removal of elements once they expire).
+|=================
+
+ELEMENTS
+--------
+[verse]
+____
+{*add* | *create* | *delete* | *destroy* | *get* | *reset* } *element* ['family'] 'table' 'set' *{* 'ELEMENT'[*,* ...] *}*
+
+'ELEMENT' := 'key_expression' 'OPTIONS' [*:* 'value_expression']
+'OPTIONS' := [*timeout* 'TIMESPEC'] [*expires* 'TIMESPEC'] [*comment* 'string']
+'TIMESPEC' := ['num'*d*]['num'*h*]['num'*m*]['num'[*s*]]
+____
+Element-related commands allow one to change contents of named sets and maps.
+'key_expression' is typically a value matching the set type.
+'value_expression' is not allowed in sets but mandatory when adding to maps, where it
+matches the data part in its type definition. When deleting from maps, it may
+be specified but is optional as 'key_expression' uniquely identifies the
+element.
+
+*create* command is similar to *add* with the exception that none of the
+listed elements may already exist.
+
+*get* command is useful to check if an element is contained in a set which may
+be non-trivial in very large and/or interval sets. In the latter case, the
+containing interval is returned instead of just the element itself.
+
+*reset* command resets state attached to the given element(s), e.g. counter and
+quota statement values.
+
+.Element options
+[options="header"]
+|=================
+|Option | Description
+|timeout |
+timeout value for sets/maps with flag *timeout*
+|expires |
+the time until given element expires, useful for ruleset replication only
+|comment |
+per element comment field
+|=================
+
+
+FLOWTABLES
+-----------
+[verse]
+{*add* | *create*} *flowtable* ['family'] 'table' 'flowtable' *{ hook* 'hook' *priority* 'priority' *; devices = {* 'device'[*,* ...] *} ; }*
+*list flowtables* ['family']
+{*delete* | *destroy* | *list*} *flowtable* ['family'] 'table' 'flowtable'
+*delete* *flowtable* ['family'] 'table' *handle* 'handle'
+
+Flowtables allow you to accelerate packet forwarding in software. Flowtables
+entries are represented through a tuple that is composed of the input interface,
+source and destination address, source and destination port; and layer 3/4
+protocols. Each entry also caches the destination interface and the gateway
+address - to update the destination link-layer address - to forward packets.
+The ttl and hoplimit fields are also decremented. Hence, flowtables provides an
+alternative path that allow packets to bypass the classic forwarding path.
+Flowtables reside in the ingress hook that is located before the prerouting
+hook. You can select which flows you want to offload through the flow
+expression from the forward chain. Flowtables are identified by their address
+family and their name. The address family must be one of ip, ip6, or inet. The inet
+address family is a dummy family which is used to create hybrid IPv4/IPv6
+tables. When no address family is specified, ip is used by default.
+
+The *priority* can be a signed integer or *filter* which stands for 0. Addition
+and subtraction can be used to set relative priority, e.g. filter + 5 equals to
+5.
+
+[horizontal]
+*add*:: Add a new flowtable for the given family with the given name.
+*delete*:: Delete the specified flowtable.
+*destroy*:: Delete the specified flowtable, it does not fail if it does not exist.
+*list*:: List all flowtables.
+
+LISTING
+-------
+[verse]
+*list { secmarks | synproxys | flow tables | meters | hooks }* ['family']
+*list { secmarks | synproxys | flow tables | meters | hooks } table* ['family'] 'table'
+*list ct { timeout | expectation | helper | helpers } table* ['family'] 'table'
+
+Inspect configured objects.
+*list hooks* shows the full hook pipeline, including those registered by
+kernel modules, such as nf_conntrack.
+
+STATEFUL OBJECTS
+----------------
+[verse]
+{*add* | *delete* | *destroy* | *list* | *reset*} *counter* ['family'] 'table' 'object'
+{*add* | *delete* | *destroy* | *list* | *reset*} *quota* ['family'] 'table' 'object'
+{*add* | *delete* | *destroy* | *list*} *limit* ['family'] 'table' 'object'
+*delete* 'counter' ['family'] 'table' *handle* 'handle'
+*delete* 'quota' ['family'] 'table' *handle* 'handle'
+*delete* 'limit' ['family'] 'table' *handle* 'handle'
+*destroy* 'counter' ['family'] 'table' *handle* 'handle'
+*destroy* 'quota' ['family'] 'table' *handle* 'handle'
+*destroy* 'limit' ['family'] 'table' *handle* 'handle'
+*list counters* ['family']
+*list quotas* ['family']
+*list limits* ['family']
+*reset counters* ['family']
+*reset quotas* ['family']
+*reset counters* ['family'] 'table'
+*reset quotas* ['family'] 'table'
+
+Stateful objects are attached to tables and are identified by a unique name.
+They group stateful information from rules, to reference them in rules the
+keywords "type name" are used e.g. "counter name".
+
+[horizontal]
+*add*:: Add a new stateful object in the specified table.
+*delete*:: Delete the specified object.
+*destroy*:: Delete the specified object, it does not fail if it does not exist.
+*list*:: Display stateful information the object holds.
+*reset*:: List-and-reset stateful object.
+
+include::stateful-objects.txt[]
+
+EXPRESSIONS
+------------
+Expressions represent values, either constants like network addresses, port
+numbers, etc., or data gathered from the packet during ruleset evaluation.
+Expressions can be combined using binary, logical, relational and other types of
+expressions to form complex or relational (match) expressions. They are also
+used as arguments to certain types of operations, like NAT, packet marking etc.
+
+Each expression has a data type, which determines the size, parsing and
+representation of symbolic values and type compatibility with other expressions.
+
+DESCRIBE COMMAND
+~~~~~~~~~~~~~~~~
+[verse]
+*describe* 'expression' | 'data type'
+
+The *describe* command shows information about the type of an expression and its data type.
+A data type may also be given, in which nft will display more information
+about the type.
+
+.The describe command
+---------------------
+$ nft describe tcp flags
+payload expression, datatype tcp_flag (TCP flag) (basetype bitmask, integer), 8 bits
+
+predefined symbolic constants:
+fin 0x01
+syn 0x02
+rst 0x04
+psh 0x08
+ack 0x10
+urg 0x20
+ecn 0x40
+cwr 0x80
+---------------------
+
+DATA TYPES
+----------
+
+Data types determine the size, parsing and representation of symbolic values
+and type compatibility of expressions. A number of global data types exist, in
+addition some expression types define further data types specific to the
+expression type. Most data types have a fixed size, some however may have a
+dynamic size, f.i. the string type. +
+Some types also have predefined symbolic constants. Those can be listed
+using the nft *describe* command:
+
+---------------------
+$ nft describe ct_state
+datatype ct_state (conntrack state) (basetype bitmask, integer), 32 bits
+
+pre-defined symbolic constants (in hexadecimal):
+invalid 0x00000001
+new ...
+---------------------
+
+Types may be derived from lower order types, f.i. the IPv4 address type is
+derived from the integer type, meaning an IPv4 address can also be specified as
+an integer value. +
+
+In certain contexts (set and map definitions), it is necessary to explicitly
+specify a data type. Each type has a name which is used for this.
+
+include::data-types.txt[]
+
+PRIMARY EXPRESSIONS
+-------------------
+The lowest order expression is a primary expression, representing either a
+constant or a single datum from a packet's payload, meta data or a stateful
+module.
+
+include::primary-expression.txt[]
+
+PAYLOAD EXPRESSIONS
+-------------------
+Payload expressions refer to data from the packet's payload.
+
+include::payload-expression.txt[]
+
+STATEMENTS
+----------
+Statements represent actions to be performed. They can alter control flow
+(return, jump to a different chain, accept or drop the packet) or can perform
+actions, such as logging, rejecting a packet, etc. +
+
+Statements exist in two kinds. Terminal statements unconditionally terminate
+evaluation of the current rule, non-terminal statements either only
+conditionally or never terminate evaluation of the current rule, in other words,
+they are passive from the ruleset evaluation perspective. There can be an
+arbitrary amount of non-terminal statements in a rule, but only a single
+terminal statement as the final statement.
+
+include::statements.txt[]
+
+ADDITIONAL COMMANDS
+-------------------
+These are some additional commands included in nft.
+
+MONITOR
+~~~~~~~~
+The monitor command allows you to listen to Netlink events produced by the
+nf_tables subsystem. These are either related to creation and deletion of
+objects or to packets for which *meta nftrace* was enabled. When they
+occur, nft will print to stdout the monitored events in either JSON or
+native nft format. +
+
+[verse]
+____
+*monitor* [*new* | *destroy*] 'MONITOR_OBJECT'
+*monitor* *trace*
+
+'MONITOR_OBJECT' := *tables* | *chains* | *sets* | *rules* | *elements* | *ruleset*
+____
+
+To filter events related to a concrete object, use one of the keywords in
+'MONITOR_OBJECT'.
+
+To filter events related to a concrete action, use keyword *new* or *destroy*.
+
+The second form of invocation takes no further options and exclusively prints
+events generated for packets with *nftrace* enabled.
+
+Hit ^C to finish the monitor operation.
+
+.Listen to all events, report in native nft format
+--------------------------------------------------
+% nft monitor
+--------------------------------------------------
+
+.Listen to deleted rules, report in JSON format
+-----------------------------------------------
+% nft -j monitor destroy rules
+-----------------------------------------------
+
+.Listen to both new and destroyed chains, in native nft format
+-----------------------------------------------------------------
+% nft monitor chains
+-------------------------------
+
+.Listen to ruleset events such as table, chain, rule, set, counters and quotas, in native nft format
+----------------------------------------------------------------------------------------------------
+% nft monitor ruleset
+---------------------
+
+.Trace incoming packets from host 10.0.0.1
+------------------------------------------
+% nft add rule filter input ip saddr 10.0.0.1 meta nftrace set 1
+% nft monitor trace
+------------------------------------------
+
+ERROR REPORTING
+---------------
+When an error is detected, nft shows the line(s) containing the error, the
+position of the erroneous parts in the input stream and marks up the erroneous
+parts using carets (^). If the error results from the combination of two
+expressions or statements, the part imposing the constraints which are violated
+is marked using tildes (~). +
+
+For errors returned by the kernel, nft cannot detect which parts of the input
+caused the error and the entire command is marked.
+
+.Error caused by single incorrect expression
+--------------------------------------------
+<cmdline>:1:19-22: Error: Interface does not exist
+filter output oif eth0
+ ^^^^
+--------------------------------------------
+
+.Error caused by invalid combination of two expressions
+-------------------------------------------------------
+<cmdline>:1:28-36: Error: Right hand side of relational expression (==) must be constant
+filter output tcp dport == tcp dport
+ ~~ ^^^^^^^^^
+-------------------------------------------------------
+
+.Error returned by the kernel
+-----------------------------
+<cmdline>:0:0-23: Error: Could not process rule: Operation not permitted
+filter output oif wlan0
+^^^^^^^^^^^^^^^^^^^^^^^
+---------------------------------
+
+EXIT STATUS
+-----------
+On success, nft exits with a status of 0. Unspecified errors cause it to exit
+with a status of 1, memory allocation errors with a status of 2, unable to open
+Netlink socket with 3.
+
+SEE ALSO
+--------
+[verse]
+libnftables(3), libnftables-json(5), iptables(8), ip6tables(8), arptables(8), ebtables(8), ip(8), tc(8)
+
+There is an official wiki at: https://wiki.nftables.org
+
+AUTHORS
+-------
+nftables was written by Patrick McHardy and Pablo Neira Ayuso, among many other contributors from the Netfilter community.
+
+COPYRIGHT
+---------
+Copyright © 2008-2014 Patrick McHardy <kaber@trash.net> Copyright © 2013-2018 Pablo Neira Ayuso <pablo@netfilter.org> +
+
+nftables is free software; you can redistribute it and/or modify it under the
+terms of the GNU General Public License version 2 as published by the Free
+Software Foundation. +
+
+This documentation is licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 license, CC BY-SA 4.0 http://creativecommons.org/licenses/by-sa/4.0/.
diff --git a/doc/payload-expression.txt b/doc/payload-expression.txt
new file mode 100644
index 0000000..c7c267d
--- /dev/null
+++ b/doc/payload-expression.txt
@@ -0,0 +1,973 @@
+ETHERNET HEADER EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+[verse]
+*ether* {*daddr* | *saddr* | *type*}
+
+.Ethernet header expression types
+[options="header"]
+|==================
+|Keyword| Description| Type
+|daddr|
+Destination MAC address|
+ether_addr
+|saddr|
+Source MAC address|
+ether_addr
+|type|
+EtherType|
+ether_type
+|==================
+
+VLAN HEADER EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~~
+[verse]
+*vlan* {*id* | *dei* | *pcp* | *type*}
+
+The vlan expression is used to match on the vlan header fields.
+This expression will not work in the *ip*, *ip6* and *inet* families,
+unless the vlan interface is configured with the *reorder_hdr off* setting.
+The default is *reorder_hdr on* which will automatically remove the vlan tag
+from the packet. See ip-link(8) for more information.
+For these families its easier to match the vlan interface name
+instead, using the *meta iif* or *meta iifname* expression.
+
+.VLAN header expression
+[options="header"]
+|==================
+|Keyword| Description| Type
+|id|
+VLAN ID (VID) |
+integer (12 bit)
+|dei|
+Drop Eligible Indicator|
+integer (1 bit)
+|pcp|
+Priority code point|
+integer (3 bit)
+|type|
+EtherType|
+ether_type
+|==================
+
+ARP HEADER EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~
+[verse]
+*arp* {*htype* | *ptype* | *hlen* | *plen* | *operation* | *saddr* { *ip* | *ether* } | *daddr* { *ip* | *ether* }
+
+.ARP header expression
+[options="header"]
+|==================
+|Keyword| Description| Type
+|htype|
+ARP hardware type|
+integer (16 bit)
+|ptype|
+EtherType|
+ether_type
+|hlen|
+Hardware address len|
+integer (8 bit)
+|plen|
+Protocol address len |
+integer (8 bit)
+|operation|
+Operation |
+arp_op
+|saddr ether|
+Ethernet sender address|
+ether_addr
+|daddr ether|
+Ethernet target address|
+ether_addr
+|saddr ip|
+IPv4 sender address|
+ipv4_addr
+|daddr ip|
+IPv4 target address|
+ipv4_addr
+|======================
+
+IPV4 HEADER EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~~
+[verse]
+*ip* {*version* | *hdrlength* | *dscp* | *ecn* | *length* | *id* | *frag-off* | *ttl* | *protocol* | *checksum* | *saddr* | *daddr* }
+
+.IPv4 header expression
+[options="header"]
+|==================
+|Keyword| Description| Type
+|version|
+IP header version (4)|
+integer (4 bit)
+|hdrlength|
+IP header length including options|
+integer (4 bit) FIXME scaling
+|dscp|
+Differentiated Services Code Point|
+dscp
+|ecn|
+Explicit Congestion Notification|
+ecn
+|length|
+Total packet length |
+integer (16 bit)
+|id|
+IP ID|
+integer (16 bit)
+|frag-off|
+Fragment offset |
+integer (16 bit)
+|ttl|
+Time to live|
+integer (8 bit)
+|protocol|
+Upper layer protocol |
+inet_proto
+|checksum|
+IP header checksum|
+integer (16 bit)
+|saddr|
+Source address|
+ipv4_addr
+|daddr|
+Destination address |
+ipv4_addr
+|======================
+
+Careful with matching on *ip length*: If GRO/GSO is enabled, then the Linux
+kernel might aggregate several packets into one big packet that is larger than
+MTU. Moreover, if GRO/GSO maximum size is larger than 65535 (see man ip-link(8),
+specifically gro_ipv6_max_size and gso_ipv6_max_size), then *ip length* might
+be 0 for such jumbo packets. *meta length* allows you to match on the packet
+length including the IP header size. If you want to perform heuristics on the
+*ip length* field, then disable GRO/GSO.
+
+ICMP HEADER EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~~
+[verse]
+*icmp* {*type* | *code* | *checksum* | *id* | *sequence* | *gateway* | *mtu*}
+
+This expression refers to ICMP header fields. When using it in *inet*,
+*bridge* or *netdev* families, it will cause an implicit dependency on IPv4 to
+be created. To match on unusual cases like ICMP over IPv6, one has to add an
+explicit *meta protocol ip6* match to the rule.
+
+.ICMP header expression
+[options="header"]
+|==================
+|Keyword|Description| Type
+|type|
+ICMP type field |
+icmp_type
+|code|
+ICMP code field |
+integer (8 bit)
+|checksum|
+ICMP checksum field |
+integer (16 bit)
+|id|
+ID of echo request/response |
+integer (16 bit)
+|sequence|
+sequence number of echo request/response|
+integer (16 bit)
+|gateway|
+gateway of redirects|
+integer (32 bit)
+|mtu|
+MTU of path MTU discovery|
+integer (16 bit)
+|============================
+
+IGMP HEADER EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~~
+[verse]
+*igmp* {*type* | *mrt* | *checksum* | *group*}
+
+This expression refers to IGMP header fields. When using it in *inet*,
+*bridge* or *netdev* families, it will cause an implicit dependency on IPv4 to
+be created. To match on unusual cases like IGMP over IPv6, one has to add an
+explicit *meta protocol ip6* match to the rule.
+
+.IGMP header expression
+[options="header"]
+|==================
+|Keyword|Description| Type
+|type|
+IGMP type field |
+igmp_type
+|mrt|
+IGMP maximum response time field |
+integer (8 bit)
+|checksum|
+IGMP checksum field |
+integer (16 bit)
+|group|
+Group address|
+integer (32 bit)
+|============================
+
+IPV6 HEADER EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~~
+[verse]
+*ip6* {*version* | *dscp* | *ecn* | *flowlabel* | *length* | *nexthdr* | *hoplimit* | *saddr* | *daddr*}
+
+This expression refers to the ipv6 header fields. Caution when using *ip6
+nexthdr*, the value only refers to the next header, i.e. *ip6 nexthdr tcp* will
+only match if the ipv6 packet does not contain any extension headers. Packets
+that are fragmented or e.g. contain a routing extension headers will not be
+matched. Please use *meta l4proto* if you wish to match the real transport header
+and ignore any additional extension headers instead.
+
+.IPv6 header expression
+[options="header"]
+|==================
+|Keyword|Description| Type
+|version|
+IP header version (6)|
+integer (4 bit)
+|dscp|
+Differentiated Services Code Point|
+dscp
+|ecn|
+Explicit Congestion Notification|
+ecn
+|flowlabel|
+Flow label|
+integer (20 bit)
+|length|
+Payload length|
+integer (16 bit)
+|nexthdr|
+Nexthdr protocol|
+inet_proto
+|hoplimit|
+Hop limit|
+integer (8 bit)
+|saddr|
+Source address|
+ipv6_addr
+|daddr|
+Destination address |
+ipv6_addr
+|=======================
+
+Careful with matching on *ip6 length*: If GRO/GSO is enabled, then the Linux
+kernel might aggregate several packets into one big packet that is larger than
+MTU. Moreover, if GRO/GSO maximum size is larger than 65535 (see man ip-link(8),
+specifically gro_ipv6_max_size and gso_ipv6_max_size), then *ip6 length* might
+be 0 for such jumbo packets. *meta length* allows you to match on the packet
+length including the IP header size. If you want to perform heuristics on the
+*ip6 length* field, then disable GRO/GSO.
+
+.Using ip6 header expressions
+-----------------------------
+# matching if first extension header indicates a fragment
+ip6 nexthdr ipv6-frag
+-----------------------------
+
+ICMPV6 HEADER EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~~~~
+[verse]
+*icmpv6* {*type* | *code* | *checksum* | *parameter-problem* | *packet-too-big* | *id* | *sequence* | *max-delay* | *taddr* | *daddr*}
+
+This expression refers to ICMPv6 header fields. When using it in *inet*,
+*bridge* or *netdev* families, it will cause an implicit dependency on IPv6 to
+be created. To match on unusual cases like ICMPv6 over IPv4, one has to add an
+explicit *meta protocol ip* match to the rule.
+
+.ICMPv6 header expression
+[options="header"]
+|==================
+|Keyword| Description| Type
+|type|
+ICMPv6 type field|
+icmpv6_type
+|code|
+ICMPv6 code field|
+integer (8 bit)
+|checksum|
+ICMPv6 checksum field|
+integer (16 bit)
+|parameter-problem|
+pointer to problem|
+integer (32 bit)
+|packet-too-big|
+oversized MTU|
+integer (32 bit)
+|id|
+ID of echo request/response |
+integer (16 bit)
+|sequence|
+sequence number of echo request/response|
+integer (16 bit)
+|max-delay|
+maximum response delay of MLD queries|
+integer (16 bit)
+|taddr|
+target address of neighbor solicit/advert, redirect or MLD|
+ipv6_addr
+|daddr|
+destination address of redirect|
+ipv6_addr
+|==============================
+
+TCP HEADER EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~
+[verse]
+*tcp* {*sport* | *dport* | *sequence* | *ackseq* | *doff* | *reserved* | *flags* | *window* | *checksum* | *urgptr*}
+
+.TCP header expression
+[options="header"]
+|==================
+|Keyword| Description| Type
+|sport|
+Source port|
+inet_service
+|dport|
+Destination port|
+inet_service
+|sequence|
+Sequence number|
+integer (32 bit)
+|ackseq|
+Acknowledgement number |
+integer (32 bit)
+|doff|
+Data offset |
+integer (4 bit) FIXME scaling
+|reserved|
+Reserved area |
+integer (4 bit)
+|flags|
+TCP flags|
+tcp_flag
+|window|
+Window|
+integer (16 bit)
+|checksum|
+Checksum|
+integer (16 bit)
+|urgptr|
+Urgent pointer|
+integer (16 bit)
+|======================
+
+UDP HEADER EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~
+[verse]
+*udp* {*sport* | *dport* | *length* | *checksum*}
+
+.UDP header expression
+[options="header"]
+|==================
+|Keyword| Description| Type
+|sport|
+Source port|
+inet_service
+|dport|
+Destination port|
+inet_service
+|length|
+Total packet length|
+integer (16 bit)
+|checksum|
+Checksum|
+integer (16 bit)
+|================
+
+UDP-LITE HEADER EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+[verse]
+*udplite* {*sport* | *dport* | *checksum*}
+
+.UDP-Lite header expression
+[options="header"]
+|==================
+|Keyword| Description| Type
+|sport|
+Source port|
+inet_service
+|dport|
+Destination port|
+inet_service
+|checksum|
+Checksum|
+integer (16 bit)
+|================
+
+SCTP HEADER EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~~~
+[verse]
+____
+*sctp* {*sport* | *dport* | *vtag* | *checksum*}
+*sctp chunk* 'CHUNK' [ 'FIELD' ]
+
+'CHUNK' := *data* | *init* | *init-ack* | *sack* | *heartbeat* |
+ *heartbeat-ack* | *abort* | *shutdown* | *shutdown-ack* | *error* |
+ *cookie-echo* | *cookie-ack* | *ecne* | *cwr* | *shutdown-complete*
+ | *asconf-ack* | *forward-tsn* | *asconf*
+
+'FIELD' := 'COMMON_FIELD' | 'DATA_FIELD' | 'INIT_FIELD' | 'INIT_ACK_FIELD' |
+ 'SACK_FIELD' | 'SHUTDOWN_FIELD' | 'ECNE_FIELD' | 'CWR_FIELD' |
+ 'ASCONF_ACK_FIELD' | 'FORWARD_TSN_FIELD' | 'ASCONF_FIELD'
+
+'COMMON_FIELD' := *type* | *flags* | *length*
+'DATA_FIELD' := *tsn* | *stream* | *ssn* | *ppid*
+'INIT_FIELD' := *init-tag* | *a-rwnd* | *num-outbound-streams* |
+ *num-inbound-streams* | *initial-tsn*
+'INIT_ACK_FIELD' := 'INIT_FIELD'
+'SACK_FIELD' := *cum-tsn-ack* | *a-rwnd* | *num-gap-ack-blocks* |
+ *num-dup-tsns*
+'SHUTDOWN_FIELD' := *cum-tsn-ack*
+'ECNE_FIELD' := *lowest-tsn*
+'CWR_FIELD' := *lowest-tsn*
+'ASCONF_ACK_FIELD' := *seqno*
+'FORWARD_TSN_FIELD' := *new-cum-tsn*
+'ASCONF_FIELD' := *seqno*
+____
+
+.SCTP header expression
+[options="header"]
+|==================
+|Keyword| Description| Type
+|sport|
+Source port|
+inet_service
+|dport|
+Destination port|
+inet_service
+|vtag|
+Verification Tag|
+integer (32 bit)
+|checksum|
+Checksum|
+integer (32 bit)
+|chunk|
+Search chunk in packet|
+without 'FIELD', boolean indicating existence
+|================
+
+.SCTP chunk fields
+[options="header"]
+|==================
+|Name| Width in bits | Chunk | Notes
+|type| 8 | all | not useful, defined by chunk type
+|flags| 8 | all | semantics defined on per-chunk basis
+|length| 16 | all | length of this chunk in bytes excluding padding
+|tsn| 32 | data | transmission sequence number
+|stream| 16 | data | stream identifier
+|ssn| 16 | data | stream sequence number
+|ppid| 32 | data | payload protocol identifier
+|init-tag| 32 | init, init-ack | initiate tag
+|a-rwnd| 32 | init, init-ack, sack | advertised receiver window credit
+|num-outbound-streams| 16 | init, init-ack | number of outbound streams
+|num-inbound-streams| 16 | init, init-ack | number of inbound streams
+|initial-tsn| 32 | init, init-ack | initial transmit sequence number
+|cum-tsn-ack| 32 | sack, shutdown | cumulative transmission sequence number acknowledged
+|num-gap-ack-blocks| 16 | sack | number of Gap Ack Blocks included
+|num-dup-tsns| 16 | sack | number of duplicate transmission sequence numbers received
+|lowest-tsn| 32 | ecne, cwr | lowest transmission sequence number
+|seqno| 32 | asconf-ack, asconf | sequence number
+|new-cum-tsn| 32 | forward-tsn | new cumulative transmission sequence number
+|==================
+
+DCCP HEADER EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~~
+[verse]
+*dccp* {*sport* | *dport* | *type*}
+
+.DCCP header expression
+[options="header"]
+|==================
+|Keyword| Description| Type
+|sport|
+Source port|
+inet_service
+|dport|
+Destination port|
+inet_service
+|type|
+Packet type|
+dccp_pkttype
+|========================
+
+AUTHENTICATION HEADER EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+[verse]
+*ah* {*nexthdr* | *hdrlength* | *reserved* | *spi* | *sequence*}
+
+.AH header expression
+[options="header"]
+|==================
+|Keyword| Description| Type
+|nexthdr|
+Next header protocol|
+inet_proto
+|hdrlength|
+AH Header length|
+integer (8 bit)
+|reserved|
+Reserved area|
+integer (16 bit)
+|spi|
+Security Parameter Index |
+integer (32 bit)
+|sequence|
+Sequence number|
+integer (32 bit)
+|========================
+
+ENCRYPTED SECURITY PAYLOAD HEADER EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+[verse]
+*esp* {*spi* | *sequence*}
+
+.ESP header expression
+[options="header"]
+|==================
+|Keyword| Description| Type
+|spi|
+Security Parameter Index |
+integer (32 bit)
+|sequence|
+Sequence number|
+integer (32 bit)
+|===========================
+
+IPCOMP HEADER EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~~~~~
+*comp* {*nexthdr* | *flags* | *cpi*}
+
+.IPComp header expression
+[options="header"]
+|==================
+|Keyword| Description| Type
+|nexthdr|
+Next header protocol|
+inet_proto
+|flags|
+Flags|
+bitmask
+|cpi|
+compression Parameter Index |
+integer (16 bit)
+|============================
+
+GRE HEADER EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~~~
+[verse]
+*gre* {*flags* | *version* | *protocol*}
+*gre* *ip* {*version* | *hdrlength* | *dscp* | *ecn* | *length* | *id* | *frag-off* | *ttl* | *protocol* | *checksum* | *saddr* | *daddr* }
+*gre* *ip6* {*version* | *dscp* | *ecn* | *flowlabel* | *length* | *nexthdr* | *hoplimit* | *saddr* | *daddr*}
+
+The gre expression is used to match on the gre header fields. This expression
+also allows to match on the IPv4 or IPv6 packet within the gre header.
+
+.GRE header expression
+[options="header"]
+|==================
+|Keyword| Description| Type
+|flags|
+checksum, routing, key, sequence and strict source route flags|
+integer (5 bit)
+|version|
+gre version field, 0 for GRE and 1 for PPTP|
+integer (3 bit)
+|protocol|
+EtherType of encapsulated packet|
+integer (16 bit)
+|==================
+
+.Matching inner IPv4 destination address encapsulated in gre
+------------------------------------------------------------
+netdev filter ingress gre ip daddr 9.9.9.9 counter
+------------------------------------------------------------
+
+GENEVE HEADER EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~~~~
+[verse]
+*geneve* {*vni* | *flags*}
+*geneve* *ether* {*daddr* | *saddr* | *type*}
+*geneve* *vlan* {*id* | *dei* | *pcp* | *type*}
+*geneve* *ip* {*version* | *hdrlength* | *dscp* | *ecn* | *length* | *id* | *frag-off* | *ttl* | *protocol* | *checksum* | *saddr* | *daddr* }
+*geneve* *ip6* {*version* | *dscp* | *ecn* | *flowlabel* | *length* | *nexthdr* | *hoplimit* | *saddr* | *daddr*}
+*geneve* *tcp* {*sport* | *dport* | *sequence* | *ackseq* | *doff* | *reserved* | *flags* | *window* | *checksum* | *urgptr*}
+*geneve* *udp* {*sport* | *dport* | *length* | *checksum*}
+
+The geneve expression is used to match on the geneve header fields. The geneve
+header encapsulates a ethernet frame within a *udp* packet. This expression
+requires that you restrict the matching to *udp* packets (usually at
+port 6081 according to IANA-assigned ports).
+
+.GENEVE header expression
+[options="header"]
+|==================
+|Keyword| Description| Type
+|protocol|
+EtherType of encapsulated packet|
+integer (16 bit)
+|vni|
+Virtual Network ID (VNI)|
+integer (24 bit)
+|==================
+
+.Matching inner TCP destination port encapsulated in geneve
+----------------------------------------------------------
+netdev filter ingress udp dport 4789 geneve tcp dport 80 counter
+----------------------------------------------------------
+
+GRETAP HEADER EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~~~~
+[verse]
+*gretap* {*vni* | *flags*}
+*gretap* *ether* {*daddr* | *saddr* | *type*}
+*gretap* *vlan* {*id* | *dei* | *pcp* | *type*}
+*gretap* *ip* {*version* | *hdrlength* | *dscp* | *ecn* | *length* | *id* | *frag-off* | *ttl* | *protocol* | *checksum* | *saddr* | *daddr* }
+*gretap* *ip6* {*version* | *dscp* | *ecn* | *flowlabel* | *length* | *nexthdr* | *hoplimit* | *saddr* | *daddr*}
+*gretap* *tcp* {*sport* | *dport* | *sequence* | *ackseq* | *doff* | *reserved* | *flags* | *window* | *checksum* | *urgptr*}
+*gretap* *udp* {*sport* | *dport* | *length* | *checksum*}
+
+The gretap expression is used to match on the encapsulated ethernet frame
+within the gre header. Use the *gre* expression to match on the *gre* header
+fields.
+
+.Matching inner TCP destination port encapsulated in gretap
+----------------------------------------------------------
+netdev filter ingress gretap tcp dport 80 counter
+----------------------------------------------------------
+
+VXLAN HEADER EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~~~
+[verse]
+*vxlan* {*vni* | *flags*}
+*vxlan* *ether* {*daddr* | *saddr* | *type*}
+*vxlan* *vlan* {*id* | *dei* | *pcp* | *type*}
+*vxlan* *ip* {*version* | *hdrlength* | *dscp* | *ecn* | *length* | *id* | *frag-off* | *ttl* | *protocol* | *checksum* | *saddr* | *daddr* }
+*vxlan* *ip6* {*version* | *dscp* | *ecn* | *flowlabel* | *length* | *nexthdr* | *hoplimit* | *saddr* | *daddr*}
+*vxlan* *tcp* {*sport* | *dport* | *sequence* | *ackseq* | *doff* | *reserved* | *flags* | *window* | *checksum* | *urgptr*}
+*vxlan* *udp* {*sport* | *dport* | *length* | *checksum*}
+
+The vxlan expression is used to match on the vxlan header fields. The vxlan
+header encapsulates a ethernet frame within a *udp* packet. This expression
+requires that you restrict the matching to *udp* packets (usually at
+port 4789 according to IANA-assigned ports).
+
+.VXLAN header expression
+[options="header"]
+|==================
+|Keyword| Description| Type
+|flags|
+vxlan flags|
+integer (8 bit)
+|vni|
+Virtual Network ID (VNI)|
+integer (24 bit)
+|==================
+
+.Matching inner TCP destination port encapsulated in vxlan
+----------------------------------------------------------
+netdev filter ingress udp dport 4789 vxlan tcp dport 80 counter
+----------------------------------------------------------
+
+ARP HEADER EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~
+[verse]
+*arp* {*htype* | *ptype* | *hlen* | *plen* | *operation* | *saddr* { *ip* | *ether* } | *daddr* { *ip* | *ether* }
+
+.ARP header expression
+[options="header"]
+|==================
+|Keyword| Description| Type
+|htype|
+ARP hardware type|
+integer (16 bit)
+|ptype|
+EtherType|
+ether_type
+|hlen|
+Hardware address len|
+integer (8 bit)
+|plen|
+Protocol address len |
+integer (8 bit)
+|operation|
+Operation |
+arp_op
+|saddr ether|
+Ethernet sender address|
+ether_addr
+|daddr ether|
+Ethernet target address|
+ether_addr
+|saddr ip|
+IPv4 sender address|
+ipv4_addr
+|daddr ip|
+IPv4 target address|
+ipv4_addr
+|======================
+
+RAW PAYLOAD EXPRESSION
+~~~~~~~~~~~~~~~~~~~~~~
+[verse]
+*@*'base'*,*'offset'*,*'length'
+
+The raw payload expression instructs to load 'length' bits starting at 'offset' bits.
+Bit 0 refers to the very first bit -- in the C programming language, this
+corresponds to the topmost bit, i.e. 0x80 in case of an octet. They are useful
+to match headers that do not have a human-readable template expression yet. Note
+that nft will not add dependencies for Raw payload expressions. If you e.g. want
+to match protocol fields of a transport header with protocol number 5, you need
+to manually exclude packets that have a different transport header, for instance
+by using *meta l4proto 5* before the raw expression.
+
+.Supported payload protocol bases
+[options="header"]
+|==================
+|Base| Description
+|ll|
+Link layer, for example the Ethernet header
+|nh|
+Network header, for example IPv4 or IPv6
+|th|
+Transport Header, for example TCP
+|ih|
+Inner Header / Payload, i.e. after the L4 transport level header
+|==============================
+
+.Matching destination port of both UDP and TCP
+----------------------------------------------
+inet filter input meta l4proto {tcp, udp} @th,16,16 { 53, 80 }
+-----------------------------------------------------------------
+The above can also be written as
+-----------------------------------------------------------------
+inet filter input meta l4proto {tcp, udp} th dport { 53, 80 }
+-----------------------------------------------------------------
+it is more convenient, but like the raw expression notation no
+dependencies are created or checked. It is the users responsibility
+to restrict matching to those header types that have a notion of ports.
+Otherwise, rules using raw expressions will errnously match unrelated
+packets, e.g. mis-interpreting ESP packets SPI field as a port.
+
+.Rewrite arp packet target hardware address if target protocol address matches a given address
+----------------------------------------------------------------------------------------------
+input meta iifname enp2s0 arp ptype 0x0800 arp htype 1 arp hlen 6 arp plen 4 @nh,192,32 0xc0a88f10 @nh,144,48 set 0x112233445566 accept
+-----------------------------------------------------------------------------------------------
+
+EXTENSION HEADER EXPRESSIONS
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Extension header expressions refer to data from variable-sized protocol headers, such as IPv6 extension headers, TCP options and IPv4 options.
+
+nftables currently supports matching (finding) a given ipv6 extension header, TCP option or IPv4 option.
+[verse]
+*hbh* {*nexthdr* | *hdrlength*}
+*frag* {*nexthdr* | *frag-off* | *more-fragments* | *id*}
+*rt* {*nexthdr* | *hdrlength* | *type* | *seg-left*}
+*dst* {*nexthdr* | *hdrlength*}
+*mh* {*nexthdr* | *hdrlength* | *checksum* | *type*}
+*srh* {*flags* | *tag* | *sid* | *seg-left*}
+*tcp option* {*eol* | *nop* | *maxseg* | *window* | *sack-perm* | *sack* | *sack0* | *sack1* | *sack2* | *sack3* | *timestamp*} 'tcp_option_field'
+*ip option* { lsrr | ra | rr | ssrr } 'ip_option_field'
+
+The following syntaxes are valid only in a relational expression with boolean type on right-hand side for checking header existence only:
+[verse]
+*exthdr* {*hbh* | *frag* | *rt* | *dst* | *mh*}
+*tcp option* {*eol* | *nop* | *maxseg* | *window* | *sack-perm* | *sack* | *sack0* | *sack1* | *sack2* | *sack3* | *timestamp*}
+*ip option* { lsrr | ra | rr | ssrr }
+*dccp option* 'dccp_option_type'
+
+.IPv6 extension headers
+[options="header"]
+|==================
+|Keyword| Description
+|hbh|
+Hop by Hop
+|rt|
+Routing Header
+|frag|
+Fragmentation header
+|dst|
+dst options
+|mh|
+Mobility Header
+|srh|
+Segment Routing Header
+|=====================
+
+.TCP Options
+[options="header"]
+|==================
+|Keyword| Description | TCP option fields
+|eol|
+End if option list|
+-
+|nop|
+1 Byte TCP Nop padding option |
+-
+|maxseg|
+TCP Maximum Segment Size|
+length, size
+|window|
+TCP Window Scaling |
+length, count
+|sack-perm |
+TCP SACK permitted |
+length
+|sack|
+TCP Selective Acknowledgement (alias of block 0) |
+length, left, right
+|sack0|
+TCP Selective Acknowledgement (block 0) |
+length, left, right
+|sack1|
+TCP Selective Acknowledgement (block 1) |
+length, left, right
+|sack2|
+TCP Selective Acknowledgement (block 2) |
+length, left, right
+|sack3|
+TCP Selective Acknowledgement (block 3) |
+length, left, right
+|timestamp|
+TCP Timestamps |
+length, tsval, tsecr
+|============================
+
+TCP option matching also supports raw expression syntax to access arbitrary options:
+[verse]
+*tcp option*
+[verse]
+*tcp option* *@*'number'*,*'offset'*,*'length'
+
+.IP Options
+[options="header"]
+|==================
+|Keyword| Description | IP option fields
+|lsrr|
+Loose Source Route |
+type, length, ptr, addr
+|ra|
+Router Alert |
+type, length, value
+|rr|
+Record Route |
+type, length, ptr, addr
+|ssrr|
+Strict Source Route |
+type, length, ptr, addr
+|============================
+
+.finding TCP options
+--------------------
+filter input tcp option sack-perm exists counter
+--------------------
+
+.matching TCP options
+--------------------
+filter input tcp option maxseg size lt 536
+--------------------
+
+.matching IPv6 exthdr
+---------------------
+ip6 filter input frag more-fragments 1 counter
+---------------------------------------
+
+.finding IP option
+------------------
+filter input ip option lsrr exists counter
+---------------------------------------
+
+.finding DCCP option
+------------------
+filter input dccp option 40 exists counter
+---------------------------------------
+
+CONNTRACK EXPRESSIONS
+~~~~~~~~~~~~~~~~~~~~~
+Conntrack expressions refer to meta data of the connection tracking entry associated with a packet. +
+
+There are three types of conntrack expressions. Some conntrack expressions
+require the flow direction before the conntrack key, others must be used
+directly because they are direction agnostic. The *packets*, *bytes* and
+*avgpkt* keywords can be used with or without a direction. If the direction is
+omitted, the sum of the original and the reply direction is returned. The same
+is true for the *zone*, if a direction is given, the zone is only matched if the
+zone id is tied to the given direction. +
+
+[verse]
+*ct* {*state* | *direction* | *status* | *mark* | *expiration* | *helper* | *label* | *count* | *id*}
+*ct* [*original* | *reply*] {*l3proto* | *protocol* | *bytes* | *packets* | *avgpkt* | *zone*}
+*ct* {*original* | *reply*} {*proto-src* | *proto-dst*}
+*ct* {*original* | *reply*} {*ip* | *ip6*} {*saddr* | *daddr*}
+
+The conntrack-specific types in this table are described in the sub-section CONNTRACK TYPES above.
+
+.Conntrack expressions
+[options="header"]
+|==================
+|Keyword| Description | Type
+|state|
+State of the connection |
+ct_state
+|direction|
+Direction of the packet relative to the connection |
+ct_dir
+|status|
+Status of the connection |
+ct_status
+|mark|
+Connection mark |
+mark
+|expiration|
+Connection expiration time |
+time
+|helper|
+Helper associated with the connection|
+string
+|label|
+Connection tracking label bit or symbolic name defined in connlabel.conf in the nftables include path|
+ct_label
+|l3proto|
+Layer 3 protocol of the connection|
+nf_proto
+|saddr|
+Source address of the connection for the given direction |
+ipv4_addr/ipv6_addr
+|daddr|
+Destination address of the connection for the given direction |
+ipv4_addr/ipv6_addr
+|protocol|
+Layer 4 protocol of the connection for the given direction |
+inet_proto
+|proto-src|
+Layer 4 protocol source for the given direction|
+integer (16 bit)
+|proto-dst|
+Layer 4 protocol destination for the given direction |
+integer (16 bit)
+|packets|
+packet count seen in the given direction or sum of original and reply |
+integer (64 bit)
+|bytes|
+byte count seen, see description for *packets* keyword |
+integer (64 bit)
+|avgpkt|
+average bytes per packet, see description for *packets* keyword |
+integer (64 bit)
+|zone|
+conntrack zone |
+integer (16 bit)
+|count|
+number of current connections|
+integer (32 bit)
+|id|
+Connection id|
+ct_id|
+|==========================================
+
+.restrict the number of parallel connections to a server
+--------------------
+nft add set filter ssh_flood '{ type ipv4_addr; flags dynamic; }'
+nft add rule filter input tcp dport 22 add @ssh_flood '{ ip saddr ct count over 2 }' reject
+--------------------
diff --git a/doc/primary-expression.txt b/doc/primary-expression.txt
new file mode 100644
index 0000000..e13970c
--- /dev/null
+++ b/doc/primary-expression.txt
@@ -0,0 +1,488 @@
+META EXPRESSIONS
+~~~~~~~~~~~~~~~~
+[verse]
+*meta* {*length* | *nfproto* | *l4proto* | *protocol* | *priority*}
+[*meta*] {*mark* | *iif* | *iifname* | *iiftype* | *oif* | *oifname* | *oiftype* | *skuid* | *skgid* | *nftrace* | *rtclassid* | *ibrname* | *obrname* | *pkttype* | *cpu* | *iifgroup* | *oifgroup* | *cgroup* | *random* | *ipsec* | *iifkind* | *oifkind* | *time* | *hour* | *day* }
+
+A meta expression refers to meta data associated with a packet.
+
+There are two types of meta expressions: unqualified and qualified meta
+expressions. Qualified meta expressions require the meta keyword before the meta
+key, unqualified meta expressions can be specified by using the meta key
+directly or as qualified meta expressions. Meta l4proto is useful to match a
+particular transport protocol that is part of either an IPv4 or IPv6 packet. It
+will also skip any IPv6 extension headers present in an IPv6 packet.
+
+meta iif, oif, iifname and oifname are used to match the interface a packet
+arrived on or is about to be sent out on.
+
+iif and oif are used to match on the interface index, whereas iifname and
+oifname are used to match on the interface name.
+This is not the same -- assuming the rule
+
+ filter input meta iif "foo"
+
+Then this rule can only be added if the interface "foo" exists.
+Also, the rule will continue to match even if the
+interface "foo" is renamed to "bar".
+
+This is because internally the interface index is used.
+In case of dynamically created interfaces, such as tun/tap or dialup
+interfaces (ppp for example), it might be better to use iifname or oifname
+instead.
+
+In these cases, the name is used so the interface doesn't have to exist to
+add such a rule, it will stop matching if the interface gets renamed and it
+will match again in case interface gets deleted and later a new interface
+with the same name is created.
+
+Like with iptables, wildcard matching on interface name prefixes is available for
+*iifname* and *oifname* matches by appending an asterisk (*) character. Note
+however that unlike iptables, nftables does not accept interface names
+consisting of the wildcard character only - users are supposed to just skip
+those always matching expressions. In order to match on literal asterisk
+character, one may escape it using backslash (\).
+
+.Meta expression types
+[options="header"]
+|==================
+|Keyword | Description | Type
+|length|
+Length of the packet in bytes|
+integer (32-bit)
+|nfproto|
+real hook protocol family, useful only in inet table|
+integer (32 bit)
+|l4proto|
+layer 4 protocol, skips ipv6 extension headers|
+integer (8 bit)
+|protocol|
+EtherType protocol value|
+ether_type
+|priority|
+TC packet priority|
+tc_handle
+|mark|
+Packet mark |
+mark
+|iif|
+Input interface index |
+iface_index
+|iifname|
+Input interface name |
+ifname
+|iiftype|
+Input interface type|
+iface_type
+|oif|
+Output interface index|
+iface_index
+|oifname|
+Output interface name|
+ifname
+|oiftype|
+Output interface hardware type|
+iface_type
+|sdif|
+Slave device input interface index |
+iface_index
+|sdifname|
+Slave device interface name|
+ifname
+|skuid|
+UID associated with originating socket|
+uid
+|skgid|
+GID associated with originating socket|
+gid
+|rtclassid|
+Routing realm|
+realm
+|ibrname|
+Input bridge interface name|
+ifname
+|obrname|
+Output bridge interface name|
+ifname
+|pkttype|
+packet type|
+pkt_type
+|cpu|
+cpu number processing the packet|
+integer (32 bit)
+|iifgroup|
+incoming device group|
+devgroup
+|oifgroup|
+outgoing device group|
+devgroup
+|cgroup|
+control group id |
+integer (32 bit)
+|random|
+pseudo-random number|
+integer (32 bit)
+|ipsec|
+true if packet was ipsec encrypted |
+boolean (1 bit)
+|iifkind|
+Input interface kind |
+|oifkind|
+Output interface kind|
+|time|
+Absolute time of packet reception|
+Integer (32 bit) or string
+|day|
+Day of week|
+Integer (8 bit) or string
+|hour|
+Hour of day|
+String
+|====================
+
+.Meta expression specific types
+[options="header"]
+|==================
+|Type | Description
+|iface_index |
+Interface index (32 bit number). Can be specified numerically or as name of an existing interface.
+|ifname|
+Interface name (16 byte string). Does not have to exist.
+|iface_type|
+Interface type (16 bit number).
+|uid|
+User ID (32 bit number). Can be specified numerically or as user name.
+|gid|
+Group ID (32 bit number). Can be specified numerically or as group name.
+|realm|
+Routing Realm (32 bit number). Can be specified numerically or as symbolic name defined in /etc/iproute2/rt_realms.
+|devgroup_type|
+Device group (32 bit number). Can be specified numerically or as symbolic name defined in /etc/iproute2/group.
+|pkt_type|
+Packet type: *host* (addressed to local host), *broadcast* (to all),
+*multicast* (to group), *other* (addressed to another host).
+|ifkind|
+Interface kind (16 byte string). See TYPES in ip-link(8) for a list.
+|time|
+Either an integer or a date in ISO format. For example: "2019-06-06 17:00".
+Hour and seconds are optional and can be omitted if desired. If omitted,
+midnight will be assumed.
+The following three would be equivalent: "2019-06-06", "2019-06-06 00:00"
+and "2019-06-06 00:00:00".
+When an integer is given, it is assumed to be a UNIX timestamp.
+|day|
+Either a day of week ("Monday", "Tuesday", etc.), or an integer between 0 and 6.
+Strings are matched case-insensitively, and a full match is not expected (e.g. "Mon" would match "Monday").
+When an integer is given, 0 is Sunday and 6 is Saturday.
+|hour|
+A string representing an hour in 24-hour format. Seconds can optionally be specified.
+For example, 17:00 and 17:00:00 would be equivalent.
+|=============================
+
+.Using meta expressions
+-----------------------
+# qualified meta expression
+filter output meta oif eth0
+filter forward meta iifkind { "tun", "veth" }
+
+# unqualified meta expression
+filter output oif eth0
+
+# incoming packet was subject to ipsec processing
+raw prerouting meta ipsec exists accept
+-----------------------
+
+SOCKET EXPRESSION
+~~~~~~~~~~~~~~~~~
+[verse]
+*socket* {*transparent* | *mark* | *wildcard*}
+*socket* *cgroupv2* *level* 'NUM'
+
+Socket expression can be used to search for an existing open TCP/UDP socket and
+its attributes that can be associated with a packet. It looks for an established
+or non-zero bound listening socket (possibly with a non-local address). You can
+also use it to match on the socket cgroupv2 at a given ancestor level, e.g. if
+the socket belongs to cgroupv2 'a/b', ancestor level 1 checks for a matching on
+cgroup 'a' and ancestor level 2 checks for a matching on cgroup 'b'.
+
+.Available socket attributes
+[options="header"]
+|==================
+|Name |Description| Type
+|transparent|
+Value of the IP_TRANSPARENT socket option in the found socket. It can be 0 or 1.|
+boolean (1 bit)
+|mark| Value of the socket mark (SOL_SOCKET, SO_MARK). | mark
+|wildcard|
+Indicates whether the socket is wildcard-bound (e.g. 0.0.0.0 or ::0). |
+boolean (1 bit)
+|cgroupv2|
+cgroup version 2 for this socket (path from /sys/fs/cgroup)|
+cgroupv2
+|==================
+
+.Using socket expression
+------------------------
+# Mark packets that correspond to a transparent socket. "socket wildcard 0"
+# means that zero-bound listener sockets are NOT matched (which is usually
+# exactly what you want).
+table inet x {
+ chain y {
+ type filter hook prerouting priority mangle; policy accept;
+ socket transparent 1 socket wildcard 0 mark set 0x00000001 accept
+ }
+}
+
+# Trace packets that corresponds to a socket with a mark value of 15
+table inet x {
+ chain y {
+ type filter hook prerouting priority mangle; policy accept;
+ socket mark 0x0000000f nftrace set 1
+ }
+}
+
+# Set packet mark to socket mark
+table inet x {
+ chain y {
+ type filter hook prerouting priority mangle; policy accept;
+ tcp dport 8080 mark set socket mark
+ }
+}
+
+# Count packets for cgroupv2 "user.slice" at level 1
+table inet x {
+ chain y {
+ type filter hook input priority filter; policy accept;
+ socket cgroupv2 level 1 "user.slice" counter
+ }
+}
+----------------------
+
+OSF EXPRESSION
+~~~~~~~~~~~~~~
+[verse]
+*osf* [*ttl* {*loose* | *skip*}] {*name* | *version*}
+
+The osf expression does passive operating system fingerprinting. This
+expression compares some data (Window Size, MSS, options and their order, DF,
+and others) from packets with the SYN bit set.
+
+.Available osf attributes
+[options="header"]
+|==================
+|Name |Description| Type
+|ttl|
+Do TTL checks on the packet to determine the operating system.|
+string
+|version|
+Do OS version checks on the packet.|
+|name|
+Name of the OS signature to match. All signatures can be found at pf.os file.
+Use "unknown" for OS signatures that the expression could not detect.|
+string
+|==================
+
+.Available ttl values
+---------------------
+If no TTL attribute is passed, make a true IP header and fingerprint TTL true comparison. This generally works for LANs.
+
+* loose: Check if the IP header's TTL is less than the fingerprint one. Works for globally-routable addresses.
+* skip: Do not compare the TTL at all.
+---------------------
+
+.Using osf expression
+---------------------
+# Accept packets that match the "Linux" OS genre signature without comparing TTL.
+table inet x {
+ chain y {
+ type filter hook input priority filter; policy accept;
+ osf ttl skip name "Linux"
+ }
+}
+-----------------------
+
+FIB EXPRESSIONS
+~~~~~~~~~~~~~~~
+[verse]
+*fib* {*saddr* | *daddr* | *mark* | *iif* | *oif*} [*.* ...] {*oif* | *oifname* | *type*}
+
+A fib expression queries the fib (forwarding information base) to obtain
+information such as the output interface index a particular address would use.
+The input is a tuple of elements that is used as input to the fib lookup
+functions.
+
+.fib expression specific types
+[options="header"]
+|==================
+|Keyword| Description| Type
+|oif|
+Output interface index|
+integer (32 bit)
+|oifname|
+Output interface name|
+string
+|type|
+Address type |
+fib_addrtype
+|=======================
+
+Use *nft* *describe* *fib_addrtype* to get a list of all address types.
+
+.Using fib expressions
+----------------------
+# drop packets without a reverse path
+filter prerouting fib saddr . iif oif missing drop
+
+In this example, 'saddr . iif' looks up routing information based on the source address and the input interface.
+oif picks the output interface index from the routing information.
+If no route was found for the source address/input interface combination, the output interface index is zero.
+In case the input interface is specified as part of the input key, the output interface index is always the same as the input interface index or zero.
+If only 'saddr oif' is given, then oif can be any interface index or zero.
+
+# drop packets to address not configured on incoming interface
+filter prerouting fib daddr . iif type != { local, broadcast, multicast } drop
+
+# perform lookup in a specific 'blackhole' table (0xdead, needs ip appropriate ip rule)
+filter prerouting meta mark set 0xdead fib daddr . mark type vmap { blackhole : drop, prohibit : jump prohibited, unreachable : drop }
+----------------------
+
+ROUTING EXPRESSIONS
+~~~~~~~~~~~~~~~~~~~
+[verse]
+*rt* [*ip* | *ip6*] {*classid* | *nexthop* | *mtu* | *ipsec*}
+
+A routing expression refers to routing data associated with a packet.
+
+.Routing expression types
+[options="header"]
+|=======================
+|Keyword| Description| Type
+|classid|
+Routing realm|
+realm
+|nexthop|
+Routing nexthop|
+ipv4_addr/ipv6_addr
+|mtu|
+TCP maximum segment size of route |
+integer (16 bit)
+|ipsec|
+route via ipsec tunnel or transport |
+boolean
+|=================================
+
+.Routing expression specific types
+[options="header"]
+|=======================
+|Type| Description
+|realm|
+Routing Realm (32 bit number). Can be specified numerically or as symbolic name defined in /etc/iproute2/rt_realms.
+|========================
+
+.Using routing expressions
+--------------------------
+# IP family independent rt expression
+filter output rt classid 10
+
+# IP family dependent rt expressions
+ip filter output rt nexthop 192.168.0.1
+ip6 filter output rt nexthop fd00::1
+inet filter output rt ip nexthop 192.168.0.1
+inet filter output rt ip6 nexthop fd00::1
+
+# outgoing packet will be encapsulated/encrypted by ipsec
+filter output rt ipsec exists
+--------------------------
+
+IPSEC EXPRESSIONS
+~~~~~~~~~~~~~~~~~
+
+[verse]
+*ipsec* {*in* | *out*} [ *spnum* 'NUM' ] {*reqid* | *spi*}
+*ipsec* {*in* | *out*} [ *spnum* 'NUM' ] {*ip* | *ip6*} {*saddr* | *daddr*}
+
+An ipsec expression refers to ipsec data associated with a packet.
+
+The 'in' or 'out' keyword needs to be used to specify if the expression should
+examine inbound or outbound policies. The 'in' keyword can be used in the
+prerouting, input and forward hooks. The 'out' keyword applies to forward,
+output and postrouting hooks.
+The optional keyword spnum can be used to match a specific state in a chain,
+it defaults to 0.
+
+.Ipsec expression types
+[options="header"]
+|=======================
+|Keyword| Description| Type
+|reqid|
+Request ID|
+integer (32 bit)
+|spi|
+Security Parameter Index|
+integer (32 bit)
+|saddr|
+Source address of the tunnel|
+ipv4_addr/ipv6_addr
+|daddr|
+Destination address of the tunnel|
+ipv4_addr/ipv6_addr
+|=================================
+
+*Note:* When using xfrm_interface, this expression is not useable in output
+hook as the plain packet does not traverse it with IPsec info attached - use a
+chain in postrouting hook instead.
+
+NUMGEN EXPRESSION
+~~~~~~~~~~~~~~~~~
+
+[verse]
+*numgen* {*inc* | *random*} *mod* 'NUM' [ *offset* 'NUM' ]
+
+Create a number generator. The *inc* or *random* keywords control its
+operation mode: In *inc* mode, the last returned value is simply incremented.
+In *random* mode, a new random number is returned. The value after *mod*
+keyword specifies an upper boundary (read: modulus) which is not reached by
+returned numbers. The optional *offset* allows one to increment the returned value
+by a fixed offset.
+
+A typical use-case for *numgen* is load-balancing:
+
+.Using numgen expression
+------------------------
+# round-robin between 192.168.10.100 and 192.168.20.200:
+add rule nat prerouting dnat to numgen inc mod 2 map \
+ { 0 : 192.168.10.100, 1 : 192.168.20.200 }
+
+# probability-based with odd bias using intervals:
+add rule nat prerouting dnat to numgen random mod 10 map \
+ { 0-2 : 192.168.10.100, 3-9 : 192.168.20.200 }
+------------------------
+
+HASH EXPRESSIONS
+~~~~~~~~~~~~~~~~
+
+[verse]
+*jhash* {*ip saddr* | *ip6 daddr* | *tcp dport* | *udp sport* | *ether saddr*} [*.* ...] *mod* 'NUM' [ *seed* 'NUM' ] [ *offset* 'NUM' ]
+*symhash* *mod* 'NUM' [ *offset* 'NUM' ]
+
+Use a hashing function to generate a number. The functions available are
+*jhash*, known as Jenkins Hash, and *symhash*, for Symmetric Hash. The
+*jhash* requires an expression to determine the parameters of the packet
+header to apply the hashing, concatenations are possible as well. The value
+after *mod* keyword specifies an upper boundary (read: modulus) which is
+not reached by returned numbers. The optional *seed* is used to specify an
+init value used as seed in the hashing function. The optional *offset*
+allows one to increment the returned value by a fixed offset.
+
+A typical use-case for *jhash* and *symhash* is load-balancing:
+
+.Using hash expressions
+------------------------
+# load balance based on source ip between 2 ip addresses:
+add rule nat prerouting dnat to jhash ip saddr mod 2 map \
+ { 0 : 192.168.10.100, 1 : 192.168.20.200 }
+
+# symmetric load balancing between 2 ip addresses:
+add rule nat prerouting dnat to symhash mod 2 map \
+ { 0 : 192.168.10.100, 1 : 192.168.20.200 }
+------------------------
diff --git a/doc/stateful-objects.txt b/doc/stateful-objects.txt
new file mode 100644
index 0000000..00d3c5f
--- /dev/null
+++ b/doc/stateful-objects.txt
@@ -0,0 +1,243 @@
+CT HELPER
+~~~~~~~~~
+[verse]
+*add* *ct helper* ['family'] 'table' 'name' *{ type* 'type' *protocol* 'protocol' *;* [*l3proto* 'family' *;*] *}*
+*delete* *ct helper* ['family'] 'table' 'name'
+*list* *ct helpers*
+
+Ct helper is used to define connection tracking helpers that can then be used in
+combination with the *ct helper set* statement. 'type' and 'protocol' are
+mandatory, l3proto is derived from the table family by default, i.e. in the inet
+table the kernel will try to load both the ipv4 and ipv6 helper backends, if
+they are supported by the kernel.
+
+.conntrack helper specifications
+[options="header"]
+|=================
+|Keyword | Description | Type
+| type |
+name of helper type |
+quoted string (e.g. "ftp")
+|protocol |
+layer 4 protocol of the helper |
+string (e.g. ip)
+|l3proto |
+layer 3 protocol of the helper |
+address family (e.g. ip)
+|comment |
+per ct helper comment field |
+string
+|=================
+
+.defining and assigning ftp helper
+----------------------------------
+Unlike iptables, helper assignment needs to be performed after the conntrack
+lookup has completed, for example with the default 0 hook priority.
+
+table inet myhelpers {
+ ct helper ftp-standard {
+ type "ftp" protocol tcp
+ }
+ chain prerouting {
+ type filter hook prerouting priority filter;
+ tcp dport 21 ct helper set "ftp-standard"
+ }
+}
+----------------------------------
+
+CT TIMEOUT
+~~~~~~~~~~
+[verse]
+*add* *ct timeout* ['family'] 'table' 'name' *{ protocol* 'protocol' *; policy = {* 'state'*:* 'value' [*,* ...] *} ;* [*l3proto* 'family' *;*] *}*
+*delete* *ct timeout* ['family'] 'table' 'name'
+*list* *ct timeouts*
+
+Ct timeout is used to update connection tracking timeout values.Timeout policies are assigned
+with the *ct timeout set* statement. 'protocol' and 'policy' are
+ mandatory, l3proto is derived from the table family by default.
+
+.conntrack timeout specifications
+[options="header"]
+|=================
+|Keyword | Description | Type
+| protocol |
+layer 4 protocol of the timeout object |
+string (e.g. ip)
+|state |
+connection state name |
+string (e.g. "established")
+|value |
+timeout value for connection state |
+unsigned integer
+|l3proto |
+layer 3 protocol of the timeout object |
+address family (e.g. ip)
+|comment |
+per ct timeout comment field |
+string
+|=================
+
+tcp connection state names that can have a specific timeout value are:
+
+'close', 'close_wait', 'established', 'fin_wait', 'last_ack', 'retrans', 'syn_recv', 'syn_sent', 'time_wait' and 'unack'.
+
+You can use 'sysctl -a |grep net.netfilter.nf_conntrack_tcp_timeout_' to view and change the system-wide defaults.
+'ct timeout' allows for flow-specific settings, without changing the global timeouts.
+
+For example, tcp port 53 could have much lower settings than other traffic.
+
+udp state names that can have a specific timeout value are 'replied' and 'unreplied'.
+
+.defining and assigning ct timeout policy
+----------------------------------
+table ip filter {
+ ct timeout customtimeout {
+ protocol tcp;
+ l3proto ip
+ policy = { established: 2m, close: 20s }
+ }
+
+ chain output {
+ type filter hook output priority filter; policy accept;
+ ct timeout set "customtimeout"
+ }
+}
+----------------------------------
+
+.testing the updated timeout policy
+----------------------------------
+
+% conntrack -E
+
+It should display:
+
+[UPDATE] tcp 6 120 ESTABLISHED src=172.16.19.128 dst=172.16.19.1
+sport=22 dport=41360 [UNREPLIED] src=172.16.19.1 dst=172.16.19.128
+sport=41360 dport=22
+----------------------------------
+
+CT EXPECTATION
+~~~~~~~~~~~~~~
+[verse]
+*add* *ct expectation* ['family'] 'table' 'name' *{ protocol* 'protocol' *; dport* 'dport' *; timeout* 'timeout' *; size* 'size' *; [*l3proto* 'family' *;*] *}*
+*delete* *ct expectation* ['family'] 'table' 'name'
+*list* *ct expectations*
+
+Ct expectation is used to create connection expectations. Expectations are
+assigned with the *ct expectation set* statement. 'protocol', 'dport',
+'timeout' and 'size' are mandatory, l3proto is derived from the table family
+by default.
+
+.conntrack expectation specifications
+[options="header"]
+|=================
+|Keyword | Description | Type
+|protocol |
+layer 4 protocol of the expectation object |
+string (e.g. ip)
+|dport |
+destination port of expected connection |
+unsigned integer
+|timeout |
+timeout value for expectation |
+unsigned integer
+|size |
+size value for expectation |
+unsigned integer
+|l3proto |
+layer 3 protocol of the expectation object |
+address family (e.g. ip)
+|comment |
+per ct expectation comment field |
+string
+|=================
+
+.defining and assigning ct expectation policy
+---------------------------------------------
+table ip filter {
+ ct expectation expect {
+ protocol udp
+ dport 9876
+ timeout 2m
+ size 8
+ l3proto ip
+ }
+
+ chain input {
+ type filter hook input priority filter; policy accept;
+ ct expectation set "expect"
+ }
+}
+----------------------------------
+
+COUNTER
+~~~~~~~
+[verse]
+*add* *counter* ['family'] 'table' 'name' [*{* [ *packets* 'packets' *bytes* 'bytes' ';' ] [ *comment* 'comment' ';' *}*]
+*delete* *counter* ['family'] 'table' 'name'
+*list* *counters*
+
+.Counter specifications
+[options="header"]
+|=================
+|Keyword | Description | Type
+|packets |
+initial count of packets |
+unsigned integer (64 bit)
+|bytes |
+initial count of bytes |
+unsigned integer (64 bit)
+|comment |
+per counter comment field |
+string
+|=================
+
+.*Using named counters*
+------------------
+nft add counter filter http
+nft add rule filter input tcp dport 80 counter name \"http\"
+------------------
+
+.*Using named counters with maps*
+------------------
+nft add counter filter http
+nft add counter filter https
+nft add rule filter input counter name tcp dport map { 80 : \"http\", 443 : \"https\" }
+------------------
+
+QUOTA
+~~~~~
+[verse]
+*add* *quota* ['family'] 'table' 'name' *{* [*over*|*until*] 'bytes' 'BYTE_UNIT' [ *used* 'bytes' 'BYTE_UNIT' ] ';' [ *comment* 'comment' ';' ] *}*
+BYTE_UNIT := bytes | kbytes | mbytes
+*delete* *quota* ['family'] 'table' 'name'
+*list* *quotas*
+
+.Quota specifications
+[options="header"]
+|=================
+|Keyword | Description | Type
+|quota |
+quota limit, used as the quota name |
+Two arguments, unsigned integer (64 bit) and string: bytes, kbytes, mbytes.
+"over" and "until" go before these arguments
+|used |
+initial value of used quota |
+Two arguments, unsigned integer (64 bit) and string: bytes, kbytes, mbytes
+|comment |
+per quota comment field |
+string
+|=================
+
+.*Using named quotas*
+------------------
+nft add quota filter user123 { over 20 mbytes }
+nft add rule filter input ip saddr 192.168.10.123 quota name \"user123\"
+------------------
+
+.*Using named quotas with maps*
+------------------
+nft add quota filter user123 { over 20 mbytes }
+nft add quota filter user124 { over 20 mbytes }
+nft add rule filter input quota name ip saddr map { 192.168.10.123 : \"user123\", 192.168.10.124 : \"user124\" }
+------------------
diff --git a/doc/statements.txt b/doc/statements.txt
new file mode 100644
index 0000000..1967280
--- /dev/null
+++ b/doc/statements.txt
@@ -0,0 +1,875 @@
+VERDICT STATEMENT
+~~~~~~~~~~~~~~~~~
+The verdict statement alters control flow in the ruleset and issues policy decisions for packets.
+
+[verse]
+{*accept* | *drop* | *queue* | *continue* | *return*}
+{*jump* | *goto*} 'chain'
+
+*accept* and *drop* are absolute verdicts -- they terminate ruleset evaluation immediately.
+
+[horizontal]
+*accept*:: Terminate ruleset evaluation and accept the packet.
+The packet can still be dropped later by another hook, for instance accept
+in the forward hook still allows one to drop the packet later in the postrouting hook,
+or another forward base chain that has a higher priority number and is evaluated
+afterwards in the processing pipeline.
+*drop*:: Terminate ruleset evaluation and drop the packet.
+The drop occurs instantly, no further chains or hooks are evaluated.
+It is not possible to accept the packet in a later chain again, as those
+are not evaluated anymore for the packet.
+*queue*:: Terminate ruleset evaluation and queue the packet to userspace.
+Userspace must provide a drop or accept verdict. In case of accept, processing
+resumes with the next base chain hook, not the rule following the queue verdict.
+*continue*:: Continue ruleset evaluation with the next rule. This
+ is the default behaviour in case a rule issues no verdict.
+*return*:: Return from the current chain and continue evaluation at the
+ next rule in the last chain. If issued in a base chain, it is equivalent to the
+ base chain policy.
+*jump* 'chain':: Continue evaluation at the first rule in 'chain'. The current
+ position in the ruleset is pushed to a call stack and evaluation will continue
+ there when the new chain is entirely evaluated or a *return* verdict is issued.
+ In case an absolute verdict is issued by a rule in the chain, ruleset evaluation
+ terminates immediately and the specific action is taken.
+*goto* 'chain':: Similar to *jump*, but the current position is not pushed to the
+ call stack, meaning that after the new chain evaluation will continue at the last
+ chain instead of the one containing the goto statement.
+
+.Using verdict statements
+-------------------
+# process packets from eth0 and the internal network in from_lan
+# chain, drop all packets from eth0 with different source addresses.
+
+filter input iif eth0 ip saddr 192.168.0.0/24 jump from_lan
+filter input iif eth0 drop
+-------------------
+
+PAYLOAD STATEMENT
+~~~~~~~~~~~~~~~~~
+[verse]
+'payload_expression' *set* 'value'
+
+The payload statement alters packet content. It can be used for example to
+set ip DSCP (diffserv) header field or ipv6 flow labels.
+
+.route some packets instead of bridging
+---------------------------------------
+# redirect tcp:http from 192.160.0.0/16 to local machine for routing instead of bridging
+# assumes 00:11:22:33:44:55 is local MAC address.
+bridge input meta iif eth0 ip saddr 192.168.0.0/16 tcp dport 80 meta pkttype set unicast ether daddr set 00:11:22:33:44:55
+-------------------------------------------
+
+.Set IPv4 DSCP header field
+---------------------------
+ip forward ip dscp set 42
+---------------------------
+
+EXTENSION HEADER STATEMENT
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+[verse]
+'extension_header_expression' *set* 'value'
+
+The extension header statement alters packet content in variable-sized headers.
+This can currently be used to alter the TCP Maximum segment size of packets,
+similar to the TCPMSS target in iptables.
+
+.change tcp mss
+---------------
+tcp flags syn tcp option maxseg size set 1360
+# set a size based on route information:
+tcp flags syn tcp option maxseg size set rt mtu
+---------------
+
+You can also remove tcp options via reset keyword.
+
+.remove tcp option
+---------------
+tcp flags syn reset tcp option sack-perm
+---------------
+
+LOG STATEMENT
+~~~~~~~~~~~~~
+[verse]
+*log* [*prefix* 'quoted_string'] [*level* 'syslog-level'] [*flags* 'log-flags']
+*log* *group* 'nflog_group' [*prefix* 'quoted_string'] [*queue-threshold* 'value'] [*snaplen* 'size']
+*log level audit*
+
+The log statement enables logging of matching packets. When this statement is
+used from a rule, the Linux kernel will print some information on all matching
+packets, such as header fields, via the kernel log (where it can be read with
+dmesg(1) or read in the syslog).
+
+In the second form of invocation (if 'nflog_group' is specified), the Linux
+kernel will pass the packet to nfnetlink_log which will send the log through a
+netlink socket to the specified group. One userspace process may subscribe to
+the group to receive the logs, see man(8) ulogd for the Netfilter userspace log
+daemon and libnetfilter_log documentation for details in case you would like to
+develop a custom program to digest your logs.
+
+In the third form of invocation (if level audit is specified), the Linux
+kernel writes a message into the audit buffer suitably formatted for reading
+with auditd. Therefore no further formatting options (such as prefix or flags)
+are allowed in this mode.
+
+This is a non-terminating statement, so the rule evaluation continues after
+the packet is logged.
+
+.log statement options
+[options="header"]
+|==================
+|Keyword | Description | Type
+|prefix|
+Log message prefix|
+quoted string
+|level|
+Syslog level of logging |
+string: emerg, alert, crit, err, warn [default], notice, info, debug, audit
+|group|
+NFLOG group to send messages to|
+unsigned integer (16 bit)
+|snaplen|
+Length of packet payload to include in netlink message |
+unsigned integer (32 bit)
+|queue-threshold|
+Number of packets to queue inside the kernel before sending them to userspace |
+unsigned integer (32 bit)
+|==================================
+
+.log-flags
+[options="header"]
+|==================
+| Flag | Description
+|tcp sequence|
+Log TCP sequence numbers.
+|tcp options|
+Log options from the TCP packet header.
+|ip options|
+Log options from the IP/IPv6 packet header.
+|skuid|
+Log the userid of the process which generated the packet.
+|ether|
+Decode MAC addresses and protocol.
+|all|
+Enable all log flags listed above.
+|==============================
+
+.Using log statement
+--------------------
+# log the UID which generated the packet and ip options
+ip filter output log flags skuid flags ip options
+
+# log the tcp sequence numbers and tcp options from the TCP packet
+ip filter output log flags tcp sequence,options
+
+# enable all supported log flags
+ip6 filter output log flags all
+-----------------------
+
+REJECT STATEMENT
+~~~~~~~~~~~~~~~~
+[verse]
+____
+*reject* [ *with* 'REJECT_WITH' ]
+
+'REJECT_WITH' := *icmp* 'icmp_code' |
+ *icmpv6* 'icmpv6_code' |
+ *icmpx* 'icmpx_code' |
+ *tcp reset*
+____
+
+A reject statement is used to send back an error packet in response to the
+matched packet otherwise it is equivalent to drop so it is a terminating
+statement, ending rule traversal. This statement is only valid in base chains
+using the *input*,
+*forward* or *output* hooks, and user-defined chains which are only called from
+those chains.
+
+.different ICMP reject variants are meant for use in different table families
+[options="header"]
+|==================
+|Variant |Family | Type
+|icmp|
+ip|
+icmp_code
+|icmpv6|
+ip6|
+icmpv6_code
+|icmpx|
+inet|
+icmpx_code
+|==================
+
+For a description of the different types and a list of supported keywords refer
+to DATA TYPES section above. The common default reject value is
+*port-unreachable*. +
+
+Note that in bridge family, reject statement is only allowed in base chains
+which hook into input or prerouting.
+
+COUNTER STATEMENT
+~~~~~~~~~~~~~~~~~
+A counter statement sets the hit count of packets along with the number of bytes.
+
+[verse]
+*counter* *packets* 'number' *bytes* 'number'
+*counter* { *packets* 'number' | *bytes* 'number' }
+
+CONNTRACK STATEMENT
+~~~~~~~~~~~~~~~~~~~
+The conntrack statement can be used to set the conntrack mark and conntrack labels.
+
+[verse]
+*ct* {*mark* | *event* | *label* | *zone*} *set* 'value'
+
+The ct statement sets meta data associated with a connection. The zone id
+has to be assigned before a conntrack lookup takes place, i.e. this has to be
+done in prerouting and possibly output (if locally generated packets need to be
+placed in a distinct zone), with a hook priority of *raw* (-300).
+
+Unlike iptables, where the helper assignment happens in the raw table,
+the helper needs to be assigned after a conntrack entry has been
+found, i.e. it will not work when used with hook priorities equal or before
+-200.
+
+.Conntrack statement types
+[options="header"]
+|==================
+|Keyword| Description| Value
+|event|
+conntrack event bits |
+bitmask, integer (32 bit)
+|helper|
+name of ct helper object to assign to the connection |
+quoted string
+|mark|
+Connection tracking mark |
+mark
+|label|
+Connection tracking label|
+label
+|zone|
+conntrack zone|
+integer (16 bit)
+|==================
+
+.save packet nfmark in conntrack
+--------------------------------
+ct mark set meta mark
+--------------------------------
+
+.set zone mapped via interface
+------------------------------
+table inet raw {
+ chain prerouting {
+ type filter hook prerouting priority raw;
+ ct zone set iif map { "eth1" : 1, "veth1" : 2 }
+ }
+ chain output {
+ type filter hook output priority raw;
+ ct zone set oif map { "eth1" : 1, "veth1" : 2 }
+ }
+}
+------------------------------------------------------
+
+.restrict events reported by ctnetlink
+--------------------------------------
+ct event set new,related,destroy
+--------------------------------------
+
+NOTRACK STATEMENT
+~~~~~~~~~~~~~~~~~
+The notrack statement allows one to disable connection tracking for certain
+packets.
+
+[verse]
+*notrack*
+
+Note that for this statement to be effective, it has to be applied to packets
+before a conntrack lookup happens. Therefore, it needs to sit in a chain with
+either prerouting or output hook and a hook priority of -300 (*raw*) or less.
+
+See SYNPROXY STATEMENT for an example usage.
+
+META STATEMENT
+~~~~~~~~~~~~~~
+A meta statement sets the value of a meta expression. The existing meta fields
+are: priority, mark, pkttype, nftrace. +
+
+[verse]
+*meta* {*mark* | *priority* | *pkttype* | *nftrace* | *broute*} *set* 'value'
+
+A meta statement sets meta data associated with a packet. +
+
+.Meta statement types
+[options="header"]
+|==================
+|Keyword| Description| Value
+|priority |
+TC packet priority|
+tc_handle
+|mark|
+Packet mark |
+mark
+|pkttype |
+packet type |
+pkt_type
+|nftrace |
+ruleset packet tracing on/off. Use *monitor trace* command to watch traces|
+0, 1
+|broute |
+broute on/off. packets are routed instead of being bridged|
+0, 1
+|==========================
+
+LIMIT STATEMENT
+~~~~~~~~~~~~~~~
+[verse]
+____
+*limit rate* [*over*] 'packet_number' */* 'TIME_UNIT' [*burst* 'packet_number' *packets*]
+*limit rate* [*over*] 'byte_number' 'BYTE_UNIT' */* 'TIME_UNIT' [*burst* 'byte_number' 'BYTE_UNIT']
+
+'TIME_UNIT' := *second* | *minute* | *hour* | *day*
+'BYTE_UNIT' := *bytes* | *kbytes* | *mbytes*
+____
+
+A limit statement matches at a limited rate using a token bucket filter. A rule
+using this statement will match until this limit is reached. It can be used in
+combination with the log statement to give limited logging. The optional
+*over* keyword makes it match over the specified rate.
+
+The *burst* value influences the bucket size, i.e. jitter tolerance. With
+packet-based *limit*, the bucket holds exactly *burst* packets, by default
+five. If you specify packet *burst*, it must be a non-zero value. With
+byte-based *limit*, the bucket's minimum size is the given rate's byte value
+and the *burst* value adds to that, by default zero bytes.
+
+.limit statement values
+[options="header"]
+|==================
+|Value | Description | Type
+|packet_number |
+Number of packets |
+unsigned integer (32 bit)
+|byte_number |
+Number of bytes |
+unsigned integer (32 bit)
+|========================
+
+NAT STATEMENTS
+~~~~~~~~~~~~~~
+[verse]
+____
+*snat* [[*ip* | *ip6*] [ *prefix* ] *to*] 'ADDR_SPEC' [*:*'PORT_SPEC'] ['FLAGS']
+*dnat* [[*ip* | *ip6*] [ *prefix* ] *to*] 'ADDR_SPEC' [*:*'PORT_SPEC'] ['FLAGS']
+*masquerade* [*to :*'PORT_SPEC'] ['FLAGS']
+*redirect* [*to :*'PORT_SPEC'] ['FLAGS']
+
+'ADDR_SPEC' := 'address' | 'address' *-* 'address'
+'PORT_SPEC' := 'port' | 'port' *-* 'port'
+
+'FLAGS' := 'FLAG' [*,* 'FLAGS']
+'FLAG' := *persistent* | *random* | *fully-random*
+____
+
+The nat statements are only valid from nat chain types. +
+
+The *snat* and *masquerade* statements specify that the source address of the
+packet should be modified. While *snat* is only valid in the postrouting and
+input chains, *masquerade* makes sense only in postrouting. The dnat and
+redirect statements are only valid in the prerouting and output chains, they
+specify that the destination address of the packet should be modified. You can
+use non-base chains which are called from base chains of nat chain type too.
+All future packets in this connection will also be mangled, and rules should
+cease being examined.
+
+The *masquerade* statement is a special form of snat which always uses the
+outgoing interface's IP address to translate to. It is particularly useful on
+gateways with dynamic (public) IP addresses.
+
+The *redirect* statement is a special form of dnat which always translates the
+destination address to the local host's one. It comes in handy if one only wants
+to alter the destination port of incoming traffic on different interfaces.
+
+When used in the inet family (available with kernel 5.2), the dnat and snat
+statements require the use of the ip and ip6 keyword in case an address is
+provided, see the examples below.
+
+Before kernel 4.18 nat statements require both prerouting and postrouting base chains
+to be present since otherwise packets on the return path won't be seen by
+netfilter and therefore no reverse translation will take place.
+
+The optional *prefix* keyword allows to map to map *n* source addresses to *n*
+destination addresses. See 'Advanced NAT examples' below.
+
+.NAT statement values
+[options="header"]
+|==================
+|Expression| Description| Type
+|address|
+Specifies that the source/destination address of the packet should be modified.
+You may specify a mapping to relate a list of tuples composed of arbitrary
+expression key with address value. |
+ipv4_addr, ipv6_addr, e.g. abcd::1234, or you can use a mapping, e.g. meta mark map { 10 : 192.168.1.2, 20 : 192.168.1.3 }
+|port|
+Specifies that the source/destination port of the packet should be modified. |
+port number (16 bit)
+|===============================
+
+.NAT statement flags
+[options="header"]
+|==================
+|Flag| Description
+|persistent |
+Gives a client the same source-/destination-address for each connection.
+|random|
+In kernel 5.0 and newer this is the same as fully-random.
+In earlier kernels the port mapping will be randomized using a seeded MD5
+hash mix using source and destination address and destination port.
+
+|fully-random|
+If used then port mapping is generated based on a 32-bit pseudo-random algorithm.
+|=============================
+
+.Using NAT statements
+---------------------
+# create a suitable table/chain setup for all further examples
+add table nat
+add chain nat prerouting { type nat hook prerouting priority dstnat; }
+add chain nat postrouting { type nat hook postrouting priority srcnat; }
+
+# translate source addresses of all packets leaving via eth0 to address 1.2.3.4
+add rule nat postrouting oif eth0 snat to 1.2.3.4
+
+# redirect all traffic entering via eth0 to destination address 192.168.1.120
+add rule nat prerouting iif eth0 dnat to 192.168.1.120
+
+# translate source addresses of all packets leaving via eth0 to whatever
+# locally generated packets would use as source to reach the same destination
+add rule nat postrouting oif eth0 masquerade
+
+# redirect incoming TCP traffic for port 22 to port 2222
+add rule nat prerouting tcp dport 22 redirect to :2222
+
+# inet family:
+# handle ip dnat:
+add rule inet nat prerouting dnat ip to 10.0.2.99
+# handle ip6 dnat:
+add rule inet nat prerouting dnat ip6 to fe80::dead
+# this masquerades both ipv4 and ipv6:
+add rule inet nat postrouting meta oif ppp0 masquerade
+
+------------------------
+
+.Advanced NAT examples
+----------------------
+
+# map prefixes in one network to that of another, e.g. 10.141.11.4 is mangled to 192.168.2.4,
+# 10.141.11.5 is mangled to 192.168.2.5 and so on.
+add rule nat postrouting snat ip prefix to ip saddr map { 10.141.11.0/24 : 192.168.2.0/24 }
+
+# map a source address, source port combination to a pool of destination addresses and ports:
+add rule nat postrouting dnat to ip saddr . tcp dport map { 192.168.1.2 . 80 : 10.141.10.2-10.141.10.5 . 8888-8999 }
+
+# The above example generates the following NAT expression:
+#
+# [ nat dnat ip addr_min reg 1 addr_max reg 10 proto_min reg 9 proto_max reg 11 ]
+#
+# which expects to obtain the following tuple:
+# IP address (min), source port (min), IP address (max), source port (max)
+# to be obtained from the map. The given addresses and ports are inclusive.
+
+# This also works with named maps and in combination with both concatenations and ranges:
+table ip nat {
+ map ipportmap {
+ typeof ip saddr : interval ip daddr . tcp dport
+ flags interval
+ elements = { 192.168.1.2 : 10.141.10.1-10.141.10.3 . 8888-8999, 192.168.2.0/24 : 10.141.11.5-10.141.11.20 . 8888-8999 }
+ }
+
+ chain prerouting {
+ type nat hook prerouting priority dstnat; policy accept;
+ ip protocol tcp dnat ip to ip saddr map @ipportmap
+ }
+}
+
+@ipportmap maps network prefixes to a range of hosts and ports.
+The new destination is taken from the range provided by the map element.
+Same for the destination port.
+
+Note the use of the "interval" keyword in the typeof description.
+This is required so nftables knows that it has to ask for twice the
+amount of storage for each key-value pair in the map.
+
+": ipv4_addr . inet_service" would allow associating one address and one port
+with each key. But for this case, for each key, two addresses and two ports
+(The minimum and maximum values for both) have to be stored.
+
+------------------------
+
+TPROXY STATEMENT
+~~~~~~~~~~~~~~~~
+Tproxy redirects the packet to a local socket without changing the packet header
+in any way. If any of the arguments is missing the data of the incoming packet
+is used as parameter. Tproxy matching requires another rule that ensures the
+presence of transport protocol header is specified.
+
+[verse]
+*tproxy to* 'address'*:*'port'
+*tproxy to* {'address' | *:*'port'}
+
+This syntax can be used in *ip/ip6* tables where network layer protocol is
+obvious. Either IP address or port can be specified, but at least one of them is
+necessary.
+
+[verse]
+*tproxy* {*ip* | *ip6*} *to* 'address'[*:*'port']
+*tproxy to :*'port'
+
+This syntax can be used in *inet* tables. The *ip/ip6* parameter defines the
+family the rule will match. The *address* parameter must be of this family.
+When only *port* is defined, the address family should not be specified. In
+this case the rule will match for both families.
+
+.tproxy attributes
+[options="header"]
+|=================
+| Name | Description
+| address | IP address the listening socket with IP_TRANSPARENT option is bound to.
+| port | Port the listening socket with IP_TRANSPARENT option is bound to.
+|=================
+
+.Example ruleset for tproxy statement
+-------------------------------------
+table ip x {
+ chain y {
+ type filter hook prerouting priority mangle; policy accept;
+ tcp dport ntp tproxy to 1.1.1.1
+ udp dport ssh tproxy to :2222
+ }
+}
+table ip6 x {
+ chain y {
+ type filter hook prerouting priority mangle; policy accept;
+ tcp dport ntp tproxy to [dead::beef]
+ udp dport ssh tproxy to :2222
+ }
+}
+table inet x {
+ chain y {
+ type filter hook prerouting priority mangle; policy accept;
+ tcp dport 321 tproxy to :ssh
+ tcp dport 99 tproxy ip to 1.1.1.1:999
+ udp dport 155 tproxy ip6 to [dead::beef]:smux
+ }
+}
+-------------------------------------
+
+SYNPROXY STATEMENT
+~~~~~~~~~~~~~~~~~~
+This statement will process TCP three-way-handshake parallel in netfilter
+context to protect either local or backend system. This statement requires
+connection tracking because sequence numbers need to be translated.
+
+[verse]
+*synproxy* [*mss* 'mss_value'] [*wscale* 'wscale_value'] ['SYNPROXY_FLAGS']
+
+.synproxy statement attributes
+[options="header"]
+|=================
+| Name | Description
+| mss | Maximum segment size announced to clients. This must match the backend.
+| wscale | Window scale announced to clients. This must match the backend.
+|=================
+
+.synproxy statement flags
+[options="header"]
+|=================
+| Flag | Description
+| sack-perm |
+Pass client selective acknowledgement option to backend (will be disabled if
+not present).
+| timestamp |
+Pass client timestamp option to backend (will be disabled if not present, also
+needed for selective acknowledgement and window scaling).
+|=================
+
+.Example ruleset for synproxy statement
+---------------------------------------
+Determine tcp options used by backend, from an external system
+
+ tcpdump -pni eth0 -c 1 'tcp[tcpflags] == (tcp-syn|tcp-ack)'
+ port 80 &
+ telnet 192.0.2.42 80
+ 18:57:24.693307 IP 192.0.2.42.80 > 192.0.2.43.48757:
+ Flags [S.], seq 360414582, ack 788841994, win 14480,
+ options [mss 1460,sackOK,
+ TS val 1409056151 ecr 9690221,
+ nop,wscale 9],
+ length 0
+
+Switch tcp_loose mode off, so conntrack will mark out-of-flow packets as state INVALID.
+
+ echo 0 > /proc/sys/net/netfilter/nf_conntrack_tcp_loose
+
+Make SYN packets untracked.
+
+ table ip x {
+ chain y {
+ type filter hook prerouting priority raw; policy accept;
+ tcp flags syn notrack
+ }
+ }
+
+Catch UNTRACKED (SYN packets) and INVALID (3WHS ACK packets) states and send
+them to SYNPROXY. This rule will respond to SYN packets with SYN+ACK
+syncookies, create ESTABLISHED for valid client response (3WHS ACK packets) and
+drop incorrect cookies. Flags combinations not expected during 3WHS will not
+match and continue (e.g. SYN+FIN, SYN+ACK). Finally, drop invalid packets, this
+will be out-of-flow packets that were not matched by SYNPROXY.
+
+ table ip x {
+ chain z {
+ type filter hook input priority filter; policy accept;
+ ct state invalid, untracked synproxy mss 1460 wscale 9 timestamp sack-perm
+ ct state invalid drop
+ }
+ }
+---------------------------------------
+
+FLOW STATEMENT
+~~~~~~~~~~~~~~
+A flow statement allows us to select what flows you want to accelerate
+forwarding through layer 3 network stack bypass. You have to specify the
+flowtable name where you want to offload this flow.
+
+*flow add @*'flowtable'
+
+QUEUE STATEMENT
+~~~~~~~~~~~~~~~
+This statement passes the packet to userspace using the nfnetlink_queue handler.
+The packet is put into the queue identified by its 16-bit queue number.
+Userspace can inspect and modify the packet if desired. Userspace must then drop
+or re-inject the packet into the kernel. See libnetfilter_queue documentation
+for details.
+
+[verse]
+____
+*queue* [*flags* 'QUEUE_FLAGS'] [*to* 'queue_number']
+*queue* [*flags* 'QUEUE_FLAGS'] [*to* 'queue_number_from' - 'queue_number_to']
+*queue* [*flags* 'QUEUE_FLAGS'] [*to* 'QUEUE_EXPRESSION' ]
+
+'QUEUE_FLAGS' := 'QUEUE_FLAG' [*,* 'QUEUE_FLAGS']
+'QUEUE_FLAG' := *bypass* | *fanout*
+'QUEUE_EXPRESSION' := *numgen* | *hash* | *symhash* | *MAP STATEMENT*
+____
+
+QUEUE_EXPRESSION can be used to compute a queue number
+at run-time with the hash or numgen expressions. It also
+allows one to use the map statement to assign fixed queue numbers
+based on external inputs such as the source ip address or interface names.
+
+.queue statement values
+[options="header"]
+|==================
+|Value | Description | Type
+|queue_number |
+Sets queue number, default is 0. |
+unsigned integer (16 bit)
+|queue_number_from |
+Sets initial queue in the range, if fanout is used. |
+unsigned integer (16 bit)
+|queue_number_to |
+Sets closing queue in the range, if fanout is used. |
+unsigned integer (16 bit)
+|=====================
+
+.queue statement flags
+[options="header"]
+|==================
+|Flag | Description
+|bypass |
+Let packets go through if userspace application cannot back off. Before using
+this flag, read libnetfilter_queue documentation for performance tuning recommendations.
+|fanout |
+Distribute packets between several queues.
+|===============================
+
+DUP STATEMENT
+~~~~~~~~~~~~~
+The dup statement is used to duplicate a packet and send the copy to a different
+destination.
+
+[verse]
+*dup to* 'device'
+*dup to* 'address' *device* 'device'
+
+.Dup statement values
+[options="header"]
+|==================
+|Expression | Description | Type
+|address |
+Specifies that the copy of the packet should be sent to a new gateway.|
+ipv4_addr, ipv6_addr, e.g. abcd::1234, or you can use a mapping, e.g. ip saddr map { 192.168.1.2 : 10.1.1.1 }
+|device |
+Specifies that the copy should be transmitted via device. |
+string
+|===================
+
+
+.Using the dup statement
+------------------------
+# send to machine with ip address 10.2.3.4 on eth0
+ip filter forward dup to 10.2.3.4 device "eth0"
+
+# copy raw frame to another interface
+netdev ingress dup to "eth0"
+dup to "eth0"
+
+# combine with map dst addr to gateways
+dup to ip daddr map { 192.168.7.1 : "eth0", 192.168.7.2 : "eth1" }
+-----------------------------------
+
+FWD STATEMENT
+~~~~~~~~~~~~~
+The fwd statement is used to redirect a raw packet to another interface. It is
+only available in the netdev family ingress and egress hooks. It is similar to
+the dup statement except that no copy is made.
+
+You can also specify the address of the next hop and the device to forward the
+packet to. This updates the source and destination MAC address of the packet by
+transmitting it through the neighboring layer. This also decrements the ttl
+field of the IP packet. This provides a way to effectively bypass the classical
+forwarding path, thus skipping the fib (forwarding information base) lookup.
+
+[verse]
+*fwd to* 'device'
+*fwd* [*ip* | *ip6*] *to* 'address' *device* 'device'
+
+.Using the fwd statement
+------------------------
+# redirect raw packet to device
+netdev ingress fwd to "eth0"
+
+# forward packet to next hop 192.168.200.1 via eth0 device
+netdev ingress ether saddr set fwd ip to 192.168.200.1 device "eth0"
+-----------------------------------
+
+SET STATEMENT
+~~~~~~~~~~~~~
+The set statement is used to dynamically add or update elements in a set from
+the packet path. The set setname must already exist in the given table and must
+have been created with one or both of the dynamic and the timeout flags. The
+dynamic flag is required if the set statement expression includes a stateful
+object. The timeout flag is implied if the set is created with a timeout, and is
+required if the set statement updates elements, rather than adding them.
+Furthermore, these sets should specify both a maximum set size (to prevent
+memory exhaustion), and their elements should have a timeout (so their number
+will not grow indefinitely) either from the set definition or from the statement
+that adds or updates them. The set statement can be used to e.g. create dynamic
+blacklists.
+
+Dynamic updates are also supported with maps. In this case, the *add* or
+*update* rule needs to provide both the key and the data element (value),
+separated via ':'.
+
+[verse]
+{*add* | *update*} *@*'setname' *{* 'expression' [*timeout* 'timeout'] [*comment* 'string'] *}*
+
+.Example for simple blacklist
+-----------------------------
+# declare a set, bound to table "filter", in family "ip".
+# Timeout and size are mandatory because we will add elements from packet path.
+# Entries will timeout after one minute, after which they might be
+# re-added if limit condition persists.
+nft add set ip filter blackhole \
+ "{ type ipv4_addr; flags dynamic; timeout 1m; size 65536; }"
+
+# declare a set to store the limit per saddr.
+# This must be separate from blackhole since the timeout is different
+nft add set ip filter flood \
+ "{ type ipv4_addr; flags dynamic; timeout 10s; size 128000; }"
+
+# whitelist internal interface.
+nft add rule ip filter input meta iifname "internal" accept
+
+# drop packets coming from blacklisted ip addresses.
+nft add rule ip filter input ip saddr @blackhole counter drop
+
+# add source ip addresses to the blacklist if more than 10 tcp connection
+# requests occurred per second and ip address.
+nft add rule ip filter input tcp flags syn tcp dport ssh \
+ add @flood { ip saddr limit rate over 10/second } \
+ add @blackhole { ip saddr } \
+ drop
+
+# inspect state of the sets.
+nft list set ip filter flood
+nft list set ip filter blackhole
+
+# manually add two addresses to the blackhole.
+nft add element filter blackhole { 10.2.3.4, 10.23.1.42 }
+-----------------------------------------------
+
+MAP STATEMENT
+~~~~~~~~~~~~~
+The map statement is used to lookup data based on some specific input key.
+
+[verse]
+____
+'expression' *map* *{* 'MAP_ELEMENTS' *}*
+
+'MAP_ELEMENTS' := 'MAP_ELEMENT' [*,* 'MAP_ELEMENTS']
+'MAP_ELEMENT' := 'key' *:* 'value'
+____
+
+The 'key' is a value returned by 'expression'.
+// XXX: Write about where map statement can be used (list of statements?)
+
+.Using the map statement
+------------------------
+# select DNAT target based on TCP dport:
+# connections to port 80 are redirected to 192.168.1.100,
+# connections to port 8888 are redirected to 192.168.1.101
+nft add rule ip nat prerouting dnat tcp dport map { 80 : 192.168.1.100, 8888 : 192.168.1.101 }
+
+# source address based SNAT:
+# packets from net 192.168.1.0/24 will appear as originating from 10.0.0.1,
+# packets from net 192.168.2.0/24 will appear as originating from 10.0.0.2
+nft add rule ip nat postrouting snat to ip saddr map { 192.168.1.0/24 : 10.0.0.1, 192.168.2.0/24 : 10.0.0.2 }
+------------------------
+
+VMAP STATEMENT
+~~~~~~~~~~~~~~
+The verdict map (vmap) statement works analogous to the map statement, but
+contains verdicts as values.
+
+[verse]
+____
+'expression' *vmap* *{* 'VMAP_ELEMENTS' *}*
+
+'VMAP_ELEMENTS' := 'VMAP_ELEMENT' [*,* 'VMAP_ELEMENTS']
+'VMAP_ELEMENT' := 'key' *:* 'verdict'
+____
+
+.Using the vmap statement
+-------------------------
+# jump to different chains depending on layer 4 protocol type:
+nft add rule ip filter input ip protocol vmap { tcp : jump tcp-chain, udp : jump udp-chain , icmp : jump icmp-chain }
+------------------------
+
+XT STATEMENT
+~~~~~~~~~~~~
+This represents an xt statement from xtables compat interface. It is a
+fallback if translation is not available or not complete.
+
+[verse]
+____
+*xt* 'TYPE' 'NAME'
+
+'TYPE' := *match* | *target* | *watcher*
+____
+
+Seeing this means the ruleset (or parts of it) were created by *iptables-nft*
+and one should use that to manage it.
+
+*BEWARE:* nftables won't restore these statements.