git: 27fca15016a9 - main - pf tests: validate ToS translation with nat64

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Tue, 17 Dec 2024 10:08:09 UTC
The branch main has been updated by kp:

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

commit 27fca15016a90f0d044176ba5f8f5b0fa91469ba
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2024-12-02 17:01:42 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2024-12-17 10:07:17 +0000

    pf tests: validate ToS translation with nat64
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 tests/sys/netpfil/pf/nat64.sh | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/tests/sys/netpfil/pf/nat64.sh b/tests/sys/netpfil/pf/nat64.sh
index 9e91e95570c1..c1202dfee2e8 100644
--- a/tests/sys/netpfil/pf/nat64.sh
+++ b/tests/sys/netpfil/pf/nat64.sh
@@ -203,6 +203,38 @@ sctp_cleanup()
 	pft_cleanup
 }
 
+atf_test_case "tos" "cleanup"
+tos_head()
+{
+	atf_set descr 'ToS translation test'
+	atf_set require.user root
+}
+
+tos_body()
+{
+	nat64_setup
+
+	# Ensure we can distinguish ToS on the destination
+	jexec dst pfctl -e
+	pft_set_rules dst \
+	    "pass" \
+	    "block in inet tos 8"
+
+	atf_check -s exit:0 -o ignore \
+	    ping6 -c 1 -z 4 64:ff9b::192.0.2.2
+	atf_check -s exit:2 -o ignore \
+	    ping6 -c 1 -z 8 64:ff9b::192.0.2.2
+	atf_check -s exit:0 -o ignore \
+	    ping6 -c 1 -z 16 64:ff9b::192.0.2.2
+
+	jexec dst pfctl -sr -vv
+}
+
+tos_cleanup()
+{
+	pft_cleanup
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case "icmp_echo"
@@ -210,4 +242,5 @@ atf_init_test_cases()
 	atf_add_test_case "tcp"
 	atf_add_test_case "udp"
 	atf_add_test_case "sctp"
+	atf_add_test_case "tos"
 }