Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 May 2021 10:20:31 GMT
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 3c790f9e1d54 - stable/13 - pf tests: Test the ability to kill floating states by interface
Message-ID:  <202105271020.14RAKVjg055517@gitrepo.freebsd.org>

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

URL: https://cgit.FreeBSD.org/src/commit/?id=3c790f9e1d54ed57f09358216464ec80cab8f131

commit 3c790f9e1d54ed57f09358216464ec80cab8f131
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2021-05-13 08:04:20 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2021-05-27 07:09:40 +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
    
    (cherry picked from commit 7bd7933f9a4f1757fdefeee2e1ac8b8c4d299fc3)
---
 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?202105271020.14RAKVjg055517>