From owner-svn-src-head@freebsd.org Sat Jul 14 21:32:33 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8BA09103F03C; Sat, 14 Jul 2018 21:32:33 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 40C108A554; Sat, 14 Jul 2018 21:32:33 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 21FA724894; Sat, 14 Jul 2018 21:32:33 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6ELWXJK079230; Sat, 14 Jul 2018 21:32:33 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6ELWWmX079227; Sat, 14 Jul 2018 21:32:32 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201807142132.w6ELWWmX079227@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Sat, 14 Jul 2018 21:32:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336297 - head/tests/sys/netpfil/pf X-SVN-Group: head X-SVN-Commit-Author: kp X-SVN-Commit-Paths: head/tests/sys/netpfil/pf X-SVN-Commit-Revision: 336297 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jul 2018 21:32:33 -0000 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" +}