git: 9aeee9486a07 - main - pf tests: basic test for sticky-address configuration on rules

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Thu, 15 Aug 2024 11:06:32 UTC
The branch main has been updated by kp:

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

commit 9aeee9486a07078698d65f254d7b414abd96cfff
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2024-08-15 09:10:09 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2024-08-15 09:11:59 +0000

    pf tests: basic test for sticky-address configuration on rules
    
    There was a bug in pf_handle_get_addr() where it confused the counter and
    pointer in the pf_addr_wrap.p union, causing panics. Test for this.
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 tests/sys/netpfil/pf/route_to.sh | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/tests/sys/netpfil/pf/route_to.sh b/tests/sys/netpfil/pf/route_to.sh
index 5f47cea39b01..305ca4c8eddd 100644
--- a/tests/sys/netpfil/pf/route_to.sh
+++ b/tests/sys/netpfil/pf/route_to.sh
@@ -786,6 +786,30 @@ dummynet_double_cleanup()
 	pft_cleanup
 }
 
+atf_test_case "sticky" "cleanup"
+sticky_head()
+{
+	atf_set descr 'Set and retrieve a rule with sticky-address'
+	atf_set require.user root
+}
+
+sticky_body()
+{
+	pft_init
+
+	vnet_mkjail alcatraz
+
+	pft_set_rules alcatraz \
+	    "pass in quick log on n_test_h_rtr route-to (n_srv_h_rtr <change_dst>) sticky-address from any to <dst> keep state"
+
+	jexec alcatraz pfctl -qvvsr
+}
+
+sticky_cleanup()
+{
+	pft_cleanup
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case "v4"
@@ -802,4 +826,5 @@ atf_init_test_cases()
 	atf_add_test_case "ifbound_reply_to_rdr_dummynet"
 	atf_add_test_case "dummynet_frag"
 	atf_add_test_case "dummynet_double"
+	atf_add_test_case "sticky"
 }