git: 4ffb7d1300a6 - main - pf tests: Test EtherType filtering
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 02 Mar 2022 16:00:49 UTC
The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=4ffb7d1300a6e4d46ab7fe212509ba32555d1024 commit 4ffb7d1300a6e4d46ab7fe212509ba32555d1024 Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2021-02-10 09:42:06 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2022-03-02 16:00:05 +0000 pf tests: Test EtherType filtering Test filtering packets by their EtherType (i.e. ARP/IPv4/IPv6/...). Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31745 --- tests/sys/netpfil/pf/ether.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/sys/netpfil/pf/ether.sh b/tests/sys/netpfil/pf/ether.sh index 2781dda611e5..273c5654afa5 100644 --- a/tests/sys/netpfil/pf/ether.sh +++ b/tests/sys/netpfil/pf/ether.sh @@ -91,7 +91,50 @@ mac_cleanup() pft_cleanup } +atf_test_case "proto" "cleanup" +proto_head() +{ + atf_set descr 'Test EtherType filtering' + atf_set require.user root +} + +proto_body() +{ + pft_init + + epair=$(vnet_mkepair) + epair_a_mac=$(ifconfig ${epair}a ether | awk '/ether/ { print $2; }') + + ifconfig ${epair}a 192.0.2.1/24 up + + vnet_mkjail alcatraz ${epair}b + jexec alcatraz ifconfig ${epair}b 192.0.2.2/24 up + + pft_set_rules alcatraz \ + "ether block proto 0x0810" + jexec alcatraz pfctl -e + + atf_check -s exit:0 -o ignore ping -c 1 -t 1 192.0.2.2 + + # Block IP + pft_set_rules alcatraz \ + "ether block proto 0x0800" + atf_check -s exit:2 -o ignore ping -c 1 -t 1 192.0.2.2 + + # Block ARP + pft_set_rules alcatraz \ + "ether block proto 0x0806" + arp -d 192.0.2.2 + atf_check -s exit:2 -o ignore ping -c 1 -t 1 192.0.2.2 +} + +proto_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "mac" + atf_add_test_case "proto" }