Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Jan 2024 08:52:06 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: d086b9f77c3f - main - pf tests: test per-rule pflow
Message-ID:  <202401160852.40G8q6rp077488@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=d086b9f77c3f72fc5e38a2a180ef53cd82b57f2f

commit d086b9f77c3f72fc5e38a2a180ef53cd82b57f2f
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2024-01-11 13:54:09 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2024-01-16 08:45:55 +0000

    pf tests: test per-rule pflow
    
    Test that we can enable pflow on a per-rule basis.
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 tests/sys/netpfil/pf/pflow.sh | 49 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/tests/sys/netpfil/pf/pflow.sh b/tests/sys/netpfil/pf/pflow.sh
index 88478cfbfe84..3cef5f5a2d98 100644
--- a/tests/sys/netpfil/pf/pflow.sh
+++ b/tests/sys/netpfil/pf/pflow.sh
@@ -234,10 +234,59 @@ nat_cleanup()
 	pft_cleanup
 }
 
+atf_test_case "rule" "cleanup"
+rule_head()
+{
+	atf_set descr 'Test per-rule pflow option'
+	atf_set require.user root
+	atf_set require.progs scapy
+}
+
+rule_body()
+{
+	pflow_init
+
+	epair=$(vnet_mkepair)
+	ifconfig ${epair}a 192.0.2.2/24 up
+	ifconfig ${epair}a alias 192.0.2.3/24 up
+
+	vnet_mkjail alcatraz ${epair}b
+	jexec alcatraz ifconfig ${epair}b 192.0.2.1/24 up
+
+	# Sanity check
+	atf_check -s exit:0 -o ignore ping -c 1 192.0.2.1
+
+	jexec alcatraz pfctl -e
+	pft_set_rules alcatraz \
+		"pass in from 192.0.2.2 keep state (pflow)" \
+		"pass in from 192.0.2.3 keep state"
+
+	pflow=$(jexec alcatraz pflowctl -c)
+	jexec alcatraz pflowctl -s ${pflow} dst 192.0.2.2:2055
+
+	# No flow is generated if we ping from 192.0.2.3
+	ping -c 1 -S 192.0.2.3 192.0.2.1
+
+	atf_check -o match:"No data" \
+	    $(atf_get_srcdir)/pft_read_ipfix.py --recvif ${epair}a --port 2055
+
+	# But there is one if we ping from 192.0.2.2
+	ping -c 1 -S 192.0.2.2 192.0.2.1
+
+	atf_check -o match:".*v=5.*" \
+	    $(atf_get_srcdir)/pft_read_ipfix.py --recvif ${epair}a --port 2055
+}
+
+rule_cleanup()
+{
+	pft_cleanup
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case "basic"
 	atf_add_test_case "state_defaults"
 	atf_add_test_case "v6"
 	atf_add_test_case "nat"
+	atf_add_test_case "rule"
 }



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