diff options
| author | Kristof Provost <kp@FreeBSD.org> | 2026-01-13 08:54:28 +0000 |
|---|---|---|
| committer | Kristof Provost <kp@FreeBSD.org> | 2026-01-14 06:44:44 +0000 |
| commit | 098febfcc1559950ebe49e106f25851e7706a018 (patch) | |
| tree | 493b69f62e4ee9d2279a07ef4b29804a4a5ffb0a | |
| parent | e28dfd6b5557a502bad6faecac4b0b8ecfd611cc (diff) | |
pf tests: test block/no-match limiters
Sponsored by: Rubicon Communications, LLC ("Netgate")
| -rw-r--r-- | tests/sys/netpfil/pf/limiters.sh | 56 |
1 files changed, 56 insertions, 0 deletions
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" } |
