tests: shell: Add coverage for nf_connlabels_replace()
PATCH 1/1 tests: shell: Add coverage for nf_connlabels_replace()
Signed-off-by Jiri Peska <[email protected]>
--- tests/shell/testcases/packetpath/ct_label_set | 27 ++++ .../packetpath/dumps/ct_label_set.json-nft | 132 ++++++++++++++++++ .../packetpath/dumps/ct_label_set.nft | 11 ++ 3 files changed, 170 insertions(+) create mode 100755 tests/shell/testcases/packetpath/ct_label_set create mode 100644 tests/shell/testcases/packetpath/dumps/ct_label_set.json-nft create mode 100644 tests/shell/testcases/packetpath/dumps/ct_label_set.nft
tests/shell/testcases/packetpath/ct_label_set new file +27 -0
@@ -0,0 +1,27 @@ +#!/bin/bash + +set -e + +ip link set lo up + +$NFT -f - <<EOF +table ip test { + counter labeled {} + chain output { + type filter hook output priority filter; policy accept; + # set bit 1 on each echo-request + icmp type echo-request ip daddr 127.0.0.1 ct label set 1 + # count only if label is already set + icmp type echo-request ip daddr 127.0.0.1 ct label 1 counter name labeled + } +} +EOF + +# Packet 1: replace sets bit 1 +ping -c 1 -W 1 127.0.0.1 >/dev/null + +# Packet 2+: same rule applies on same ICMP ct +ping -c 2 -W 1 127.0.0.1 >/dev/null + +# Assert correct number of matched packets +$NFT list counter ip test labeled | grep -q 'packets 3'
tests/shell/testcases/packetpath/dumps/ct_label_set.json-nft new file +132 -0
132 lines not on this page · raw message
tests/shell/testcases/packetpath/dumps/ct_label_set.nft new file +11 -0
@@ -0,0 +1,11 @@ +table ip test { + counter labeled { + packets 3 bytes 252 + } + + chain output { + type filter hook output priority filter; policy accept; + icmp type echo-request ip daddr 127.0.0.1 ct label set 1 + icmp type echo-request ip daddr 127.0.0.1 ct label 1 counter name "labeled" + } +}
Signature · 1 line
2.54.0
Florian Westphal
maintainerQuoted 9 lines · Jiri Peska
Signed-off-by Jiri Peska <[email protected]>--- tests/shell/testcases/packetpath/ct_label_set | 27 ++++ .../packetpath/dumps/ct_label_set.json-nft | 132 ++++++++++++++++++ .../packetpath/dumps/ct_label_set.nft | 11 ++ 3 files changed, 170 insertions(+) create mode 100755 tests/shell/testcases/packetpath/ct_label_set create mode 100644 tests/shell/testcases/packetpath/dumps/ct_label_set.json-nft create mode 100644 tests/shell/testcases/packetpath/dumps/ct_label_set.nft
This fails for me in dump validation, diff is:
- icmp type echo-request ip daddr 127.0.0.1 ct label set 1 - icmp type echo-request ip daddr 127.0.0.1 ct label 1 counter name "labeled" + icmp type echo-request ip daddr 127.0.0.1 ct label set "bar" + icmp type echo-request ip daddr 127.0.0.1 ct label "bar" counter name "labeled"
This is caused by local configuration. I'd remove the dump files here before applying (and add a nodump file instead).
As the test explicitly checks counters in the script, it will still be useful to assert match/nomatch.
What do you think?