git: 34276498fae8 - main - pf tests: verify pflow over IPv6

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Tue, 16 Jan 2024 08:52:02 UTC
The branch main has been updated by kp:

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

commit 34276498fae8b41ca1d8944d466cd79aa47fadfb
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2023-12-13 17:12:08 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2024-01-16 08:45:55 +0000

    pf tests: verify pflow over IPv6
    
    Test that we can send netflow information over IPv6.
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D43115
---
 tests/sys/netpfil/pf/pflow.sh | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/tests/sys/netpfil/pf/pflow.sh b/tests/sys/netpfil/pf/pflow.sh
index 12d194d84c14..4bed49ef6f76 100644
--- a/tests/sys/netpfil/pf/pflow.sh
+++ b/tests/sys/netpfil/pf/pflow.sh
@@ -141,8 +141,51 @@ state_defaults_cleanup()
 	pft_cleanup
 }
 
+atf_test_case "v6" "cleanup"
+v6_head()
+{
+	atf_set descr 'Test pflow over IPv6'
+	atf_set require.user root
+	atf_set require.progs scapy
+}
+
+v6_body()
+{
+	pflow_init
+
+	epair=$(vnet_mkepair)
+	ifconfig ${epair}a inet6 2001:db8::2/64 up no_dad
+
+	vnet_mkjail alcatraz ${epair}b
+	jexec alcatraz ifconfig ${epair}b inet6 2001:db8::1/64 up no_dad
+
+	# Sanity check
+	atf_check -s exit:0 -o ignore \
+	    ping -6 -c 1 2001:db8::1
+
+	pflow=$(jexec alcatraz pflowctl -c )
+	# Note proto 10, because there's no IPv6 information in v5
+	jexec alcatraz pflowctl -s ${pflow} dst [2001:db8::2]:2055 proto 10
+
+	jexec alcatraz pfctl -e
+	pft_set_rules alcatraz \
+		"set state-defaults pflow" \
+		"pass"
+
+	ping -6 -c 1 2001:db8::1
+
+	atf_check -o match:"^v=10.*" \
+	    $(atf_get_srcdir)/pft_read_ipfix.py --recvif ${epair}a --port 2055
+}
+
+v6_cleanup()
+{
+	pft_cleanup
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case "basic"
 	atf_add_test_case "state_defaults"
+	atf_add_test_case "v6"
 }