git: 098febfcc155 - main - pf tests: test block/no-match limiters
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 14 Jan 2026 08:06:19 UTC
The branch main has been updated by kp:
URL: https://cgit.FreeBSD.org/src/commit/?id=098febfcc1559950ebe49e106f25851e7706a018
commit 098febfcc1559950ebe49e106f25851e7706a018
Author: Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2026-01-13 08:54:28 +0000
Commit: Kristof Provost <kp@FreeBSD.org>
CommitDate: 2026-01-14 06:44:44 +0000
pf tests: test block/no-match limiters
Sponsored by: Rubicon Communications, LLC ("Netgate")
---
tests/sys/netpfil/pf/limiters.sh | 56 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/tests/sys/netpfil/pf/limiters.sh b/tests/sys/netpfil/pf/limiters.sh
index ee58d3974f9f..4775039a4a94 100644
--- a/tests/sys/netpfil/pf/limiters.sh
+++ b/tests/sys/netpfil/pf/limiters.sh
@@ -130,6 +130,61 @@ state_rate_cleanup()
pft_cleanup
}
+atf_test_case "state_block" "cleanup"
+state_block_head()
+{
+ atf_set descr 'Test block mode state limiter'
+ atf_set require.user root
+}
+
+state_block_body()
+{
+ pft_init
+
+ epair=$(vnet_mkepair)
+
+ ifconfig ${epair}a 192.0.2.2/24 up
+
+ vnet_mkjail alcatraz ${epair}b
+ jexec alcatraz ifconfig ${epair}b 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
+ # Allow one ICMP state per 5 seconds
+ pft_set_rules alcatraz \
+ "set timeout icmp.error 120" \
+ "state limiter \"server\" id 1 limit 1000 rate 1/5" \
+ "pass" \
+ "pass in proto icmp state limiter \"server\" (block)"
+
+ atf_check -s exit:0 -o ignore \
+ ping -c 2 192.0.2.1
+
+ # This should now fail
+ atf_check -s exit:2 -o ignore \
+ ping -c 2 192.0.2.1
+
+ # However, if we set no-match and exceed the limit we just pass
+ pft_set_rules alcatraz \
+ "set timeout icmp.error 120" \
+ "state limiter \"server\" id 1 limit 1000 rate 1/5" \
+ "pass" \
+ "pass in proto icmp state limiter \"server\" (no-match)"
+
+ atf_check -s exit:0 -o ignore \
+ ping -c 2 192.0.2.1
+ atf_check -s exit:0 -o ignore \
+ ping -c 2 192.0.2.1
+}
+
+state_block_cleanup()
+{
+ pft_cleanup
+}
+
atf_test_case "source_basic" "cleanup"
source_basic_head()
{
@@ -205,5 +260,6 @@ atf_init_test_cases()
{
atf_add_test_case "state_basic"
atf_add_test_case "state_rate"
+ atf_add_test_case "state_block"
atf_add_test_case "source_basic"
}