From nobody Tue Jan 16 08:51:55 2024 X-Original-To: dev-commits-src-all@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 4TDjRw3KCJz57B4Z; Tue, 16 Jan 2024 08:51: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 4TDjRw1vPlz4Pv6; Tue, 16 Jan 2024 08:51:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705395116; 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=Ttw//nj/kE/iM5IfW0cxUVwggkB4M5Yu5ELwRiktpGE=; b=ASWOwD/s1FO7GZF5fuSJlHj/0wTEryarHwrNgi14vs0ouKW8DnAd1mSQmxvgs9OaBmwzgq mhTCEYWyb1Bi2Wp8a/pix9r6SWEXMjZnY1MKnHWWIjMGC8EYMZmuyFKDCZ6gqi8wNNLOoc ztWRJZ7XSaLlbomePXu7SXUKJXw7cRpv5tnKe3DfNdrOvTUzsEu+Zlw3Ef0DrTSMGqq1Hi HXZtHVfLL6LvmcyXnx1lP7Iahc8kv8n99+Dmz76OXopzPLUeNwmCwvFVHLRRrkS24N0qob hvo/dSheCneTSrUy9bVlxHt9zXCkIJJAswINskXKCbFBL9F8Zgyb7U7lSqSsxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705395116; 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=Ttw//nj/kE/iM5IfW0cxUVwggkB4M5Yu5ELwRiktpGE=; b=TBuj1sFTflskiipIBfAN8QtHXTGaREicbac35b2iAPLe7RmchQhoCJ4OIyy4F4Q4hBZdPI kUslwpRgw3tGQBRPyL974Paahu0VH2NhxrSO6qnPmSNenZUzy8pk6+9yB2SFQntXbAGkn0 qi/Zti3+IyDxHtONHDH1RHbUTUD/9pGcf41qH6EPJbYrDygj9W3JQak01zpHMTZAHcedcN EBwA7ErUrV9obCnYXIiyH1XDWViqfjYJW8D24bvZCDT4r3Z+c4YWN6wdta2hyyGsSVHnV+ dYaV6Dj1RDra9VJtCfV0PuhLSqUUuMU/GxDFUDRFRb5LQ4DMwKW+CAYyHPfOkQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705395116; a=rsa-sha256; cv=none; b=OzmLcme77PD0OquFeWbGhB2poRv6EafFLd/nf9ftLseZmJIUW5LiyCtY+DUj8v5SpZ7Aph J+E6vTg8mJfQAi81hlZma+tPW24B6END81hRKSxABoLQfgq+B/wV9ixcGrF/zpoWcIELdL 8H6zE45xIkunbBZMJ1XzTfdoYzOahzXfc2tQ8LNyahy3HjMXMUSjV9EclXQ9v38d37tlvE QyvhglM+iaGY/Gc0CVz29p2/n62ITpUW0a5vo7fTF5IJyyc5NemqNgNYp2NGvuBZXGVDFb qxw4Hdp7hTRfKwHOXuAlOOdn2xYzbEMW35NOFinv11SDFd6rzQyXkkWyh/lqAQ== 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 4TDjRw0SFyzZ6f; Tue, 16 Jan 2024 08:51:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40G8ptnL076254; Tue, 16 Jan 2024 08:51:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40G8ptsL076236; Tue, 16 Jan 2024 08:51:55 GMT (envelope-from git) Date: Tue, 16 Jan 2024 08:51:55 GMT Message-Id: <202401160851.40G8ptsL076236@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: fb0c74685f5f - main - pf tests: initial pflow test case List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: fb0c74685f5f57f148a4628efc1fd3784a597819 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=fb0c74685f5f57f148a4628efc1fd3784a597819 commit fb0c74685f5f57f148a4628efc1fd3784a597819 Author: Kristof Provost AuthorDate: 2023-12-01 17:04:00 +0000 Commit: Kristof Provost CommitDate: 2024-01-16 08:45:54 +0000 pf tests: initial pflow test case Basic creation, validation and cleanup test for the new pflow interface. Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D43109 --- tests/sys/netpfil/pf/Makefile | 1 + tests/sys/netpfil/pf/pflow.sh | 80 +++++++++++++++++++++++++++++++++++++++++ tests/sys/netpfil/pf/utils.subr | 9 +++++ 3 files changed, 90 insertions(+) diff --git a/tests/sys/netpfil/pf/Makefile b/tests/sys/netpfil/pf/Makefile index 5f18d7c5da35..a1a40cf4d8f4 100644 --- a/tests/sys/netpfil/pf/Makefile +++ b/tests/sys/netpfil/pf/Makefile @@ -25,6 +25,7 @@ ATF_TESTS_SH+= altq \ nat \ pass_block \ pflog \ + pflow \ pfsync \ prio \ proxy \ diff --git a/tests/sys/netpfil/pf/pflow.sh b/tests/sys/netpfil/pf/pflow.sh new file mode 100644 index 000000000000..3ae4fedf3a93 --- /dev/null +++ b/tests/sys/netpfil/pf/pflow.sh @@ -0,0 +1,80 @@ +# +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2023 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 "basic" "cleanup" +basic_head() +{ + atf_set descr 'Basic pflow test' + atf_set require.user root +} + +basic_body() +{ + pflow_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 + + # Sanity check + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.1 + + pflow=$(jexec alcatraz pflowctl -c) + + # Reject invalid flow destinations + atf_check -s exit:1 -e ignore \ + jexec alcatraz pflowctl -s ${pflow} dst 256.0.0.1:4000 + atf_check -s exit:1 -e ignore \ + jexec alcatraz pflowctl -s ${pflow} dst 192.0.0.2:400000 + + # A valid destination is accepted + atf_check -s exit:0 \ + jexec alcatraz pflowctl -s ${pflow} dst 192.0.2.2:4000 + + # Reject invalid version numbers + atf_check -s exit:1 -e ignore \ + jexec alcatraz pflowctl -s ${pflow} proto 9 + + # Valid version passes + atf_check -s exit:0 \ + jexec alcatraz pflowctl -s ${pflow} proto 5 + atf_check -s exit:0 \ + jexec alcatraz pflowctl -s ${pflow} proto 10 +} + +basic_cleanup() +{ + pft_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case "basic" +} diff --git a/tests/sys/netpfil/pf/utils.subr b/tests/sys/netpfil/pf/utils.subr index 74ed07984601..25720c1bcb66 100644 --- a/tests/sys/netpfil/pf/utils.subr +++ b/tests/sys/netpfil/pf/utils.subr @@ -88,6 +88,15 @@ pflog_init() fi } +pflow_init() +{ + pft_init + + if ! kldstat -q -m pflow; then + atf_skip "This test requires pflow" + fi +} + dummynet_init() { pft_init