Skip to content

Commit

Permalink
pf tests: dummynet + nat fragmentation test
Browse files Browse the repository at this point in the history
Ensure that we do the right thing when we reassemble fragmented packet
and send it through a dummynet pipe.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
  • Loading branch information
kprovost committed Jan 15, 2024
1 parent 24c0058 commit 3f9a6e0
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/sys/netpfil/pf/fragmentation_pass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,53 @@ dummynet_cleanup()
pft_cleanup
}

atf_test_case "dummynet_nat" "cleanup"
dummynet_nat_head()
{
atf_set descr 'Test dummynet on NATed fragmented traffic'
atf_set require.user root
}

dummynet_nat_body()
{
pft_init
dummynet_init

epair_one=$(vnet_mkepair)
ifconfig ${epair_one}a 192.0.2.1/24 up

epair_two=$(vnet_mkepair)

vnet_mkjail alcatraz ${epair_one}b ${epair_two}a
jexec alcatraz ifconfig ${epair_one}b 192.0.2.2/24 up
jexec alcatraz ifconfig ${epair_two}a 198.51.100.1/24 up
jexec alcatraz sysctl net.inet.ip.forwarding=1

vnet_mkjail singsing ${epair_two}b
jexec singsing ifconfig ${epair_two}b 198.51.100.2/24 up
jexec singsing route add default 198.51.100.1

route add 198.51.100.0/24 192.0.2.2

jexec alcatraz dnctl pipe 1 config bw 1600Byte/s
jexec alcatraz dnctl pipe 2 config bw 1700Byte/s

jexec alcatraz pfctl -e
pft_set_rules alcatraz \
"set reassemble yes" \
"nat on ${epair_two}a from 192.0.2.0/24 -> (${epair_two}a)" \
"block in" \
"pass in inet proto icmp all icmp-type echoreq dnpipe (1, 2)"

atf_check -s exit:0 -o ignore ping -c 1 198.51.100.2
atf_check -s exit:0 -o ignore ping -c 1 -s 2000 198.51.100.2
}

dummynet_nat_cleanup()
{
pft_cleanup
}

atf_init_test_cases()
{
atf_add_test_case "too_many_fragments"
Expand All @@ -518,4 +565,5 @@ atf_init_test_cases()
atf_add_test_case "no_df"
atf_add_test_case "reassemble_slowpath"
atf_add_test_case "dummynet"
atf_add_test_case "dummynet_nat"
}

0 comments on commit 3f9a6e0

Please sign in to comment.