git: a7222b3cc341 - main - pf tests: bridge-to test case
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 02 Nov 2022 14:51:31 UTC
The branch main has been updated by kp:
URL: https://cgit.FreeBSD.org/src/commit/?id=a7222b3cc3417929b520b96672af86a19902d8a9
commit a7222b3cc3417929b520b96672af86a19902d8a9
Author: Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2022-10-28 09:56:43 +0000
Commit: Kristof Provost <kp@FreeBSD.org>
CommitDate: 2022-11-02 14:45:23 +0000
pf tests: bridge-to test case
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D37194
---
tests/sys/netpfil/pf/ether.sh | 51 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
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"
}