aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristof Provost <kp@FreeBSD.org>2024-11-18 13:40:01 +0000
committerKristof Provost <kp@FreeBSD.org>2024-11-18 17:57:53 +0000
commit5eee34fa0351f1fdb240f7d085145c05e9ed95d5 (patch)
tree930186e0555dc6f2d5c91b46f76e104bb40dbba5
parent10343013a4daff5e009a2fe980086ce915fb5a28 (diff)
pf tests: check counters on anchors
Sponsored by: Rubicon Communications, LLC ("Netgate")
-rw-r--r--tests/sys/netpfil/pf/anchor.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/sys/netpfil/pf/anchor.sh b/tests/sys/netpfil/pf/anchor.sh
index 25d9d5b6df03..847f8d4f6dab 100644
--- a/tests/sys/netpfil/pf/anchor.sh
+++ b/tests/sys/netpfil/pf/anchor.sh
@@ -233,6 +233,44 @@ quick_cleanup()
pft_cleanup
}
+atf_test_case "counter" "cleanup"
+counter_head()
+{
+ atf_set descr 'Test counters on anchors'
+ atf_set require.user root
+}
+
+counter_body()
+{
+ pft_init
+
+ epair=$(vnet_mkepair)
+ vnet_mkjail alcatraz ${epair}a
+
+ ifconfig ${epair}b 192.0.2.2/24 up
+ jexec alcatraz ifconfig ${epair}a 192.0.2.1/24 up
+
+ # Sanity check
+ atf_check -s exit:0 -o ignore ping -c 1 192.0.2.1
+
+ jexec alcatraz pfctl -e
+ pft_set_rules alcatraz \
+ "anchor \"foo\" {\n\
+ pass\n\
+ }"
+
+ # 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 ]' \
+ jexec alcatraz pfctl -sr -vv
+}
+
+counter_cleanup()
+{
+ pft_cleanup
+}
+
atf_init_test_cases()
{
atf_add_test_case "pr183198"
@@ -241,4 +279,5 @@ atf_init_test_cases()
atf_add_test_case "wildcard"
atf_add_test_case "nested_label"
atf_add_test_case "quick"
+ atf_add_test_case "counter"
}