From owner-dev-commits-src-branches@freebsd.org Fri Sep 17 17:53:53 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7E2DF6B6EB1; Fri, 17 Sep 2021 17:53:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HB1m12rjSz4mgV; Fri, 17 Sep 2021 17:53:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4336319C3B; Fri, 17 Sep 2021 17:53:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 18HHrrkg061088; Fri, 17 Sep 2021 17:53:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 18HHrri9061087; Fri, 17 Sep 2021 17:53:53 GMT (envelope-from git) Date: Fri, 17 Sep 2021 17:53:53 GMT Message-Id: <202109171753.18HHrri9061087@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 2134d9f05faa - stable/13 - pf tests: synproxy to localhost test MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2134d9f05faaa5c9a8980b13701c1e4a7037856c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Sep 2021 17:53:53 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=2134d9f05faaa5c9a8980b13701c1e4a7037856c commit 2134d9f05faaa5c9a8980b13701c1e4a7037856c Author: Kristof Provost AuthorDate: 2021-06-30 12:22:27 +0000 Commit: Kristof Provost CommitDate: 2021-09-17 15:55:40 +0000 pf tests: synproxy to localhost test Test syn-proxying a connection to the local host. Sponsored by: Modirum MDPay MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31854 (cherry picked from commit 6598cababf6425181a755ec97c3fa66d7ee31393) --- tests/sys/netpfil/pf/synproxy.sh | 83 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/tests/sys/netpfil/pf/synproxy.sh b/tests/sys/netpfil/pf/synproxy.sh index aedbb8885129..a111f40cfbcf 100644 --- a/tests/sys/netpfil/pf/synproxy.sh +++ b/tests/sys/netpfil/pf/synproxy.sh @@ -79,7 +79,90 @@ synproxy_cleanup() pft_cleanup } +atf_test_case "local" "cleanup" +local_head() +{ + atf_set descr 'Synproxy a locally terminated connection' + atf_set require.user root +} + +local_body() +{ + pft_init + + epair=$(vnet_mkepair) + ifconfig ${epair}a 192.0.2.2/24 up + + 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 + + jexec alcatraz pfctl -e + pft_set_rules alcatraz "set fail-policy return" \ + "scrub in all fragment reassemble" \ + "pass in quick on ${epair}b proto tcp from any to any port 7 synproxy state" + + # Sanity check + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.1 + + # Check that we can talk to the jail, after synproxying + reply=$(echo ping | nc -N -w 5 192.0.2.1 7) + if [ "${reply}" != "ping" ]; + then + atf_fail "echo failed" + fi +} + +local_cleanup() +{ + rm -f inetd-alcatraz.pid + pft_cleanup +} + +atf_test_case "local_v6" "cleanup" +local_v6_head() +{ + atf_set descr 'Synproxy (v6) a locally terminated connection' + atf_set require.user root +} + +local_v6_body() +{ + pft_init + + epair=$(vnet_mkepair) + ifconfig ${epair}a inet6 2001:db8:42::1/64 up + + vnet_mkjail alcatraz ${epair}b + jexec alcatraz ifconfig ${epair}b inet6 2001:db8:42::2/64 up + jexec alcatraz /usr/sbin/inetd -p inetd-alcatraz.pid \ + $(atf_get_srcdir)/echo_inetd.conf + + jexec alcatraz pfctl -e + pft_set_rules alcatraz "set fail-policy return" \ + "scrub in all fragment reassemble" \ + "pass in quick on ${epair}b proto tcp from any to any port 7 synproxy state" + + # Sanity check + atf_check -s exit:0 -o ignore ping6 -c 1 2001:db8:42::2 + + reply=$(echo ping | nc -N -w 5 2001:db8:42::2 7) + if [ "${reply}" != "ping" ]; + then + atf_fail "echo failed" + fi +} + +local_v6_cleanup() +{ + rm -f inetd-alcatraz.pid + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "synproxy" + atf_add_test_case "local" + atf_add_test_case "local_v6" }