git: d5a0bf4517c0 - main - pf tests: test wildcard anchors
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 06 Sep 2022 11:19:45 UTC
The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=d5a0bf4517c053803b266742d16be456c5393ae7 commit d5a0bf4517c053803b266742d16be456c5393ae7 Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2022-08-31 13:40:33 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2022-09-06 08:42:09 +0000 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 --- tests/sys/netpfil/pf/anchor.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/sys/netpfil/pf/anchor.sh b/tests/sys/netpfil/pf/anchor.sh index 4fd3697155d9..27903d469507 100644 --- a/tests/sys/netpfil/pf/anchor.sh +++ b/tests/sys/netpfil/pf/anchor.sh @@ -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" }