git: 734782a7814e - main - pf tests: Test new L3 inspection for pf 'ether' rules
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 14 Mar 2022 21:43:56 UTC
The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=734782a7814e5eb473c97f29eaafc830b47c1d11 commit 734782a7814e5eb473c97f29eaafc830b47c1d11 Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2022-03-08 17:14:39 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2022-03-14 21:43:38 +0000 pf tests: Test new L3 inspection for pf 'ether' rules Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D34483 --- tests/sys/netpfil/pf/ether.sh | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/sys/netpfil/pf/ether.sh b/tests/sys/netpfil/pf/ether.sh index 627d027f33c8..319956219fe4 100644 --- a/tests/sys/netpfil/pf/ether.sh +++ b/tests/sys/netpfil/pf/ether.sh @@ -497,6 +497,50 @@ anchor_cleanup() pft_cleanup } +atf_test_case "ip" "cleanup" +ip_head() +{ + atf_set descr 'Test filtering based on IP source/destination' + atf_set require.user root +} + +ip_body() +{ + pft_init + + epair=$(vnet_mkepair) + + 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 pass" \ + "ether block in l3 from 192.0.2.1" + + atf_check -s exit:2 -o ignore ping -c 1 192.0.2.2 + + # Change IP address and we can ping again + ifconfig ${epair}a 192.0.2.3/24 up + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 + + # Test the 'to' keyword too + pft_set_rules alcatraz \ + "ether pass" \ + "ether block out l3 to 192.0.2.3" + atf_check -s exit:2 -o ignore ping -c 1 192.0.2.2 +} + +ip_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "mac" @@ -506,4 +550,5 @@ atf_init_test_cases() atf_add_test_case "captive_long" atf_add_test_case "dummynet" atf_add_test_case "anchor" + atf_add_test_case "ip" }