Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 May 2021 11:54:54 GMT
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 7bd7933f9a4f - main - pf tests: Test the ability to kill floating states by interface
Message-ID:  <202105201154.14KBssbM056931@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=7bd7933f9a4f1757fdefeee2e1ac8b8c4d299fc3

commit 7bd7933f9a4f1757fdefeee2e1ac8b8c4d299fc3
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2021-05-13 08:04:20 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2021-05-20 10:49:27 +0000

    pf tests: Test the ability to kill floating states by interface
    
    Reviewed by:    eri
    MFC after:      1 week
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D30247
---
 tests/sys/netpfil/pf/killstate.sh | 60 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/tests/sys/netpfil/pf/killstate.sh b/tests/sys/netpfil/pf/killstate.sh
index ec01910f0867..b3d94a245548 100644
--- a/tests/sys/netpfil/pf/killstate.sh
+++ b/tests/sys/netpfil/pf/killstate.sh
@@ -447,6 +447,65 @@ match_cleanup()
 	pft_cleanup
 }
 
+atf_test_case "interface" "cleanup"
+interface_head()
+{
+	atf_set descr 'Test killing states based on interface'
+	atf_set require.user root
+	atf_set require.progs scapy
+}
+
+interface_body()
+{
+	pft_init
+
+	epair=$(vnet_mkepair)
+	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
+	jexec alcatraz pfctl -e
+
+	pft_set_rules alcatraz "block all" \
+		"pass in proto icmp"
+
+	# Sanity check & establish state
+	# Note: use pft_ping so we always use the same ID, so pf considers all
+	# echo requests part of the same flow.
+	atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \
+		--sendif ${epair}a \
+		--to 192.0.2.2 \
+		--replyif ${epair}a
+
+	# Change rules to now deny the ICMP traffic
+	pft_set_rules noflush alcatraz "block all"
+
+	# Established state means we can still ping alcatraz
+	atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \
+		--sendif ${epair}a \
+		--to 192.0.2.2 \
+		--replyif ${epair}a
+
+	# Flushing states on a different interface doesn't affect our state
+	jexec alcatraz pfctl -i ${epair}a -Fs
+	atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \
+		--sendif ${epair}a \
+		--to 192.0.2.2 \
+		--replyif ${epair}a
+
+	# Flushing on the correct interface does (even with floating states)
+	jexec alcatraz pfctl -i ${epair}b -Fs
+	atf_check -s exit:1 -o ignore ${common_dir}/pft_ping.py \
+		--sendif ${epair}a \
+		--to 192.0.2.2 \
+		--replyif ${epair}a
+}
+
+interface_cleanup()
+{
+	pft_cleanup
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case "v4"
@@ -455,4 +514,5 @@ atf_init_test_cases()
 	atf_add_test_case "multilabel"
 	atf_add_test_case "gateway"
 	atf_add_test_case "match"
+	atf_add_test_case "interface"
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105201154.14KBssbM056931>