From owner-dev-commits-src-all@freebsd.org Fri May 14 13:06:57 2021 Return-Path: Delivered-To: dev-commits-src-all@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 BB84E647645; Fri, 14 May 2021 13:06:56 +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 4FhTM35M3yz3kyp; Fri, 14 May 2021 13:06:54 +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 C10B212AEB; Fri, 14 May 2021 13:06:54 +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 14ED6sVt052739; Fri, 14 May 2021 13:06:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ED6sdT052738; Fri, 14 May 2021 13:06:54 GMT (envelope-from git) Date: Fri, 14 May 2021 13:06:54 GMT Message-Id: <202105141306.14ED6sdT052738@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: 147c64747203 - stable/12 - pf tests: Test killing matching states 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/12 X-Git-Reftype: branch X-Git-Commit: 147c64747203053e55a28a4c5d7515f4d7cbce82 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:57 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=147c64747203053e55a28a4c5d7515f4d7cbce82 commit 147c64747203053e55a28a4c5d7515f4d7cbce82 Author: Kristof Provost AuthorDate: 2021-05-03 13:31:03 +0000 Commit: Kristof Provost CommitDate: 2021-05-14 08:48:52 +0000 pf tests: Test killing matching states MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30093 (cherry picked from commit ac200a9c3847d3a92c347de60e32a7af430dede6) --- tests/sys/netpfil/pf/killstate.sh | 71 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/tests/sys/netpfil/pf/killstate.sh b/tests/sys/netpfil/pf/killstate.sh index ae0a4b88b228..131b6268daf7 100644 --- a/tests/sys/netpfil/pf/killstate.sh +++ b/tests/sys/netpfil/pf/killstate.sh @@ -305,10 +305,81 @@ gateway_cleanup() pft_cleanup } +atf_test_case "match" "cleanup" +match_head() +{ + atf_set descr 'Test killing matching states' + atf_set require.user root +} + +match_body() +{ + pft_init + + epair_one=$(vnet_mkepair) + ifconfig ${epair_one}a 192.0.2.1/24 up + + epair_two=$(vnet_mkepair) + + vnet_mkjail alcatraz ${epair_one}b ${epair_two}a + jexec alcatraz ifconfig ${epair_one}b 192.0.2.2/24 up + jexec alcatraz ifconfig ${epair_two}a 198.51.100.1/24 up + jexec alcatraz sysctl net.inet.ip.forwarding=1 + jexec alcatraz pfctl -e + + vnet_mkjail singsing ${epair_two}b + jexec singsing ifconfig ${epair_two}b 198.51.100.2/24 up + jexec singsing route add default 198.51.100.1 + jexec singsing /usr/sbin/inetd -p inetd-echo.pid \ + $(atf_get_srcdir)/echo_inetd.conf + + route add 198.51.100.0/24 192.0.2.2 + + pft_set_rules alcatraz \ + "nat on ${epair_two}a from 192.0.2.0/24 -> (${epair_two}a)" \ + "pass all" + + nc 198.51.100.2 7 & + + # Expect two states + states=$(jexec alcatraz pfctl -s s | wc -l) + if [ $states -ne 2 ] ; + then + atf_fail "Expected two states, found $states" + fi + + # If we don't kill the matching NAT state one should be left + jexec alcatraz pfctl -k 192.0.2.1 + states=$(jexec alcatraz pfctl -s s | wc -l) + if [ $states -ne 1 ] ; + then + atf_fail "Expected one states, found $states" + fi + + # Flush + jexec alcatraz pfctl -F states + + nc 198.51.100.2 7 & + + # Kill matching states, expect all of them to be gone + jexec alcatraz pfctl -M -k 192.0.2.1 + states=$(jexec alcatraz pfctl -s s | wc -l) + if [ $states -ne 0 ] ; + then + atf_fail "Expected zero states, found $states" + fi +} + +match_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "v4" atf_add_test_case "label" atf_add_test_case "multilabel" atf_add_test_case "gateway" + atf_add_test_case "match" }