diff options
author | Kristof Provost <kp@FreeBSD.org> | 2022-10-28 09:56:43 +0000 |
---|---|---|
committer | Kristof Provost <kp@FreeBSD.org> | 2022-11-02 14:45:23 +0000 |
commit | a7222b3cc3417929b520b96672af86a19902d8a9 (patch) | |
tree | 4181287509a602288863ec6baaf9e3b1b4163af5 /tests/sys/netpfil | |
parent | 8a8af94240084a091a1c048da027f80ee37937e7 (diff) | |
download | src-a7222b3cc3417929b520b96672af86a19902d8a9.tar.gz src-a7222b3cc3417929b520b96672af86a19902d8a9.zip |
pf tests: bridge-to test case
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D37194
Diffstat (limited to 'tests/sys/netpfil')
-rw-r--r-- | tests/sys/netpfil/pf/ether.sh | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/sys/netpfil/pf/ether.sh b/tests/sys/netpfil/pf/ether.sh index 63ca9080cbd2..9db1528b6df7 100644 --- 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 @@ short_pkt_cleanup() 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_init_test_cases() atf_add_test_case "tag" atf_add_test_case "match_tag" atf_add_test_case "short_pkt" + atf_add_test_case "bridge_to" } |