git: 95d5a656a2b6 - main - pf tests: syncookie limits test

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Mon, 12 Sep 2022 08:20:52 UTC
The branch main has been updated by kp:

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

commit 95d5a656a2b69e38461fcfba31e9f517648bd52a
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2022-09-08 16:34:12 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2022-09-12 07:32:02 +0000

    pf tests: syncookie limits test
    
    Test that we can successfuly set syncookie high/low watermarks for very
    low or very high state limits.
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D36498
---
 tests/sys/netpfil/pf/syncookie.sh | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/tests/sys/netpfil/pf/syncookie.sh b/tests/sys/netpfil/pf/syncookie.sh
index d85beac1a4d1..36d80b82289b 100644
--- a/tests/sys/netpfil/pf/syncookie.sh
+++ b/tests/sys/netpfil/pf/syncookie.sh
@@ -217,10 +217,43 @@ adaptive_cleanup()
 	pft_cleanup
 }
 
+atf_test_case "limits" "cleanup"
+limits_head()
+{
+	atf_set descr 'Ensure limit calculation works for low or high state limits'
+	atf_set require.user root
+}
+
+limits_body()
+{
+	pft_init
+
+	vnet_mkjail alcatraz
+
+	jexec alcatraz pfctl -e
+	pft_set_rules alcatraz \
+		"set limit states 1" \
+		"set syncookies adaptive (start 10%%, end 5%%)" \
+		"pass in" \
+		"pass out"
+
+	pft_set_rules alcatraz \
+		"set limit states 326000000" \
+		"set syncookies adaptive (start 10%%, end 5%%)" \
+		"pass in" \
+		"pass out"
+}
+
+limits_cleanup()
+{
+	pft_cleanup
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case "basic"
 	atf_add_test_case "forward"
 	atf_add_test_case "nostate"
 	atf_add_test_case "adaptive"
+	atf_add_test_case "limits"
 }