Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Feb 2025 08:11:50 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: 921c9c7bcc35 - main - pf tests: test new log(matches) behaviour
Message-ID:  <202502210811.51L8Boqq076944@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=921c9c7bcc35747d61a9200c38da13c5fbce3643

commit 921c9c7bcc35747d61a9200c38da13c5fbce3643
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2025-02-14 13:55:30 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2025-02-21 08:11:03 +0000

    pf tests: test new log(matches) behaviour
    
    Ensure that a log(matches, to pflog1) sends all future matches to pflog1.
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 tests/sys/netpfil/pf/pflog.sh | 61 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 60 insertions(+), 1 deletion(-)

diff --git a/tests/sys/netpfil/pf/pflog.sh b/tests/sys/netpfil/pf/pflog.sh
index d885364e0df7..a315b88bd4c0 100644
--- a/tests/sys/netpfil/pf/pflog.sh
+++ b/tests/sys/netpfil/pf/pflog.sh
@@ -133,6 +133,64 @@ matches_cleanup()
 	pft_cleanup
 }
 
+atf_test_case "matches_logif" "cleanup"
+matches_logif_head()
+{
+	atf_set descr 'Test log(matches, to pflogX)'
+	atf_set require.user root
+}
+
+matches_logif_body()
+{
+	pflog_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 check
+	atf_check -s exit:0 -o ignore \
+	    ping -c 1 192.0.2.1
+
+	jexec alcatraz pfctl -e
+	jexec alcatraz ifconfig pflog0 up
+	jexec alcatraz ifconfig pflog1 create
+	jexec alcatraz ifconfig pflog1 up
+	pft_set_rules alcatraz \
+		"match log(matches, to pflog1) inet proto icmp" \
+		"match log inet from 192.0.2.2" \
+		"pass log(to pflog0)"
+
+	jexec alcatraz tcpdump -n -e -ttt --immediate-mode -l -U -i pflog1 >> ${PWD}/pflog1.txt &
+	jexec alcatraz tcpdump -n -e -ttt --immediate-mode -l -U -i pflog0 >> ${PWD}/pflog0.txt &
+	sleep 1 # Wait for tcpdump to start
+
+	atf_check -s exit:0 -o ignore \
+	    ping -c 1 192.0.2.1
+
+	echo "Rules"
+	jexec alcatraz pfctl -sr -vv
+	echo "States"
+	jexec alcatraz pfctl -ss -vv
+	echo "Log 0"
+	cat ${PWD}/pflog0.txt
+	echo "Log 1"
+	cat ${PWD}/pflog1.txt
+
+	atf_check -o match:".*rule 0/0\(match\): match in on ${epair}a: 192.0.2.2 > 192.0.2.1: ICMP echo request.*" \
+	    cat pflog1.txt
+	atf_check -o match:".*rule 1/0\(match\): match in on ${epair}a: 192.0.2.2 > 192.0.2.1: ICMP echo request.*" \
+	    cat pflog1.txt
+}
+
+matches_logif_cleanup()
+{
+	pft_cleanup
+}
+
 atf_test_case "state_max" "cleanup"
 state_max_head()
 {
@@ -326,8 +384,9 @@ atf_init_test_cases()
 {
 	atf_add_test_case "malformed"
 	atf_add_test_case "matches"
-	atf_add_test_case "rdr_action"
+	atf_add_test_case "matches_logif"
 	atf_add_test_case "state_max"
 	atf_add_test_case "unspecified_v4"
 	atf_add_test_case "unspecified_v6"
+	atf_add_test_case "rdr_action"
 }



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