git: a6719858a480 - main - pf tests: try to trigger locking issues in pfsync_timeout()

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Mon, 20 Mar 2023 16:39:32 UTC
The branch main has been updated by kp:

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

commit a6719858a48019aa54e1ea3be57d17fa88b080c6
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2023-03-20 13:58:34 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2023-03-20 15:39:14 +0000

    pf tests: try to trigger locking issues in pfsync_timeout()
    
    PR:             268246
    MFC after:      1 week
    Sponsored by:   Rubicon Communications, LLC (Netgate)
---
 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 3871d6be8e14..810b4e203a1f 100644
--- a/tests/sys/netpfil/pf/pfsync.sh
+++ b/tests/sys/netpfil/pf/pfsync.sh
@@ -669,6 +669,39 @@ ipsec_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"
@@ -678,4 +711,5 @@ atf_init_test_cases()
 	atf_add_test_case "pbr"
 	atf_add_test_case "pfsync_pbr"
 	atf_add_test_case "ipsec"
+	atf_add_test_case "timeout"
 }