diff options
author | Kristof Provost <kp@FreeBSD.org> | 2024-12-12 14:35:34 +0000 |
---|---|---|
committer | Kristof Provost <kp@FreeBSD.org> | 2024-12-17 10:07:18 +0000 |
commit | 32cac604487b4c6a8588c5df7641bdb5b452711f (patch) | |
tree | 8d5215835cc16e4a371512c3afbeb3c54cb4bf80 | |
parent | 706b42cc4bd9a255ed920b1a4095856f8df9e52c (diff) |
pf tests: test dummynet on nat64 rules
Sponsored by: Rubicon Communications, LLC ("Netgate")
-rw-r--r-- | tests/sys/netpfil/pf/nat64.sh | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/sys/netpfil/pf/nat64.sh b/tests/sys/netpfil/pf/nat64.sh index 318b6a61bcab..79fa0c99a311 100644 --- a/tests/sys/netpfil/pf/nat64.sh +++ b/tests/sys/netpfil/pf/nat64.sh @@ -555,6 +555,60 @@ table_round_robin_cleanup() pft_cleanup } +atf_test_case "dummynet" "cleanup" +dummynet_head() +{ + atf_set descr 'Test dummynet on af-to rules' + atf_set require.user root +} + +dummynet_body() +{ + pft_init + dummynet_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.1/24 up + + 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 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.1 + + jexec rtr pfctl -e + jexec rtr dnctl pipe 1 config delay 600 + pft_set_rules rtr \ + "set reassemble yes" \ + "set state-policy if-bound" \ + "pass in on ${epair}b inet6 from any to 64:ff9b::/96 dnpipe 1 af-to inet from (${epair_link}a)" + + # The ping request will pass, but take 1.2 seconds (.6 in, .6 out) + # So this works: + atf_check -s exit:0 -o ignore \ + ping6 -c 1 -t 2 64:ff9b::192.0.2.2 + + # But this times out: + atf_check -s exit:2 -o ignore \ + ping6 -c 1 -t 1 64:ff9b::192.0.2.2 +} + +dummynet_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "icmp_echo" @@ -569,4 +623,5 @@ atf_init_test_cases() atf_add_test_case "table" atf_add_test_case "table_range" atf_add_test_case "table_round_robin" + atf_add_test_case "dummynet" } |