aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristof Provost <kp@FreeBSD.org>2024-12-05 17:23:29 +0000
committerKristof Provost <kp@FreeBSD.org>2024-12-17 10:07:17 +0000
commit125e395278cf01811a06bb7fdb2dce6854eafc3c (patch)
tree0247fc997e5c01a5e4fe16b2b51e34df3b433535
parent27fca15016a90f0d044176ba5f8f5b0fa91469ba (diff)
pf tests: test not having an IPv4 address to nat64 to
This isn't expected to work, for obvious reasons, but we also expect to not panic doing this. Exercise this special case. Sponsored by: Rubicon Communications, LLC ("Netgate")
-rw-r--r--tests/sys/netpfil/pf/nat64.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/sys/netpfil/pf/nat64.sh b/tests/sys/netpfil/pf/nat64.sh
index c1202dfee2e8..809d058d34c9 100644
--- a/tests/sys/netpfil/pf/nat64.sh
+++ b/tests/sys/netpfil/pf/nat64.sh
@@ -235,6 +235,46 @@ tos_cleanup()
pft_cleanup
}
+atf_test_case "no_v4" "cleanup"
+no_v4_head()
+{
+ atf_set descr 'Test error handling when there is no IPv4 address to translate to'
+ atf_set require.user root
+}
+
+no_v4_body()
+{
+ pft_init
+
+ epair_link=$(vnet_mkepair)
+ epair=$(vnet_mkepair)
+
+ ifconfig ${epair}a inet6 2001:db8::2/64 up no_dad
+ route -6 add default 2001:db8::1
+
+ vnet_mkjail rtr ${epair}b ${epair_link}a
+ jexec rtr ifconfig ${epair}b inet6 2001:db8::1/64 up no_dad
+
+ vnet_mkjail dst ${epair_link}b
+ jexec dst ifconfig ${epair_link}b 192.0.2.2/24 up
+ jexec dst route add default 192.0.2.1
+
+ # Sanity check
+ atf_check -s exit:0 -o ignore \
+ ping6 -c 1 2001:db8::1
+
+ jexec rtr pfctl -e
+ pft_set_rules rtr \
+ "pass in on ${epair}b inet6 from any to 64:ff9b::/96 af-to inet from (${epair_link}a)"
+
+ atf_check -s exit:2 -o ignore \
+ ping6 -c 3 64:ff9b::192.0.2.2
+}
+
+no_v4_cleanup()
+{
+ pft_cleanup
+}
atf_init_test_cases()
{
atf_add_test_case "icmp_echo"
@@ -243,4 +283,5 @@ atf_init_test_cases()
atf_add_test_case "udp"
atf_add_test_case "sctp"
atf_add_test_case "tos"
+ atf_add_test_case "no_v4"
}