git: d1702bd1c3a7 - main - pf tests: basic test for ether anchors
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 02 Mar 2022 16:01:02 UTC
The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=d1702bd1c3a732c6b8ba85a91c3af64a059439a4 commit d1702bd1c3a732c6b8ba85a91c3af64a059439a4 Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2021-10-12 09:27:55 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2022-03-02 16:00:07 +0000 pf tests: basic test for ether anchors Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D32483 --- tests/sys/netpfil/pf/ether.sh | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/sys/netpfil/pf/ether.sh b/tests/sys/netpfil/pf/ether.sh index 8ca8d3fbf0c8..998badad91f1 100644 --- a/tests/sys/netpfil/pf/ether.sh +++ b/tests/sys/netpfil/pf/ether.sh @@ -339,6 +339,65 @@ dummynet_cleanup() pft_cleanup } +atf_test_case "anchor" "cleanup" +anchor_head() +{ + atf_set descr 'Test ether anchors' + atf_set require.user root +} + +anchor_body() +{ + pft_init + + epair=$(vnet_mkepair) + epair_a_mac=$(ifconfig ${epair}a ether | awk '/ether/ { print $2; }') + + vnet_mkjail alcatraz ${epair}b + + ifconfig ${epair}a 192.0.2.1/24 up + jexec alcatraz ifconfig ${epair}b 192.0.2.2/24 up + + # Sanity check + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 + + jexec alcatraz pfctl -e + pft_set_rules alcatraz \ + "ether anchor \"foo\" in on lo0 {" \ + "ether block" \ + "}" + + # That only filters on lo0, so we should still be able to pass traffic + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 + + pft_set_rules alcatraz \ + "ether block in" \ + "ether anchor \"foo\" in on ${epair}b {" \ + "ether pass" \ + "}" + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 + + pft_set_rules alcatraz \ + "ether pass" \ + "ether anchor \"bar\" in on ${epair}b {" \ + "ether block" \ + "}" + atf_check -s exit:2 -o ignore ping -c 1 -t 2 192.0.2.2 + + pft_set_rules alcatraz \ + "ether block in" \ + "ether anchor \"baz\" on ${epair}b {" \ + "ether pass in from 01:02:03:04:05:06" \ + "}" \ + "ether pass in from ${epair_a_mac}" + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 +} + +anchor_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "mac" @@ -346,4 +405,5 @@ atf_init_test_cases() atf_add_test_case "direction" atf_add_test_case "captive" atf_add_test_case "dummynet" + atf_add_test_case "anchor" }