]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: shell: cover anonymous set with reset command
authorPablo Neira Ayuso <pablo@netfilter.org>
Sun, 25 Aug 2024 22:41:43 +0000 (00:41 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 26 Aug 2024 16:38:21 +0000 (18:38 +0200)
Extend existing test to reset counters for rules with anonymous set.

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1763
Tested-by: Eric Garver <eric@garver.life>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tests/shell/testcases/rule_management/0011reset_0

index 3fede56fb7d8cd98687b6d0e1a46a48ccb443fca..2004b17d5822d4503cbff875248f7d0a8abd9ad1 100755 (executable)
@@ -4,6 +4,27 @@
 
 set -e
 
+echo "loading ruleset with anonymous set"
+$NFT -f - <<EOF
+table t {
+        chain dns-nat-pre {
+                type nat hook prerouting priority filter; policy accept;
+                meta l4proto { tcp, udp } th dport 53 ip saddr 10.24.0.0/24 ip daddr != 10.25.0.1 counter packets 1000 bytes 1000 dnat to 10.25.0.1
+        }
+}
+EOF
+
+echo "resetting ruleset with anonymous set"
+$NFT reset rules
+EXPECT='table ip t {
+       chain dns-nat-pre {
+               type nat hook prerouting priority filter; policy accept;
+               meta l4proto { tcp, udp } th dport 53 ip saddr 10.24.0.0/24 ip daddr != 10.25.0.1 counter packets 0 bytes 0 dnat to 10.25.0.1
+       }
+}'
+$DIFF -u <(echo "$EXPECT") <($NFT list ruleset)
+$NFT flush ruleset
+
 echo "loading ruleset"
 $NFT -f - <<EOF
 table ip t {