The branch main has been updated by kp:

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

commit cb7a5d9401d83e817e187099ed187eb2f5360f22
Author:     Kristof Provost <[email protected]>
AuthorDate: 2026-01-07 15:46:34 +0000
Commit:     Kristof Provost <[email protected]>
CommitDate: 2026-01-14 06:44:40 +0000

    pf tests: state limiter rate test
    
    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 851c0a95d5e5..17a66ed12c5e 100644
--- a/tests/sys/netpfil/pf/limiters.sh
+++ b/tests/sys/netpfil/pf/limiters.sh
@@ -75,7 +75,63 @@ state_basic_cleanup()
        pft_cleanup
 }
 
+atf_test_case "state_rate" "cleanup"
+state_rate_head()
+{
+       atf_set descr 'State rate limiting test'
+       atf_set require.user root
+}
+
+state_rate_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" \
+           "block in proto icmp" \
+           "pass in proto icmp state limiter \"server\""
+
+       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
+
+       jexec alcatraz pfctl -sLimiterStates
+       ratelim=$(jexec alcatraz pfctl -sLimiterStates | awk 'NR>1 { print $6; 
}')
+       if [ $ratelim -eq 0 ]; then
+               atf_fail "Rate limit not incremented"
+       fi
+
+       sleep 6
+
+       # We can now create another state
+       atf_check -s exit:0 -o ignore \
+           ping -c 2 192.0.2.1
+}
+
+state_rate_cleanup()
+{
+       pft_cleanup
+}
+
 atf_init_test_cases()
 {
        atf_add_test_case "state_basic"
+       atf_add_test_case "state_rate"
 }

Reply via email to