Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Jul 2018 21:32:32 +0000 (UTC)
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r336297 - head/tests/sys/netpfil/pf
Message-ID:  <201807142132.w6ELWWmX079227@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kp
Date: Sat Jul 14 21:32:32 2018
New Revision: 336297
URL: https://svnweb.freebsd.org/changeset/base/336297

Log:
  pf tests: Basic synproxy test
  
  A very basic syncproxy test: set up a connection via a synproxy rule.
  This triggeres the panic fixed in r336273.

Added:
  head/tests/sys/netpfil/pf/echo_inetd.conf   (contents, props changed)
  head/tests/sys/netpfil/pf/synproxy.sh   (contents, props changed)
Modified:
  head/tests/sys/netpfil/pf/Makefile

Modified: head/tests/sys/netpfil/pf/Makefile
==============================================================================
--- head/tests/sys/netpfil/pf/Makefile	Sat Jul 14 20:44:25 2018	(r336296)
+++ head/tests/sys/netpfil/pf/Makefile	Sat Jul 14 21:32:32 2018	(r336297)
@@ -9,9 +9,11 @@ ATF_TESTS_SH+=	pass_block \
 		forward \
 		fragmentation \
 		set_tos \
-		route_to
+		route_to \
+		synproxy
 
 ${PACKAGE}FILES+=	utils.subr \
+			echo_inetd.conf \
 			pft_ping.py
 
 ${PACKAGE}FILESMODE_pft_ping.py=	0555

Added: head/tests/sys/netpfil/pf/echo_inetd.conf
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tests/sys/netpfil/pf/echo_inetd.conf	Sat Jul 14 21:32:32 2018	(r336297)
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+echo   stream  tcp     nowait  root    internal
+echo   stream  tcp6    nowait  root    internal
+echo   dgram   udp     wait    root    internal
+echo   dgram   udp6    wait    root    internal

Added: head/tests/sys/netpfil/pf/synproxy.sh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tests/sys/netpfil/pf/synproxy.sh	Sat Jul 14 21:32:32 2018	(r336297)
@@ -0,0 +1,59 @@
+# $FreeBSD$
+
+. $(atf_get_srcdir)/utils.subr
+
+atf_test_case "synproxy" "cleanup"
+synproxy_head()
+{
+	atf_set descr 'Basic synproxy test'
+	atf_set require.user root
+}
+
+synproxy_body()
+{
+	pft_init
+
+	epair=$(pft_mkepair)
+	ifconfig ${epair}a 192.0.2.1/24 up
+	route add -net 198.51.100.0/24 192.0.2.2
+
+	link=$(pft_mkepair)
+
+	pft_mkjail alcatraz ${epair}b ${link}a
+	jexec alcatraz ifconfig ${epair}b 192.0.2.2/24 up
+	jexec alcatraz ifconfig ${link}a 198.51.100.1/24 up
+	jexec alcatraz sysctl net.inet.ip.forwarding=1
+
+	pft_mkjail singsing ${link}b
+	jexec singsing ifconfig ${link}b 198.51.100.2/24 up
+	jexec singsing route add default 198.51.100.1
+
+	jexec singsing /usr/sbin/inetd $(atf_get_srcdir)/echo_inetd.conf
+
+	jexec alcatraz pfctl -e
+	pft_set_rules alcatraz "set fail-policy return" \
+		"scrub in all fragment reassemble" \
+		"pass out quick on ${epair}b all no state allow-opts" \
+		"pass in quick on ${epair}b proto tcp from any to any port 7 synproxy state" \
+		"pass in quick on ${epair}b all no state"
+
+	# Sanity check, can we ping singing
+	atf_check -s exit:0 -o ignore ping -c 1 198.51.100.2
+
+	# Check that we can talk to the singsing jail, after synproxying
+	reply=$(echo ping | nc -N 198.51.100.2 7)
+	if [ "${reply}" != "ping" ];
+	then
+		atf_fail "echo failed"
+	fi
+}
+
+synproxy_cleanup()
+{
+	pft_cleanup
+}
+
+atf_init_test_cases()
+{
+	atf_add_test_case "synproxy"
+}



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