Skip to content

nf_tables: intervals, as nft_set_rbtree.c and nft_set_pipapo.c of Linux: get, overlaps and concatenated ranges - #707

Merged
tamnd merged 1 commit into
mainfrom
nft-27
Nov 12, 2026
Merged

tamnd merged 1 commit into
mainfrom
nft-27

Conversation

@tamnd

@tamnd tamnd commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Part of #542.

This PR changes the sets of nf_tables with NFT_SET_INTERVAL so that they work as nft_set_rbtree.c and nft_set_pipapo.c of Linux. It is for the "sets and maps" group of tools/nftables/report.md.

  • NFT_MSG_GETSETELEM in a set with ranges gives the range that has the key.
  • A range of a set with a key of more than one field matches a key that is in the range in each field.
  • A new element that overlaps a range of the set gives EEXIST, as nft_rbtree_insert and nft_pipapo_insert. A set with a key of more than one field looks at the first element in the order of the inserts that has the first key, as pipapo_get. Thus a range that a set already has can be added again when a later range also has its first key.
  • At the same key, the end of a range comes before the start of the next range, as nft_rbtree_cmp. Before this change, a range that started where the range before it ended did not match.
  • The dump of a set with a key of more than one field gives the elements in the order of their inserts, as nft_pipapo_walk.

Tests

The tests/shell dirs that the change touches: sets and maps, 124 tests. The kernel of these runs had this PR and the next one (nft-28: numgen, hash and meta keys). nft-28 does not change the sets.

  • x86_64 (server1, 3 jobs): sets 81 of 93 pass, maps 25 of 31 (maps/nat_addr_port needs nft-28). Before this PR, sets 78 passed. tools/nftables/report.md gives 61 for sets.
  • Tests that now pass: sets/0034get_element_0, 0044interval_overlap_0, 0047nat_0 and 0067nat_concat_interval_0, maps/typeof_integer_0, and optimizations/merge_vmap_raw. No test that passed before fails now. maps/nat_addr_port, optimizations/merge_stmts_concat_vmap and transactions/0046set_0 also pass with this kernel, but they need nft-28 (numgen, meta pkttype and meta priority).
  • Some timeouts are slow tests in a batch with a limit of 300 seconds. Alone, in one guest, they pass: sets/0044interval_overlap_1 in 246 s, maps/0004interval_map_create_once_0 in 167 s and sets/automerge_0 in 568 s.
  • The load average of server1 was 2.89, 2.95, 2.90 at the start and 2.83, 3.56, 4.36 at the end.
  • arm64 (server2, 3 jobs, a kernel without the last change to the overlap check): sets 75 of 93 and maps 25 of 31, with 13 hangs. The load average of server2 was 14.44, 14.60, 16.21 at the start and 32.36, 34.16, 33.05 at the end. Then the 13 tests that hung ran again with the final kernel, 2 jobs and a limit of 900 seconds: sets/0011, 0012, 0043concatenated_ranges_1 and 0044interval_overlap_0 pass. The other 8 hang again: they add many elements, and the arm64 guest runs in TCG. sets/sets_with_ifnames fails, as it did before this PR. The load average was 17.16, 20.89, 25.69 at the start and 18.66, 16.57, 15.84 at the end.
  • sets/0043concatenated_ranges_0 fails on Linux too: nft gives byteorder with a size of 2 and a length of 1, and nft_byteorder.c of Linux master gives EOPNOTSUPP for it.
  • The unit tests of rk-net pass.
  • Boot tests (the kernel had this PR and nft-28): cargo xtask boot-test inet passes. RK_AARCH64_TESTS=inet cargo xtask boot-test aarch64 passes: inet, inet with virtio-pci, and inet with virtio-pci behind a bridge. The load average of server2 was 25.68, 27.38, 28.93 at the start and 18.43, 21.37, 25.94 at the end.

The full gate did not run.

@tamnd tamnd added kind/feature New behavior or a new part. area/net Networking: sockets, TCP, netlink and netfilter. labels Nov 12, 2026
@tamnd
tamnd merged commit fd45f0d into main Nov 12, 2026
6 of 7 checks passed
@tamnd
tamnd deleted the nft-27 branch November 12, 2026 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/net Networking: sockets, TCP, netlink and netfilter. kind/feature New behavior or a new part.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant