Skip to content

nf_tables: numgen, hash and more meta keys, as nft_numgen.c, nft_hash.c and nft_meta.c of Linux - #711

Merged
tamnd merged 2 commits into
mainfrom
nft-28
Nov 12, 2026
Merged

tamnd merged 2 commits into
mainfrom
nft-28

Conversation

@tamnd

@tamnd tamnd commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Part of #542.

This PR adds the expressions numgen and hash of nf_tables and more keys of meta, as nft_numgen.c, nft_hash.c and nft_meta.c of Linux. It is for the "sets and maps" and "optimizations" groups of tools/nftables/report.md.

  • numgen gives a counter (inc) or a random number (random) modulo a value, plus an offset.
  • hash gives the jhash of registers (jhash) or the symmetric hash of the flow (symhash) modulo a value, plus an offset.
  • New meta keys: priority, pkttype, cpu, iifgroup, oifgroup, random, iifkind, oifkind, time, day, hour, sdif and sdifname. A rule can also set meta priority and meta pkttype. A packet now has a priority and a type, as skb->priority and skb->pkt_type.
  • meta iif and meta iifname of a packet with no device give 0 and "", as in Linux.

Tests

The tests/shell dirs that the change touches: json, maps, nft-f, optimizations, sets and transactions, 222 tests. The kernel had nft-27 (#707) and this PR.

  • x86_64 (server1, 3 jobs): 190 ok, 17 failed, 8 dump-fail, 3 timeout, 4 skipped. The load average was 2.81, 2.83, 2.84 at the start and 1.70, 2.30, 3.36 at the end.
  • arm64 (server2, 3 jobs): 182 ok, 15 failed, 8 dump-fail, 13 hang, 4 skipped. The load average was 14.44, 14.60, 16.21 at the start and 32.36, 34.16, 33.05 at the end. The hangs are tests that add many elements, and the arm64 guest runs in TCG.
  • Tests that now pass on x86_64 and arm64: maps/nat_addr_port (numgen), optimizations/merge_stmts_concat_vmap (meta pkttype) and transactions/0046set_0 (meta priority). Each of them failed before.
  • optimizations/ruleset, which uses meta iifgroup, still fails.
  • The unit tests of rk-net pass.
  • Boot tests: 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 0cd473b into main Nov 12, 2026
6 of 7 checks passed
@tamnd
tamnd deleted the nft-28 branch November 12, 2026 19:41
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