Skip to content

R5 nftables: the hooks, nf_tables, conntrack and NAT #542

Open

Description

@tamnd

Part of #14.

rukernel has no netfilter. There are no hook points in the IPv4 and IPv6 paths, no NETLINK_NETFILTER, no conntrack and no NAT. LTP net nft, nft6, iptables and ip6tables do not apply now ("nf_tables driver not available"). spec/10-networking.md section 10.5 has the scope.

Scope

  • The netfilter hook points in the IPv4 and IPv6 paths: PREROUTING, INPUT, FORWARD, OUTPUT and POSTROUTING, with a list of hooks in priority order for each network namespace, and the verdicts ACCEPT, DROP, STOLEN and QUEUE. A path with no hook does not take a lock. Test: the inet, inet6, netcfg and netns boot tests and LTP net. Exit: no change in the results, and the tcp_stream and udp_stream bench rows stay in the noise.
  • The protocol NETLINK_NETFILTER with the nfnetlink subsystems, and the nf_tables objects: tables, chains, base chains on the hooks, rules and sets. Add the transaction batch (NFNL_MSG_BATCH_BEGIN and NFNL_MSG_BATCH_END) with commit and abort, the generation ID and the dump of the rule set. Test: a new nft boot test that loads a rule set with nft -f and compares nft list ruleset with the input. Exit: the output is the same as on the reference.
  • A test harness for the nftables test suite: tools/nftables/build.sh builds nft and tests/shell of the nftables project, and a report gives the result of each test on rukernel and on the reference. Exit: the report is in tools/nftables.
  • The expression VM: immediate, payload, meta, cmp, bitwise, byteorder, range, lookup, counter, limit, log (to the kernel log), reject and the verdicts. Test: LTP nft and nft6. Exit: both pass.
  • Sets and maps: hash and rbtree sets, intervals, concatenations, timeouts, dynamic sets and verdict maps. Test: the sets and maps parts of the nftables tests/shell. Exit: they reach the pass set of the reference.
  • conntrack: connection tracking for TCP, UDP, ICMP and ICMPv6, the ct expression (state, mark, status), the /proc/sys/net/netfilter/nf_conntrack_* tunables, and ctnetlink for conntrack -L. Test: the ct parts of the nftables tests/shell. Exit: they reach the pass set of the reference.
  • NAT: the nat chains, snat, dnat, masquerade and redirect. Test: the nat parts of the nftables tests/shell, and a new part of the netns boot test that does masquerade between two network namespaces on veth. Exit: they reach the pass set of the reference.
  • iptables-nft: the nft_compat expressions for the xtables matches and targets that iptables-nft uses, for example state, conntrack and REJECT. Test: LTP iptables and ip6tables. Exit: both pass.
  • Run the full nftables tests/shell on both architectures and update the report. Exit: the suite reaches the pass set of the reference, apart from the listed exceptions.

Done when

The nftables test suite reaches the pass set of the reference. This is the exit of the seventh item of #14.

Test each task on x86_64 and on arm64. Give the result of both in the PR body.

Linux reference: net/netfilter/core.c, net/netfilter/nfnetlink.c, net/netfilter/nf_tables_api.c, net/netfilter/nf_tables_core.c, net/netfilter/nf_conntrack_core.c, net/netfilter/nft_compat.c.

Activity

  1. added
    kind/featureNew behavior or a new part.
    area/netNetworking: sockets, TCP, netlink and netfilter.
    on Nov 2, 2026
  2. tamnd commented on Nov 5, 2026

    @tamnd
    OwnerAuthor

    Progress on the nf_tables work, all merged into main:

    Next, in this order. Each one is boot tested before its PR:

    • nft-8: byteorder, range, limit and log.
    • nft-9: reject (ICMP, ICMPv6, icmpx, TCP RST).
    • nft-10: redir.

    Known limitations so far:

    • Incoming fragments get no conntrack.
    • The null binding does not remap ports.
    • Masquerade connections stay when the device loses its address.
    • NETMAP and PROTO_OFFSET give EOPNOTSUPP.
    • Jumps to other chains are only checked when a packet runs through them.
    • log has no MAC=, IP options or UID, and log group gives ENOENT.

    Still open: sets and maps, ctnetlink, masquerade between netns on veth, nft_compat, and the tools/nftables harness.

  3. tamnd commented on Nov 5, 2026

    @tamnd
    OwnerAuthor

    Two more parts of the expression VM item are merged:

    The inet boot test passes on x86_64 and on arm64 on server2 (load average 24.43, 24.41, 24.73).

    Limitations of reject: the RST is not attached to the connection (Linux does this with nf_ct_attach), and the checksum of an incoming packet is not checked before the answer.

    Next, in this order: nft-10 (redir), nft-11 (maps and verdict maps), nft-12 (set timeouts) and nft-13 (dynset).

  4. tamnd commented on Nov 5, 2026

    @tamnd
    OwnerAuthor

    One more part of the NAT item is merged:

    The gate passed. The inet boot test passes on x86_64 and on arm64 on server2 (load average 24.43, 24.41, 24.73).

    The NAT item is not done yet. Its tests need the nftables tests/shell harness and the masquerade part of the netns boot test.

    Next: nft-11 (maps and verdict maps).

  5. tamnd commented on Nov 5, 2026

    @tamnd
    OwnerAuthor

    One more part of the sets and maps item is merged:

    • net: the maps and the verdict maps of nf_tables #617 (nft-11): the maps and the verdict maps of nf_tables. lookup with NFTA_LOOKUP_DREG loads the data of an element into a register. A verdict map gives accept, drop, jump or goto, and its jumps count for the loop check of the chains.

    The gate passed. The inet boot test passes on x86_64 and on arm64 on server2 (load average 24.43, 24.41, 24.73).

    The sets and maps item is not done yet. Its exit needs the nftables tests/shell harness.

    Next: nft-12 (set timeouts).

  6. tamnd commented on Nov 6, 2026

    @tamnd
    OwnerAuthor

    One more part of the sets and maps item is merged:

    • net: the timeouts of the sets of nf_tables #622 (nft-12): the timeouts of the sets of nf_tables. A set with NFT_SET_TIMEOUT takes a timeout for the set and for each element. An element ends after its timeout. A lookup does not find it, and a dump does not show it. The dump gives the timeout and the time that is left (NFTA_SET_ELEM_TIMEOUT, NFTA_SET_ELEM_EXPIRATION).

    The item is not done. Next: nft-13, the dynset expression (dynamic sets).

  7. tamnd commented on Nov 6, 2026

    @tamnd
    OwnerAuthor

    One more part of the sets and maps item is merged:

    • net: the dynset expression of nf_tables #627 (nft-13): the dynset expression of nf_tables. A rule can add the key of a packet to a set, start the timeout of its element again (update), or remove the element (delete). The changes of the packet path go in a list that a lookup, a dump and the next commit see.

    The item is not done: the sets and maps parts of the nftables tests/shell do not run yet. Next: nft-14, masquerade between two network namespaces in the netns boot test.

  8. tamnd commented on Nov 6, 2026

    @tamnd
    OwnerAuthor

    One part of the NAT item is merged:

    The NAT item stays open. The nat parts of the nftables tests/shell do not run yet, because the test harness item is not done.

  9. tamnd commented on Nov 7, 2026

    @tamnd
    OwnerAuthor

    One part of the conntrack item is merged:

    The gate passed. The inet boot test has a new check for ctnetlink, and it passes on x86_64 and on arm64 on server2.

    The conntrack item stays open. Its exit needs the ct parts of the nftables tests/shell. Next: nft-16 (nft_compat).

  10. tamnd commented on Nov 7, 2026

    @tamnd
    OwnerAuthor

    One part of the iptables-nft item is merged:

    The gate passed. The inet boot test passes on x86_64 and on arm64 on server2.

    The iptables-nft item stays open. Its exit needs LTP iptables and ip6tables. Next: nft-17 (the matches tcp, udp, multiport and connmark, and the target LOG).

  11. tamnd commented on Nov 7, 2026

    @tamnd
    OwnerAuthor

    An other part of the iptables-nft item is merged:

    The gate passed. The inet boot test passes on x86_64 and on arm64 on server2.

    The iptables-nft item stays open. Its exit needs LTP iptables and ip6tables. Next: nft-18 (iptables-nft and nft in the tools of the LTP run), then nft-19 (the tests/shell harness), nft-20, nft-21 and nft-22.

  12. tamnd commented on Nov 7, 2026

    @tamnd
    OwnerAuthor

    The test part of the expression VM item and of the iptables-nft item is merged:

    The gate passed. With the stack of #542 up to #639, LTP iptables, nft, ip6tables and nft6 pass on x86_64 on server2.

    The two items stay open. The tools of the LTP run are x86_64 programs, so LTP nft, nft6, iptables and ip6tables did not run on arm64. Next: nft-19 (the tests/shell harness and the report), then nft-20, nft-21 and nft-22.

  13. tamnd commented on Nov 7, 2026

    @tamnd
    OwnerAuthor

    The test harness item is done, and I ticked it:

    • tools/nftables: the test harness of tests/shell of nftables, and the report #644 (nft-19): tools/nftables/build.sh builds nft 1.0.9 and tests/shell of nftables 1.0.9 in an Alpine root file system for x86_64 and arm64, run.py runs the 380 tests under QEMU on rukernel or on a Linux reference kernel, and report.py makes tools/nftables/report.md. The first report: Linux 371 of 380, rukernel x86_64 215 of 380, rukernel arm64 31 of the 44 tests of testcases/chains.

    The gate passed. Next: nft-20 (the names of the sets in the dump), nft-21 (the meta keys and the bitwise shifts), nft-22 (the check of the chains at commit) and nft-23 (the report after them: 277 of 380 on x86_64).

  14. tamnd commented on Nov 7, 2026

    @tamnd
    OwnerAuthor

    #645 (nft-20) is merged: the dump of a rule gives the name of the set of each lookup and dynset expression, as the dump of nft_lookup.c and nft_dynset.c of Linux. Before, it gave the name with %d or the ID of the set that the batch gave, and nft list did not find the anonymous sets.

    The gate passed. No item is complete with this change. Next: nft-21 (the meta keys and the bitwise shifts), nft-22 (the check of the chains at commit), nft-23 (the report after them) and nft-24 (the stateful objects counter, quota and limit, and objref).

  15. tamnd commented on Nov 7, 2026

    @tamnd
    OwnerAuthor

    #647 (nft-21) is merged: the meta keys mark, iifname, oifname, iiftype and oiftype, meta mark set, and the bitwise shifts lshift and rshift. The 10 bitwise tests of tests/shell pass on rukernel x86_64 and arm64.

    The gate passed. The expression VM item stays open, because it also needs the arm64 LTP run. Next: nft-22 (the check of the chains at commit), nft-23 (the report after nft-20 to nft-22) and nft-24 (the stateful objects).

  16. tamnd commented on Nov 7, 2026

    @tamnd
    OwnerAuthor

    #649 (nft-22) is merged: the commit of an nf_tables batch checks the chains that each base chain reaches with its jumps, gotos and verdict maps, as nft_table_validate and nft_chain_validate of Linux. A masquerade, snat, dnat, redirect or reject in a chain that a base chain of an other type or hook reaches gives EOPNOTSUPP, and a chain at the depth 16 gives EMLINK. chains/0002jumps_1, the 5 masquerade_jump tests, chains/0020depth_1 and transactions/bad_expression of tests/shell now pass on rukernel x86_64 and arm64.

    The gate passed. The NAT item stays open (snat to a range of addresses and ports). Next: nft-23 (the report after nft-20 to nft-22) and nft-24 (the stateful objects).

  17. tamnd commented on Nov 7, 2026

    @tamnd
    OwnerAuthor

    #650 (nft-23) is merged: tools/nftables/report.md after nft-20, nft-21 and nft-22. 277 of 380 tests of tests/shell pass on rukernel x86_64, and 215 in the first report.

    The gate passed. The last item stays open for the full arm64 run. Next: nft-24 (the stateful objects counter, quota and limit, the quota and objref expressions and the maps of objects).

  18. tamnd commented on Nov 7, 2026

    @tamnd
    OwnerAuthor

    #651 (nft-24) is merged: the stateful objects of nf_tables (counter, quota and limit), with NFT_MSG_NEWOBJ, GETOBJ, GETOBJ_RESET, DELOBJ and DESTROYOBJ, the quota expression, the objref expression with a name or a map of objects, and the elements with NFTA_SET_ELEM_OBJREF.

    • With it, 9 tests of tests/shell pass on rukernel x86_64 and arm64: json/0006obj_comment_0, listing/0017objects_0, maps/0016map_leak_0, maps/0018map_leak_timeout_0, maps/vmap_mark_bitwise_0, optionals/delete_object_handles_0, optionals/update_object_handles_0, sets/0026named_limit_0 and transactions/0042_stateful_expr_0.
    • The full run on rukernel x86_64 gives 288 of 380 (277 in the report of nft-23). No test that passed before fails now.
    • The object types ct helper, ct expectation, ct timeout, synproxy and secmark and the expressions of a set (NFTA_SET_EXPR) are not done, so listing/0013 and 0014objects_0, optionals/comments_objects_0, sets/0024named_objects_0, sets/0048set_counters_0 and sets/0051set_interval_counter_0 still fail.

    The gate passed. No item is complete with this change. The sets and maps item and the last item stay open.

  19. tamnd commented on Nov 12, 2026

    @tamnd
    OwnerAuthor

    #697 is merged. It adds the flowtables of nf_tables, as nf_tables_api.c and nft_flow_offload.c of Linux.

    Result on x86_64 in the dirs flowtable, listing, owner and cache: 45 of 50 tests pass. Before #697, 29 passed. The arm64 boot test inet passes. The x86_64 boot test inet passes.

    No item is ticked. The items of nf_tables objects and the expression VM have more work: the sets, the maps and the other dirs of the report.

  20. tamnd commented on Nov 12, 2026

    @tamnd
    OwnerAuthor

    #702 (nft-26) is merged. It adds the stateful expressions of sets and elements (NFTA_SET_EXPR and NFTA_SET_ELEM_EXPRESSIONS), and the connlimit expression and object.

    Results of tests/shell (the kernel had this PR and the next one, nft-27):

    • x86_64: sets 78 of 93 pass (61 in the report), transactions 37 of 41 (34 in the report), and json, maps, nft-f, optimizations and transactions together 105 of 129 (96 in the report).
    • arm64: the same dirs, with the same failures apart from hangs under load on server2 (load 8 to 11).
    • The inet boot test passes on x86_64 and arm64.

    No item is ticked. The sets and maps item is still open: payload set, numgen, meta keys, the ct objects and snat netmap are not done yet.

  21. tamnd commented on Nov 12, 2026

    @tamnd
    OwnerAuthor

    #707 (nft-27) is merged. The sets of nf_tables with ranges now work as nft_set_rbtree.c and nft_set_pipapo.c of Linux: get of a range, overlaps, concatenated ranges, adjacent ranges and the dump order of nft_pipapo_walk.

    Result on x86_64 (server1): sets 81 of 93 pass (78 before) and maps 25 of 31. sets/0034get_element_0, 0044interval_overlap_0, 0047nat_0, 0067nat_concat_interval_0, maps/typeof_integer_0 and optimizations/merge_vmap_raw now pass. The inet boot tests pass on x86_64 and arm64.

    The item "Sets and maps" stays open: sets/0046netmap_0, typeof_sets_0, sets_with_ifnames, 0028autoselect_0, 0055tcpflags_0, dynset_missing, 0024named_objects_0, maps/anon_objmap_concat, typeof_maps_0 and typeof_maps_add_delete still fail. sets/0043concatenated_ranges_0 fails on Linux too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/netNetworking: sockets, TCP, netlink and netfilter.kind/featureNew behavior or a new part.

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions