From nobody Wed Mar 02 16:00:59 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5DDC619E1369; Wed, 2 Mar 2022 16:01:03 +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 4K7zP90VLVz3NZ6; Wed, 2 Mar 2022 16:01:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646236861; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8k5bBmc/IhtiO+yY3T4I81RwOkwd4zVO0kP2eY4s1W4=; b=GozwOUMzivCYluUldguZhPk1Nyj0/DEzzjHpGvsEcYCGmHnj8okhGccbET9fedNRv47qUR SSalZKmjKwFLmhUye+orJKMBYXTEDSdnnRWshEqde6KKH2zqDKz7C6zuydElpGuJDuuftu YwNIOiFbCC4Rub7YLqtpu5byt9ikD/FUDgXBAtn9JTDUDMCSTYHDBwZ6xsh50chNjbHlzz 0CQnTiA4N+1rV+RiTDJsGuPmwxiu1IF/kC4RLiL5h9tQXROlSCtE8RQDY7eUfY+cscK4wn xnw6s6XviiE9+2ulw07lIXMxvos717ik75dRkzm6K4jV+cZhBMeuKk7xaaspYg== 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 82D10262D8; Wed, 2 Mar 2022 16:00:59 +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 222G0xsS091355; Wed, 2 Mar 2022 16:00:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 222G0xdA091354; Wed, 2 Mar 2022 16:00:59 GMT (envelope-from git) Date: Wed, 2 Mar 2022 16:00:59 GMT Message-Id: <202203021600.222G0xdA091354@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: ab1868a7d182 - main - pf tests: test match keyword and dummynet List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org 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: ab1868a7d18293cfb8a104da955b99485e64e95c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646236862; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8k5bBmc/IhtiO+yY3T4I81RwOkwd4zVO0kP2eY4s1W4=; b=rva8JLu3YUl/ZWutOr688X7JCFEHPVAPiHCshaGbyx4EZ5WlbBoP3sUcBjoC5zcfRDb+9b eGNIFWeGFGaIK/sArqWE8ULosp735AeC+NX+cPeJ6hdR+FlmEVGfEqYU9SoQ5hkwaGPoyd UGJY94OshVMnJjHiLfWEuJcwPWj7MBmlHV1Yo69S3y6gnAIvIg8gEmKTE1/bNHlLTgNfyy 73XXrRBY3EVURns/WhTkCtbIlyBXbrYxk6N+EoTYEvOLQE/Kbxiw3no+HNPkCxLiqy6WJ0 CMh5NT04OIQ9FrM/5YXj4sYw4SRkoDdQfvX6svJmhwBGFKMEnQuZPsKheIuBJw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646236862; a=rsa-sha256; cv=none; b=YLalSx5DDU8F/a6DpaDcTk/5OiDMeUROLYM7Ov7pFZVGnjX1QGeNzYbiVH3gAuupyaPls/ nCbvdWfLr2fgTuTBCVTzXErjs1gsbvjpcErakrFUHSf897neBlCDrWRioyAyZJAvOYA25y 3uPGOF8DYOIk3BYoxpdPWqsG8WVH8r8qTdg5U1OACJ2rcf/BD6WNlJac8MQS33YGFLAInt 2bVKyHDqG6ncexkjWq8xic86oGsqtkBtzHjQugCVV+M7ZlUI8ieFdBnGPssRpB01XVk1Na dZ1ZHV6CjJCYeXq9+vSi50PLhTcp5CLXZLOyv699h2pHqAj1qR1I//GUtBRPqQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=ab1868a7d18293cfb8a104da955b99485e64e95c commit ab1868a7d18293cfb8a104da955b99485e64e95c Author: Kristof Provost AuthorDate: 2021-09-29 15:45:15 +0000 Commit: Kristof Provost CommitDate: 2022-03-02 16:00:06 +0000 pf tests: test match keyword and dummynet Ensure that the 'match' keyword works with dummynet Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D32480 --- tests/sys/netpfil/pf/Makefile | 1 + tests/sys/netpfil/pf/match.sh | 77 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/tests/sys/netpfil/pf/Makefile b/tests/sys/netpfil/pf/Makefile index 6521d7fa6218..f793746cdbf0 100644 --- a/tests/sys/netpfil/pf/Makefile +++ b/tests/sys/netpfil/pf/Makefile @@ -17,6 +17,7 @@ ATF_TESTS_SH+= altq \ killstate \ macro \ map_e \ + match \ names \ nat \ pass_block \ diff --git a/tests/sys/netpfil/pf/match.sh b/tests/sys/netpfil/pf/match.sh new file mode 100644 index 000000000000..304c4e01ea71 --- /dev/null +++ b/tests/sys/netpfil/pf/match.sh @@ -0,0 +1,77 @@ +# $FreeBSD$ +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2021 Rubicon Communications, LLC (Netgate) +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +. $(atf_get_srcdir)/utils.subr + +atf_test_case "dummynet" "cleanup" +dummynet_head() +{ + atf_set descr 'Test dummynet with match keyword' + atf_set require.user root +} + +dummynet_body() +{ + pft_init + if ! kldstat -q -m dummynet; then + atf_skip "This test requires dummynet" + fi + + epair=$(vnet_mkepair) + vnet_mkjail alcatraz ${epair}b + + ifconfig ${epair}a 192.0.2.1/24 up + jexec alcatraz ifconfig ${epair}b 192.0.2.2/24 up + + # Sanity check + atf_check -s exit:0 -o ignore ping -i .1 -c 3 -s 1200 192.0.2.2 + + jexec alcatraz dnctl pipe 1 config bw 30Byte/s + jexec alcatraz pfctl -e + pft_set_rules alcatraz \ + "match in dnpipe 1" \ + "pass" + + # single ping succeeds just fine + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 + + # Saturate the link + ping -i .1 -c 5 -s 1200 192.0.2.2 + + # We should now be hitting the limits and get this packet dropped. + atf_check -s exit:2 -o ignore ping -c 1 -s 1200 192.0.2.2 +} + +dummynet_cleanup() +{ + pft_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case "dummynet" +}