aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristof Provost <kp@FreeBSD.org>2024-12-11 14:09:34 +0000
committerKristof Provost <kp@FreeBSD.org>2024-12-17 10:07:18 +0000
commit7f3d159b9ff2b594778e9180fb7910721495a24f (patch)
tree787818ed56dd8d2cf002fcc8a1822b5deff7b1f4
parentbdb583afa1980b5479836a4b6d2977da1648cd69 (diff)
pf tests: test using an address range inside a table for nat64
Sponsored by: Rubicon Communications, LLC ("Netgate")
-rw-r--r--tests/sys/netpfil/pf/nat64.sh63
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/sys/netpfil/pf/nat64.sh b/tests/sys/netpfil/pf/nat64.sh
index 3091213baa0c..318b6a61bcab 100644
--- a/tests/sys/netpfil/pf/nat64.sh
+++ b/tests/sys/netpfil/pf/nat64.sh
@@ -427,6 +427,68 @@ table_cleanup()
{
pft_cleanup
}
+
+atf_test_case "table_range" "cleanup"
+table_range_head()
+{
+ atf_set descr 'Test using an address range within a table for the IPv4 side'
+ atf_set require.user root
+}
+
+table_range_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
+ jexec rtr ifconfig ${epair_link}a 192.0.2.2/24 up
+ jexec rtr ifconfig ${epair_link}a inet alias 192.0.2.3/24 up
+
+ vnet_mkjail dst ${epair_link}b
+ jexec dst ifconfig ${epair_link}b 192.0.2.254/24 up
+ jexec dst route add default 192.0.2.2
+
+ # Sanity checks
+ atf_check -s exit:0 -o ignore \
+ ping6 -c 1 2001:db8::1
+ atf_check -s exit:0 -o ignore \
+ jexec dst ping -c 1 192.0.2.2
+
+ jexec rtr pfctl -e
+ pft_set_rules rtr \
+ "set reassemble yes" \
+ "set state-policy if-bound" \
+ "table <wanaddrs> { 192.0.2.2/31 }" \
+ "pass in on ${epair}b inet6 from any to 64:ff9b::/96 af-to inet from <wanaddrs> round-robin"
+
+ # Use pf to count sources
+ jexec dst pfctl -e
+ pft_set_rules dst \
+ "pass"
+
+ atf_check -s exit:0 -o ignore \
+ ping6 -c 1 64:ff9b::192.0.2.254
+ atf_check -s exit:0 -o ignore \
+ ping6 -c 1 64:ff9b::192.0.2.254
+
+ # Verify on dst that we saw different source addresses
+ atf_check -s exit:0 -o match:".*192.0.2.2.*" \
+ jexec dst pfctl -ss
+ atf_check -s exit:0 -o match:".*192.0.2.3.*" \
+ jexec dst pfctl -ss
+}
+
+table_range_cleanup()
+{
+ pft_cleanup
+}
+
atf_test_case "table_round_robin" "cleanup"
table_round_robin_head()
{
@@ -505,5 +567,6 @@ atf_init_test_cases()
atf_add_test_case "range"
atf_add_test_case "pool"
atf_add_test_case "table"
+ atf_add_test_case "table_range"
atf_add_test_case "table_round_robin"
}