From owner-dev-commits-src-branches@freebsd.org Tue Jul 27 11:46:51 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 4F44565DF3D; Tue, 27 Jul 2021 11:46:51 +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 4GYw4V1qT8z3s34; Tue, 27 Jul 2021 11:46:49 +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 A3CC41ADC; Tue, 27 Jul 2021 11:46:49 +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 16RBkn1I067892; Tue, 27 Jul 2021 11:46:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 16RBknSv067891; Tue, 27 Jul 2021 11:46:49 GMT (envelope-from git) Date: Tue, 27 Jul 2021 11:46:49 GMT Message-Id: <202107271146.16RBknSv067891@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: 4aa52f90f71e - stable/13 - pf tests: ensure syncookie does not create state 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: 4aa52f90f71eb7d710da46e587354190d6df5566 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: Tue, 27 Jul 2021 11:46:51 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=4aa52f90f71eb7d710da46e587354190d6df5566 commit 4aa52f90f71eb7d710da46e587354190d6df5566 Author: Kristof Provost AuthorDate: 2021-06-30 13:27:46 +0000 Commit: Kristof Provost CommitDate: 2021-07-27 07:44:06 +0000 pf tests: ensure syncookie does not create state Test that with syncookies enabled pf does not create state for connections before the remote peer has replied to the SYN|ACK message. MFC after: 1 week Sponsored by: Modirum MDPay Differential Revision: https://reviews.freebsd.org/D31142 (cherry picked from commit 27ab791a55191c0b6503391d411303b042b41047) --- tests/sys/netpfil/pf/syncookie.sh | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/sys/netpfil/pf/syncookie.sh b/tests/sys/netpfil/pf/syncookie.sh index 7bd045249be6..49acd9fab11d 100644 --- a/tests/sys/netpfil/pf/syncookie.sh +++ b/tests/sys/netpfil/pf/syncookie.sh @@ -27,6 +27,8 @@ . $(atf_get_srcdir)/utils.subr +common_dir=$(atf_get_srcdir)/../common + atf_test_case "forward" "cleanup" forward_head() { @@ -78,7 +80,54 @@ forward_cleanup() pft_cleanup } +atf_test_case "nostate" "cleanup" +nostate_head() +{ + atf_set descr 'Ensure that we do not create until SYN|ACK' + atf_set require.user root + atf_set require.progs scapy +} + +nostate_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 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 + + # Now syn flood to create many states + ${common_dir}/pft_synflood.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --count 20 + + states=$(jexec alcatraz pfctl -ss | grep tcp) + if [ -n "$states" ]; + then + echo "$states" + atf_fail "Found unexpected state" + fi +} + +nostate_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "forward" + atf_add_test_case "nostate" }