Skip to content

nf_tables: payload that writes the packet and queue, as nft_payload.c and nft_queue.c of Linux - #712

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

tamnd merged 2 commits into
mainfrom
nft-29

Conversation

@tamnd

@tamnd tamnd commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Part of #542.

This PR adds the expression payload that writes the packet and the expression queue, as nft_payload.c and nft_queue.c of Linux. It is for the "nft-f" and "sets and maps" groups of tools/nftables/report.md.

  • payload with NFTA_PAYLOAD_SREG writes a register into the link, network or transport header of the packet, as nft_payload_set_eval. With NFT_PAYLOAD_CSUM_INET, it changes the checksum at the checksum offset. With NFT_PAYLOAD_L4CSUM_PSEUDOHDR, it also changes the checksum of TCP or UDP. A UDP packet with a checksum of 0 keeps it. With NFT_PAYLOAD_CSUM_SCTP, it computes the CRC32c of the SCTP packet again.
  • The checks of nft_payload_set_init: an offset or a checksum offset of more than 255 gives ERANGE, an unknown flag gives EINVAL, a SCTP checksum that is not at offset 8 of the transport header gives EINVAL, and an unknown checksum type gives EOPNOTSUPP.
  • queue gives the verdict NF_QUEUE with the number of the queue, as nft_queue_eval. With NFT_QUEUE_FLAG_BYPASS, a packet with no listener on the queue goes to the next hook. The checks of nft_queue_init and nft_queue_sreg_init are here too.

Tests

The tests/shell dirs that the change touches: maps, nft-f and sets, 158 tests. The kernel had nft-27 (#707), nft-28 (#711) and this PR.

  • x86_64 (server1, 3 jobs): 138 ok, 8 failed, 6 dump-fail, 2 timeout, 4 skipped. maps 27 of 31, nft-f 29 of 34 and sets 82 of 93 pass. The load average was 0.57, 1.22, 1.41 at the start and 1.73, 2.36, 2.30 at the end.
  • arm64 (server2, 3 jobs): 127 ok, 8 failed, 6 dump-fail, 13 hang, 4 skipped. The load average was 17.08, 18.88, 17.84 at the start and 17.37, 19.47, 21.19 at the end. The hangs are tests that add many elements, and the arm64 guest runs in TCG. maps/0003map_add_many_elements_0 and sets/0068interval_stack_overflow_0 hang on arm64 at this load, and pass on x86_64.
  • Tests that now pass on x86_64 and arm64: nft-f/0012different_defines_0 (queue), nft-f/0024priority_0 (payload set) and maps/0007named_ifname_dtype_0. No test that passed before on x86_64 fails now.
  • New unit tests: payload writes a TCP packet and changes the IP and TCP checksums, and queue gives the verdict of its queue. The unit tests of rk-net pass (132).
  • 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 17.19, 16.59, 16.01 at the start and 21.94, 20.08, 18.07 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 b005877 into main Nov 12, 2026
6 of 7 checks passed
@tamnd
tamnd deleted the nft-29 branch November 12, 2026 23:51
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