diff --git a/tests/sys/netpfil/pf/ether.sh b/tests/sys/netpfil/pf/ether.sh --- a/tests/sys/netpfil/pf/ether.sh +++ b/tests/sys/netpfil/pf/ether.sh @@ -27,6 +27,8 @@ . $(atf_get_srcdir)/utils.subr +common_dir=$(atf_get_srcdir)/../common + atf_test_case "mac" "cleanup" mac_head() { @@ -680,6 +682,54 @@ pft_cleanup } +atf_test_case "bridge_to" "cleanup" +bridge_to_head() +{ + atf_set descr 'Test bridge-to keyword' + atf_set require.user root + atf_set require.progs scapy +} + +bridge_to_body() +{ + pft_init + + epair_in=$(vnet_mkepair) + epair_out=$(vnet_mkepair) + + ifconfig ${epair_in}a 192.0.2.1/24 up + ifconfig ${epair_out}a up + + vnet_mkjail alcatraz ${epair_in}b ${epair_out}b + jexec alcatraz ifconfig ${epair_in}b 192.0.2.2/24 up + jexec alcatraz ifconfig ${epair_out}b up + + # Sanity check + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 + atf_check -s exit:1 -o ignore \ + ${common_dir}/pft_ping.py \ + --sendif ${epair_in}a \ + --to 192.0.2.2 \ + --recvif ${epair_out}a + + jexec alcatraz pfctl -e + pft_set_rules alcatraz \ + "ether pass in on ${epair_in}b bridge-to ${epair_out}b" + + # Now the packets go out epair_out rather than be processed locally + atf_check -s exit:2 -o ignore ping -c 1 192.0.2.2 + atf_check -s exit:0 -o ignore \ + ${common_dir}/pft_ping.py \ + --sendif ${epair_in}a \ + --to 192.0.2.2 \ + --recvif ${epair_out}a +} + +bridge_to_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "mac" @@ -693,4 +743,5 @@ atf_add_test_case "tag" atf_add_test_case "match_tag" atf_add_test_case "short_pkt" + atf_add_test_case "bridge_to" }