From owner-dev-commits-src-main@freebsd.org Wed Sep 29 13:42:35 2021 Return-Path: Delivered-To: dev-commits-src-main@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 EC4636742CF; Wed, 29 Sep 2021 13:42:35 +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 4HKHcW3BqBz3lq3; Wed, 29 Sep 2021 13:42:35 +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 1F89919405; Wed, 29 Sep 2021 13:42:35 +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 18TDgZMd001232; Wed, 29 Sep 2021 13:42:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 18TDgZxO001231; Wed, 29 Sep 2021 13:42:35 GMT (envelope-from git) Date: Wed, 29 Sep 2021 13:42:35 GMT Message-Id: <202109291342.18TDgZxO001231@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 2f20d80692ce - main - pf tests: Basic adaptive mode syncookie 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/main X-Git-Reftype: branch X-Git-Commit: 2f20d80692ceb584842a7642562fc9f610a5b661 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Sep 2021 13:42:36 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=2f20d80692ceb584842a7642562fc9f610a5b661 commit 2f20d80692ceb584842a7642562fc9f610a5b661 Author: Kristof Provost AuthorDate: 2021-09-25 13:05:02 +0000 Commit: Kristof Provost CommitDate: 2021-09-29 13:42:01 +0000 pf tests: Basic adaptive mode syncookie test MFC after: 1 week Sponsored by: Modirum MDPay Differential Revision: https://reviews.freebsd.org/D32139 --- tests/sys/netpfil/pf/syncookie.sh | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/sys/netpfil/pf/syncookie.sh b/tests/sys/netpfil/pf/syncookie.sh index 8a4005d0fc6d..d85beac1a4d1 100644 --- a/tests/sys/netpfil/pf/syncookie.sh +++ b/tests/sys/netpfil/pf/syncookie.sh @@ -168,9 +168,59 @@ nostate_cleanup() pft_cleanup } +atf_test_case "adaptive" "cleanup" +adaptive_head() +{ + atf_set descr 'Adaptive mode test' + atf_set require.user root + atf_set require.progs scapy +} + +adaptive_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 limit states 100" \ + "set syncookies adaptive (start 10%%, end 5%%)" \ + "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 100 + + # Adaptive mode should kick in and stop us from creating more than + # about 10 states + states=$(jexec alcatraz pfctl -ss | grep tcp | wc -l) + if [ "$states" -gt 20 ]; + then + echo "$states" + atf_fail "Found unexpected states" + fi +} + +adaptive_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "basic" atf_add_test_case "forward" atf_add_test_case "nostate" + atf_add_test_case "adaptive" }