tests: shell: add conntrack template attachment test
Florian Westphal
maintainerPATCH 1/1 tests: shell: add conntrack template attachment test
Try to attach ct templates at various priorities and check that attachmet only works at the acceptable positions: prerouting + output, before nf_conntrack_in() on the kernel side.
Relax the test for now to not fail on kernels that lack the required validation and SKIP if all attachment request work.
---
Companion nftables.git shell test for the
'netfilter: nft_ct: validate hook and priority for ct zone set' kernel patch.
It could be added to nftables.git already, its expected to PASS or SKIP only.
...te_ct_zone_set_template_attach.sh.json-nft | 918 ++++++++++++++++++ ...alidate_ct_zone_set_template_attach.sh.nft | 206 ++++ .../validate_ct_zone_set_template_attach.sh | 377 +++++++ 3 files changed, 1501 insertions(+) create mode 100644 tests/shell/testcases/transactions/dumps/validate_ct_zone_set_template_attach.sh.json-nft create mode 100644 tests/shell/testcases/transactions/dumps/validate_ct_zone_set_template_attach.sh.nft create mode 100755 tests/shell/testcases/transactions/validate_ct_zone_set_template_attach.sh
tests/shell/testcases/transactions/dumps/validate_ct_zone_set_template_attach.sh.json-nft new file +918 -0
@@ -0,0 +1,918 @@ +{ + "nftables": [ + { + "metainfo": { + "version": "VERSION", + "release_name": "RELEASE_NAME", + "json_schema_version": 1 + } + }, + { + "table": { + "family": "ip", + "name": "ctz", + "handle": 0 + } + }, + { + "chain": { + "family": "ip", + "table": "ctz", + "name": "prerouting_before", + "handle": 0, + "type": "filter", + "hook": "prerouting", + "prio": -201, + "policy": "accept" + } + }, + { + "chain": { + "family": "ip", + "table": "ctz", + "name": "prerouting_at", + "handle": 0, + "type": "filter", + "hook": "prerouting", + "prio": -200, + "policy": "accept" + } + }, + { + "chain": { + "family": "ip", + "table": "ctz", + "name": "prerouting_after", + "handle": 0, + "type": "filter", + "hook": "prerouting", + "prio": -199, + "policy": "accept" + } + }, + { + "chain": { + "family": "ip", + "table": "ctz", + "name": "input", + "handle": 0, + "type": "filter", + "hook": "input", + "prio": 0, + "policy": "accept" + } + }, + { + "chain": { + "family": "ip", + "table": "ctz", + "name": "forward", + "handle": 0, + "type": "filter", + "hook": "forward", + "prio": 0, + "policy": "accept" + } + }, + { + "chain": { + "family": "ip", + "table": "ctz", + "name": "output_before", + "handle": 0, + "type": "filter", + "hook": "output", + "prio": -201, + "policy": "accept" + } + }, + { + "chain": { + "family": "ip", + "table": "ctz", + "name": "output_at", + "handle": 0, + "type": "filter", + "hook": "output", + "prio": -200, + "policy": "accept" + } + }, + { + "chain": { + "family": "ip", + "table": "ctz", + "name": "output_after", + "handle": 0, + "type": "filter", + "hook": "output", + "prio": -199, + "policy": "accept" + } + }, + { + "chain": { + "family": "ip", + "table": "ctz", + "name": "postrouting", + "handle": 0, + "type": "filter", + "hook": "postrouting", + "prio": 0, + "policy": "accept" + } + }, + { + "chain": { + "family": "ip", + "table": "ctz", + "name": "nonbase", + "handle": 0 + } + }, + { + "rule": { + "family": "ip", + "table": "ctz", + "chain": "prerouting_before", + "handle": 0, + "expr": [ + { + "mangle": { + "key": { + "ct": { + "key": "zone" + } + }, + "value": 1 + } + } + ] + } + }, + { + "rule": { + "family": "ip", + "table": "ctz", + "chain": "prerouting_before", + "handle": 0, + "expr": [ + { + "jump": { + "target": "nonbase" + } + } + ] + } + }, + { + "rule": { + "family": "ip", + "table": "ctz", + "chain": "output_before", + "handle": 0, + "expr": [ + { + "mangle": { + "key": { + "ct": { + "key": "zone" + } + }, + "value": 1 + } + } + ] + } + }, + { + "rule": { + "family": "ip", + "table": "ctz", + "chain": "output_before", + "handle": 0, + "expr": [ + { + "jump": { + "target": "nonbase" + } + } + ] + } + }, + { + "rule": { + "family": "ip", + "table": "ctz", + "chain": "nonbase", + "handle": 0, + "expr": [ + { + "mangle": { + "key": { + "ct": { + "key": "zone" + } + }, + "value": 1 + } + } + ] + } + }, + { + "table": { + "family": "ip6", + "name": "ctz", + "handle": 0 + } + }, + { + "chain": { + "family": "ip6", + "table": "ctz", + "name": "prerouting_before", + "handle": 0, + "type": "filter", + "hook": "prerouting", + "prio": -201, + "policy": "accept" + } + }, + { + "chain": { + "family": "ip6", + "table": "ctz", + "name": "prerouting_at", + "handle": 0, + "type": "filter", + "hook": "prerouting", + "prio": -200, + "policy": "accept" + } + }, + { + "chain": { + "family": "ip6", + "table": "ctz", + "name": "prerouting_after", + "handle": 0, + "type": "filter", + "hook": "prerouting", + "prio": -199, + "policy": "accept" + } + }, + { + "chain": { + "family": "ip6", + "table": "ctz", + "name": "input", + "handle": 0, + "type": "filter", + "hook": "input", + "prio": 0, + "policy": "accept" + } + }, + { + "chain": { + "family": "ip6", + "table": "ctz", + "name": "forward", + "handle": 0, + "type": "filter", + "hook": "forward", + "prio": 0, + "policy": "accept" + } + }, + { + "chain": { + "family": "ip6", + "table": "ctz", + "name": "output_before", + "handle": 0, + "type": "filter", + "hook": "output", + "prio": -201, + "policy": "accept" + } + }, + { + "chain": { + "family": "ip6", + "table": "ctz", + "name": "output_at", + "handle": 0, + "type": "filter", + "hook": "output", + "prio": -200, + "policy": "accept" + } + }, + { + "chain": { + "family": "ip6", + "table": "ctz", + "name": "output_after", + "handle": 0, + "type": "filter", + "hook": "output", + "prio": -199, + "policy": "accept" + } + }, + { + "chain": { + "family": "ip6", + "table": "ctz", + "name": "postrouting", + "handle": 0, + "type": "filter", + "hook": "postrouting", + "prio": 0, + "policy": "accept" + } + }, + { + "chain": { + "family": "ip6", + "table": "ctz", + "name": "nonbase", + "handle": 0 + } + }, + { + "rule": { + "family": "ip6", + "table": "ctz", + "chain": "prerouting_before", + "handle": 0, + "expr": [ + { + "mangle": { + "key": { + "ct": { + "key": "zone" + } + }, + "value": 1 + } + } + ] + } + }, + { + "rule": { + "family": "ip6", + "table": "ctz", + "chain": "prerouting_before", + "handle": 0, + "expr": [ + { + "jump": { + "target": "nonbase" + } + } + ] + } + }, + { + "rule": { + "family": "ip6", + "table": "ctz", + "chain": "output_before", + "handle": 0, + "expr": [ + { + "mangle": { + "key": { + "ct": { + "key": "zone" + } + }, + "value": 1 + } + } + ] + } + }, + { + "rule": { + "family": "ip6", + "table": "ctz", + "chain": "output_before", + "handle": 0, + "expr": [ + { + "jump": { + "target": "nonbase" + } + } + ] + } + }, + { + "rule": { + "family": "ip6", + "table": "ctz", + "chain": "nonbase", + "handle": 0, + "expr": [ + { + "mangle": { + "key": { + "ct": { + "key": "zone" + } + }, + "value": 1 + } + } + ] + } + }, + { + "table": { + "family": "bridge", + "name": "ctz", + "handle": 0 + } + }, + { + "chain": { + "family": "bridge", + "table": "ctz", + "name": "prerouting_before", + "handle": 0, + "type": "filter", + "hook": "prerouting", + "prio": -201, + "policy": "accept" + } + }, + { + "chain": { + "family": "bridge", + "table": "ctz", + "name": "prerouting_at", + "handle": 0, + "type": "filter", + "hook": "prerouting", + "prio": -200, + "policy": "accept" + } + }, + { + "chain": { + "family": "bridge", + "table": "ctz", + "name": "prerouting_after", + "handle": 0, + "type": "filter", + "hook": "prerouting", + "prio": -199, + "policy": "accept" + } + }, + { + "chain": { + "family": "bridge", + "table": "ctz", + "name": "input", + "handle": 0, + "type": "filter", + "hook": "input", + "prio": 0, + "policy": "accept" + } + }, + { + "chain": { + "family": "bridge", + "table": "ctz", + "name": "forward", + "handle": 0, + "type": "filter", + "hook": "forward", + "prio": 0, + "policy": "accept" + } + }, + { + "chain": { + "family": "bridge", + "table": "ctz", + "name": "output_before", + "handle": 0, + "type": "filter", + "hook": "output", + "prio": -201, + "policy": "accept" + } + }, + { + "chain": { + "family": "bridge", + "table": "ctz", + "name": "output_at", + "handle": 0, + "type": "filter", + "hook": "output", + "prio": -200, + "policy": "accept" + } + }, + { + "chain": { + "family": "bridge", + "table": "ctz", + "name": "output_after", + "handle": 0, + "type": "filter", + "hook": "output", + "prio": -199, + "policy": "accept" + } + }, + { + "chain": { + "family": "bridge", + "table": "ctz", + "name": "postrouting", + "handle": 0, + "type": "filter", + "hook": "postrouting", + "prio": 0, + "policy": "accept" + } + }, + { + "chain": { + "family": "bridge", + "table": "ctz", + "name": "nonbase", + "handle": 0 + } + }, + { + "rule": { + "family": "bridge", + "table": "ctz", + "chain": "prerouting_before", + "handle": 0, + "expr": [ + { + "mangle": { + "key": { + "ct": { + "key": "zone" + } + }, + "value": 1 + } + } + ] + } + }, + { + "rule": { + "family": "bridge", + "table": "ctz", + "chain": "prerouting_before", + "handle": 0, + "expr": [ + { + "jump": { + "target": "nonbase" + } + } + ] + } + }, + { + "rule": { + "family": "bridge", + "table": "ctz", + "chain": "nonbase", + "handle": 0, + "expr": [ + { + "mangle": { + "key": { + "ct": { + "key": "zone" + } + }, + "value": 1 + } + } + ] + } + }, + { + "table": { + "family": "inet", + "name": "ctz", + "handle": 0 + } + }, + { + "chain": { + "family": "inet", + "table": "ctz", + "name": "prerouting_before", + "handle": 0, + "type": "filter", + "hook": "prerouting", + "prio": -201, + "policy": "accept" + } + }, + { + "chain": { + "family": "inet", + "table": "ctz", + "name": "prerouting_at", + "handle": 0, + "type": "filter", + "hook": "prerouting", + "prio": -200, + "policy": "accept" + } + }, + { + "chain": { + "family": "inet", + "table": "ctz", + "name": "prerouting_after", + "handle": 0, + "type": "filter", + "hook": "prerouting", + "prio": -199, + "policy": "accept" + } + }, + { + "chain": { + "family": "inet", + "table": "ctz", + "name": "input", + "handle": 0, + "type": "filter", + "hook": "input", + "prio": 0, + "policy": "accept" + } + }, + { + "chain": { + "family": "inet", + "table": "ctz", + "name": "forward", + "handle": 0, + "type": "filter", + "hook": "forward", + "prio": 0, + "policy": "accept" + } + }, + { + "chain": { + "family": "inet", + "table": "ctz", + "name": "output_before", + "handle": 0, + "type": "filter", + "hook": "output", + "prio": -201, + "policy": "accept" + } + }, + { + "chain": { + "family": "inet", + "table": "ctz", + "name": "output_at", + "handle": 0, + "type": "filter", + "hook": "output", + "prio": -200, + "policy": "accept" + } + }, + { + "chain": { + "family": "inet", + "table": "ctz", + "name": "output_after", + "handle": 0, + "type": "filter", + "hook": "output", + "prio": -199, + "policy": "accept" + } + }, + { + "chain": { + "family": "inet", + "table": "ctz", + "name": "postrouting", + "handle": 0, + "type": "filter", + "hook": "postrouting", + "prio": 0, + "policy": "accept" + } + }, + { + "chain": { + "family": "inet", + "table": "ctz", + "name": "nonbase", + "handle": 0 + } + }, + { + "chain": { + "family": "inet", + "table": "ctz", + "name": "ingress", + "handle": 0, + "type": "filter", + "hook": "ingress", + "prio": 0, + "policy": "accept" + } + }, + { + "rule": { + "family": "inet", + "table": "ctz", + "chain": "prerouting_before", + "handle": 0, + "expr": [ + { + "mangle": { + "key": { + "ct": { + "key": "zone" + } + }, + "value": 1 + } + } + ] + } + }, + { + "rule": { + "family": "inet", + "table": "ctz", + "chain": "prerouting_before", + "handle": 0, + "expr": [ + { + "jump": { + "target": "nonbase" + } + } + ] + } + }, + { + "rule": { + "family": "inet", + "table": "ctz", + "chain": "output_before", + "handle": 0, + "expr": [ + { + "mangle": { + "key": { + "ct": { + "key": "zone" + } + }, + "value": 1 + } + } + ] + } + }, + { + "rule": { + "family": "inet", + "table": "ctz", + "chain": "output_before", + "handle": 0, + "expr": [ + { + "jump": { + "target": "nonbase" + } + } + ] + } + }, + { + "rule": { + "family": "inet", + "table": "ctz", + "chain": "nonbase", + "handle": 0, + "expr": [ + { + "mangle": { + "key": { + "ct": { + "key": "zone" + } + }, + "value": 1 + } + } + ] + } + }, + { + "table": { + "family": "arp", + "name": "ctz", + "handle": 0 + } + }, + { + "chain": { + "family": "arp", + "table": "ctz", + "name": "input", + "handle": 0, + "type": "filter", + "hook": "input", + "prio": 0, + "policy": "accept" + } + }, + { + "chain": { + "family": "arp", + "table": "ctz", + "name": "output", + "handle": 0, + "type": "filter", + "hook": "output", + "prio": 0, + "policy": "accept" + } + }, + { + "chain": { + "family": "arp", + "table": "ctz", + "name": "nonbase", + "handle": 0 + } + }, + { + "table": { + "family": "netdev", + "name": "ctz", + "handle": 0 + } + }, + { + "chain": { + "family": "netdev", + "table": "ctz", + "name": "ingress", + "handle": 0, + "type": "filter", + "hook": "ingress", + "prio": 0, + "policy": "accept" + } + }, + { + "chain": { + "family": "netdev", + "table": "ctz", + "name": "nonbase", + "handle": 0 + } + }, + { + "chain": { + "family": "netdev", + "table": "ctz", + "name": "egress", + "handle": 0, + "type": "filter", + "hook": "egress", + "prio": 0, + "policy": "accept" + } + } + ] +}
tests/shell/testcases/transactions/dumps/validate_ct_zone_set_template_attach.sh.nft new file +206 -0
206 lines not on this page · raw message
tests/shell/testcases/transactions/validate_ct_zone_set_template_attach.sh new file +377 -0
377 lines not on this page · raw message
Signature · 1 line
2.55.0
Florian Westphal
maintainerQuoted 9 lines · Florian Westphal
Try to attach ct templates at various priorities and check that attachmet only works at the acceptable positions: prerouting + output, before
nf_conntrack_in()on the kernel side.Relax the test for now to not fail on kernels that lack the required validation and SKIP if all attachment request work.
Assisted-by LLMSigned-off-by Florian Westphal <[email protected]>
Quoted 7 lines
---
Companion nftables.git shell test for the
'netfilter:nft_ct: validate hook and priority for ct zone set' kernel patch.It could be added to nftables.git already, its expected to PASS or SKIP only.
https://sashiko.dev/#/patchset/20261006231953.6338-1-fw%40strlen.de
I've fixed most of those up locally, if there are no objections I'll push this out tomorrow.