pf tests: test wildcard anchors

Ensure that a wildcard anchor actually includes any nested anchors (i.e.
foo/* will call into foo/bar).

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D36414
This commit is contained in:
Kristof Provost 2022-08-31 15:40:33 +02:00
parent b323fa85f1
commit d5a0bf4517

View File

@ -93,8 +93,47 @@ nested_anchor_cleanup()
pft_cleanup
}
atf_test_case "wildcard" "cleanup"
wildcard_head()
{
atf_set descr 'Test wildcard anchors for functionality'
atf_set require.user root
}
wildcard_body()
{
pft_init
epair=$(vnet_mkepair)
vnet_mkjail alcatraz ${epair}a
ifconfig ${epair}b 192.0.2.2/24 up
jexec alcatraz ifconfig ${epair}a 192.0.2.1/24 up
# Sanity check
atf_check -s exit:0 -o ignore ping -c 1 192.0.2.1
jexec alcatraz pfctl -e
pft_set_rules alcatraz \
"block" \
"anchor \"foo/*\""
atf_check -s exit:2 -o ignore ping -c 1 192.0.2.1
echo "pass" | jexec alcatraz pfctl -g -f - -a "foo/bar"
jexec alcatraz pfctl -sr -a "*"
atf_check -s exit:0 -o ignore ping -c 1 192.0.2.1
}
wildcard_cleanup()
{
pft_cleanup
}
atf_init_test_cases()
{
atf_add_test_case "pr183198"
atf_add_test_case "nested_anchor"
atf_add_test_case "wildcard"
}