Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Oct 2021 08:47:32 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: 18fe461d67c7 - stable/12 - pf tests: Basic syncookie test
Message-ID:  <202110060847.1968lWPI060925@gitrepo.freebsd.org>

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

URL: https://cgit.FreeBSD.org/src/commit/?id=18fe461d67c7626a266369cbdb862de986a85d5b

commit 18fe461d67c7626a266369cbdb862de986a85d5b
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2021-07-10 11:20:44 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2021-10-06 08:46:58 +0000

    pf tests: Basic syncookie test
    
    MFC after:      1 week
    Sponsored by:   Modirum MDPay
    Differential Revision:  https://reviews.freebsd.org/D32138
    
    (cherry picked from commit dc0636636bb1937283d4f218732ac2357f4ec4f1)
---
 tests/sys/netpfil/pf/syncookie.sh | 43 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/tests/sys/netpfil/pf/syncookie.sh b/tests/sys/netpfil/pf/syncookie.sh
index 49acd9fab11d..8a4005d0fc6d 100644
--- a/tests/sys/netpfil/pf/syncookie.sh
+++ b/tests/sys/netpfil/pf/syncookie.sh
@@ -29,6 +29,48 @@
 
 common_dir=$(atf_get_srcdir)/../common
 
+atf_test_case "basic" "cleanup"
+basic_head()
+{
+	atf_set descr 'Basic syncookie test'
+	atf_set require.user root
+}
+
+basic_body()
+{
+	pft_init
+
+	epair=$(vnet_mkepair)
+
+	vnet_mkjail alcatraz ${epair}b
+	jexec alcatraz ifconfig ${epair}b 192.0.2.1/24 up
+	jexec alcatraz /usr/sbin/inetd -p inetd-alcatraz.pid \
+	    $(atf_get_srcdir)/echo_inetd.conf
+
+	ifconfig ${epair}a 192.0.2.2/24 up
+
+	jexec alcatraz pfctl -e
+	pft_set_rules alcatraz \
+		"set syncookies always" \
+		"pass in" \
+		"pass out"
+
+	# Sanity check
+	atf_check -s exit:0 -o ignore ping -c 1 192.0.2.1
+
+	reply=$(echo foo | nc -N -w 5 192.0.2.1 7)
+	if [ "${reply}" != "foo" ];
+	then
+		atf_fail "Failed to connect to syncookie protected echo daemon"
+	fi
+}
+
+basic_cleanup()
+{
+	rm -f inetd-alcatraz.pid
+	pft_cleanup
+}
+
 atf_test_case "forward" "cleanup"
 forward_head()
 {
@@ -128,6 +170,7 @@ nostate_cleanup()
 
 atf_init_test_cases()
 {
+	atf_add_test_case "basic"
 	atf_add_test_case "forward"
 	atf_add_test_case "nostate"
 }



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