git: 5d6b503ed097 - stable/13 - pf tests: try to trigger locking issues in pfsync_timeout()

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Mon, 27 Mar 2023 08:16:38 UTC
The branch stable/13 has been updated by kp:

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

commit 5d6b503ed097733af83003cf675f3d55c2b90756
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2023-03-20 13:58:34 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2023-03-27 08:16:03 +0000

    pf tests: try to trigger locking issues in pfsync_timeout()
    
    PR:             268246
    MFC after:      1 week
    Sponsored by:   Rubicon Communications, LLC (Netgate)
    
    (cherry picked from commit a6719858a48019aa54e1ea3be57d17fa88b080c6)
---
 tests/sys/netpfil/pf/pfsync.sh | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/tests/sys/netpfil/pf/pfsync.sh b/tests/sys/netpfil/pf/pfsync.sh
index a5dc3716bbfe..748c0b2fcf29 100644
--- a/tests/sys/netpfil/pf/pfsync.sh
+++ b/tests/sys/netpfil/pf/pfsync.sh
@@ -584,6 +584,39 @@ pbr_common_cleanup()
 	pft_cleanup
 }
 
+atf_test_case "timeout" "cleanup"
+timeout_head()
+{
+	atf_set descr 'Trigger pfsync_timeout()'
+	atf_set require.user root
+}
+
+timeout_body()
+{
+	pft_init
+
+	vnet_mkjail one
+
+	jexec one ifconfig lo0 127.0.0.1/8 up
+	jexec one ifconfig lo0 inet6 ::1/128 up
+
+	pft_set_rules one \
+		"pass all"
+	jexec one pfctl -e
+	jexec one ifconfig pfsync0 defer up
+
+	jexec one ping -c 1 ::1
+	jexec one ping -c 1 127.0.0.1
+
+	# Give pfsync_timeout() time to fire (a callout on a 1 second delay)
+	sleep 2
+}
+
+timeout_cleanup()
+{
+	pft_cleanup
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case "basic"
@@ -592,4 +625,5 @@ atf_init_test_cases()
 	atf_add_test_case "bulk"
 	atf_add_test_case "pbr"
 	atf_add_test_case "pfsync_pbr"
+	atf_add_test_case "timeout"
 }