git: 6642ba36f186 - main - pf tests: explicitly test zeroing counters within an anchor

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Tue, 07 Apr 2026 15:26:23 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=6642ba36f1860599a4c5562dc24f5dff080bbb42

commit 6642ba36f1860599a4c5562dc24f5dff080bbb42
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2026-04-07 14:07:45 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2026-04-07 14:58:32 +0000

    pf tests: explicitly test zeroing counters within an anchor
    
    While here fix the match pattern in the existing test.
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 tests/sys/netpfil/pf/anchor.sh | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tests/sys/netpfil/pf/anchor.sh b/tests/sys/netpfil/pf/anchor.sh
index f321c742788e..df4a1660d797 100644
--- a/tests/sys/netpfil/pf/anchor.sh
+++ b/tests/sys/netpfil/pf/anchor.sh
@@ -352,8 +352,20 @@ counter_body()
 	# Generate traffic
 	atf_check -s exit:0 -o ignore ping -c 1 192.0.2.1
 	atf_check -s exit:0 -e ignore \
-	    -o match:'[ Evaluations: 1         Packets: 2         Bytes: 168         States: 1     ]' \
+	    -o match:'\[ Evaluations: 1         Packets: 2         Bytes: 168         States: 1     \]' \
 	    jexec alcatraz pfctl -sr -vv
+
+	# Zero counters outside of the anchor
+	jexec alcatraz pfctl -sr -vv -z
+	atf_check -s exit:0 -e ignore \
+	    -o match:'\[ Evaluations: 1         Packets: 2         Bytes: 168         States: 1     \]' \
+	    jexec alcatraz pfctl -sr -vv -a "foo"
+
+	# Zero the anchor's counters
+	jexec alcatraz pfctl -sr -vv -z -a "foo"
+	atf_check -s exit:0 -e ignore \
+	    -o match:'\[ Evaluations: 0         Packets: 0         Bytes: 0           States: 1     \]' \
+	    jexec alcatraz pfctl -sr -vv -a "foo"
 }
 
 counter_cleanup()