Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Sep 2025 12:41:46 GMT
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 2c53e251601c - main - pf tests: test once rule inside an anchor
Message-ID:  <202509251241.58PCfkZI004816@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kp:

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

commit 2c53e251601c1fcd558f42a16f6030ba75b7e8df
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2025-08-28 15:36:03 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2025-09-25 12:41:10 +0000

    pf tests: test once rule inside an anchor
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 tests/sys/netpfil/pf/once.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/tests/sys/netpfil/pf/once.sh b/tests/sys/netpfil/pf/once.sh
index 50ccb17e16c6..54dbb030dbe6 100644
--- a/tests/sys/netpfil/pf/once.sh
+++ b/tests/sys/netpfil/pf/once.sh
@@ -77,7 +77,56 @@ basic_cleanup()
 	pft_cleanup
 }
 
+atf_test_case "anchor" "cleanup"
+anchor_head()
+{
+	atf_set descr 'Test one shot rule in anchors'
+	atf_set require.user root
+}
+
+anchor_body()
+{
+	pft_init
+	epair=$(vnet_mkepair)
+
+	vnet_mkjail alcatraz ${epair}a
+	jexec alcatraz ifconfig ${epair}a 192.0.2.1/24 up
+
+	ifconfig ${epair}b 192.0.2.2/24 up
+
+	# Sanity checks
+	atf_check -s exit:0 -o ignore \
+	    ping -c 1 192.0.2.1
+
+	jexec alcatraz pfctl -e
+	pft_set_rules alcatraz \
+	    "block" \
+	    "anchor \"once\" {\n
+	        pass in from 192.0.2.2 once\n
+	    }"
+
+	# First once succeeds
+	atf_check -s exit:0 -o ignore \
+	    ping -c 3 192.0.2.1
+
+	# Check for '# expired'
+	jexec alcatraz pfctl -sr -vv -a "*"
+	atf_check -s exit:0 -e ignore \
+	    -o match:'pass in inet from 192.0.2.2 to any flags S/SA keep state once # expired' \
+	    jexec alcatraz pfctl -sr -vv -a "*"
+
+	# The second one does not
+	atf_check -s exit:2 -o ignore \
+	    ping -c 3 192.0.2.1
+}
+
+anchor_cleanup()
+{
+	pft_cleanup
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case "basic"
+	atf_add_test_case "anchor"
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202509251241.58PCfkZI004816>