selftests: netfilter: add functional test for nft ct timeout policies
Subsystems (3)
PATCH 1/1 selftests: netfilter: add functional test for nft ct timeout policies
There is no selftest coverage for nftables ct timeout objects: no test under tools/testing/selftests/net/netfilter/ exercises "ct timeout set" or checks that a named policy reaches the conntrack state machine.
Add nft_ct_timeout.sh with three subtests, using two netns joined by a veth pair and reading the remaining flow lifetime from "conntrack -L":
1. test_policy_applied: a TCP connection matched by a "ct timeout set" rule gets the ESTABLISHED timeout carried by the policy (120s here) instead of the kernel default, which is 5 days for that state (see nf_conntrack_proto_tcp.c, tcp_timeouts[TCP_CONNTRACK_ESTABLISHED]).
2. test_default_preserved: a connection on a port not covered by any rule keeps the default. The expected value is read from nf_conntrack_tcp_timeout_established rather than hardcoded, so a host that lowered the sysctl does not fail the test spuriously.
3. test_policy_reload: after the table is deleted and reloaded, a new connection through the rule receives the policy timeout again, covering the create/assign/destroy/re-create object lifecycle.
The test checks kernel behaviour rather than the parsing round-trip, which the nftables.git functional tests already cover.
---
This replaces the nft_ct timeout regression test posted in April:
https://lore.kernel.org/netfilter-devel/[email protected]/
Florian's review of that patch asked for a functional test for timeout policies rather than a regression script, and noted that the nftables.git tests only cover the parsing side. This is that test: it checks that the policy reaches the conntrack state machine, and does not re-check parsing. The executable bit is set this time.
Test output on x86_64 (nft 1.1.6, conntrack-tools 1.4.9):
PASS: test_policy_applied: timeout 119s <= policy 120s
PASS: test_default_preserved: timeout 431999s matches default 432000s
PASS: test_policy_reload: timeout 119s <= policy 120s
.../testing/selftests/net/netfilter/Makefile | 1 + .../selftests/net/netfilter/nft_ct_timeout.sh | 217 ++++++++++++++++++ 2 files changed, 218 insertions(+) create mode 100755 tools/testing/selftests/net/netfilter/nft_ct_timeout.sh
tools/testing/selftests/net/netfilter/Makefile +1 -0
@@ -25,6 +25,7 @@ TEST_PROGS := \ nft_audit.sh \ nft_concat_range.sh \ nft_conntrack_helper.sh \ + nft_ct_timeout.sh \ nft_fib.sh \ nft_fib_nexthop.sh \ nft_flowtable.sh \
tools/testing/selftests/net/netfilter/nft_ct_timeout.sh new file +217 -0
217 lines not on this page · raw message
Signature · 1 line
2.53.0