From nobody Thu Apr 3 16:43:05 2025 X-Original-To: dev-commits-src-branches@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 4ZT6x62wtNz5s8M4; Thu, 03 Apr 2025 16:43:06 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZT6x54Kkhz4J0M; Thu, 03 Apr 2025 16:43:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1743698585; 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=p8RQMEb/MLNBZhJTr/EHrnSn6eMoHZLfOY4XRrMsS4c=; b=mNoKoKUrzkn9mBluW/MJxBDyibV0BRDu46PzBmZ8D0MYPszuQLE8W0OJF7H3kpXNqOaGKS W93sB4kGttPihpywQICmIpE6McGCIVaRn6S5WmXMY+Er1nXaqThapALDt/a4dVG/VOwWkg bLGkDam9HzuUph7mFYiiG4VaiHQwVEF8/s2VjPGaOxqZEXHrhTz1ryGCEO9asuxOpVjvRD 12vHQhw+l+LkaiSn3KalcZJHWngPaigNAiYobAXUOgY7yRAzSxkh9upPAP173ENkMQcOb4 31tdb/bxK0cCUpNH/hafB9EF2Lq1QIdHvtuF/SKy+fg3WKFz+GLGYIXglnMstg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1743698585; a=rsa-sha256; cv=none; b=xr2FLwx4X75/T0DQeMIyRsGVqoR8z0yBvTU/mh64bitV48yOatVRFnZgg4mLQ9c8xz4ADf XONCXn6TpQGT65OiJnaDq7Ea02xXXwzp2OOtlSkGioBirN4pxKD2N4mblSkiMVYSTmDvVK fW84yUvhgIjnqhYgZnPFRHLzkBQg7hM2JSh1c/s1faxtJhloptY40HwIqr9GI/oa0sWMCt TLLqIL6De4ZzMwFkPyA3CsjFKauw5Erg2mvD2/+6PvS5GBRbaxHF4Fug5U3omyTQpUudcl 9ZntQ2/v7sFnx1kSy5U7FCNyFOLg/y7u+38MaLwN5ffDf2ECtAOucyyNyw4ZIQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1743698585; 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=p8RQMEb/MLNBZhJTr/EHrnSn6eMoHZLfOY4XRrMsS4c=; b=Cz+JG9B6wH1lXO0kJkGiz/XwjR5HrPnqyOIkRuIsXaesRTBeGKhbMb2qDy6eDF1U6wx37/ z7eZ726BY1q6AboEEKWoZeDAcrdgNEcsNRBhqPlBgSB9kx0tid5QQBJu9O48rn/y6XgAxz OCQN5gCo12JUmKCDPfpwqYFvmwnIfZSL4Q2ReS7RQRmSDAT27c9J+q/NLSyN4jqfw6jgVf Kyo855kPExo6o/LUWCnhU/jXQ1rY43BjAVHFa9Eei5RaRYK4nII4vxtHaELuUwQt1TNXfL puz24927tLO9SAKEwgwrqtRCvaBxLfNeq8WQc3eqVbJr7qANquB74Ag/afpgCg== 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 4ZT6x53NR8z181n; Thu, 03 Apr 2025 16:43:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 533Gh5Cw022788; Thu, 3 Apr 2025 16:43:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 533Gh5YO022785; Thu, 3 Apr 2025 16:43:05 GMT (envelope-from git) Date: Thu, 3 Apr 2025 16:43:05 GMT Message-Id: <202504031643.533Gh5YO022785@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: ca1bf31177d2 - stable/13 - pf tests: add a basic snmp_pf test case List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: ca1bf31177d2cdf7618f63f2317558fa089af54e Auto-Submitted: auto-generated The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=ca1bf31177d2cdf7618f63f2317558fa089af54e commit ca1bf31177d2cdf7618f63f2317558fa089af54e Author: Kristof Provost AuthorDate: 2025-03-19 06:42:42 +0000 Commit: Kristof Provost CommitDate: 2025-04-03 05:58:48 +0000 pf tests: add a basic snmp_pf test case Event: Tokyo Hackathon 202503 (cherry picked from commit c849f533326026501c28cb2c344b16723862551a) --- tests/sys/netpfil/pf/Makefile | 6 +++- tests/sys/netpfil/pf/bsnmpd.conf | 47 ++++++++++++++++++++++++++ tests/sys/netpfil/pf/snmp.sh | 71 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 1 deletion(-) diff --git a/tests/sys/netpfil/pf/Makefile b/tests/sys/netpfil/pf/Makefile index f033940b4564..eaec2c9d5203 100644 --- a/tests/sys/netpfil/pf/Makefile +++ b/tests/sys/netpfil/pf/Makefile @@ -27,6 +27,7 @@ ATF_TESTS_SH+= altq \ sctp \ set_skip \ set_tos \ + snmp \ src_track \ syncookie \ synproxy \ @@ -40,7 +41,9 @@ ATF_TESTS_PYTEST+= sctp.py # Tests reuse jail names and so cannot run in parallel. TEST_METADATA+= is_exclusive=true -${PACKAGE}FILES+= CVE-2019-5597.py \ +${PACKAGE}FILES+= \ + bsnmpd.conf \ + CVE-2019-5597.py \ CVE-2019-5598.py \ echo_inetd.conf \ fragcommon.py \ @@ -50,6 +53,7 @@ ${PACKAGE}FILES+= CVE-2019-5597.py \ pfsync_defer.py \ utils.subr +${PACKAGE}FILESMODE_bsnmpd.conf= 0555 ${PACKAGE}FILESMODE_CVE-2019-5597.py= 0555 ${PACKAGE}FILESMODE_CVE-2019-5598.py= 0555 ${PACKAGE}FILESMODE_fragcommon.py= 0555 diff --git a/tests/sys/netpfil/pf/bsnmpd.conf b/tests/sys/netpfil/pf/bsnmpd.conf new file mode 100644 index 000000000000..27abdda6cbd3 --- /dev/null +++ b/tests/sys/netpfil/pf/bsnmpd.conf @@ -0,0 +1,47 @@ +location := "A galaxy far, far away" +contact := "skywalker@Tatooine" +system := 1 + +read := "public" +write := "geheim" +trap := "mytrap" + +NoAuthProtocol := 1.3.6.1.6.3.10.1.1.1 +HMACMD5AuthProtocol := 1.3.6.1.6.3.10.1.1.2 +HMACSHAAuthProtocol := 1.3.6.1.6.3.10.1.1.3 +NoPrivProtocol := 1.3.6.1.6.3.10.1.2.1 +DESPrivProtocol := 1.3.6.1.6.3.10.1.2.2 +AesCfb128Protocol := 1.3.6.1.6.3.10.1.2.4 + +securityModelAny := 0 +securityModelSNMPv1 := 1 +securityModelSNMPv2c := 2 +securityModelUSM := 3 + +MPmodelSNMPv1 := 0 +MPmodelSNMPv2c := 1 +MPmodelSNMPv3 := 3 + +noAuthNoPriv := 1 +authNoPriv := 2 +authPriv := 3 + +%snmpd +begemotSnmpdDebugDumpPdus = 2 +begemotSnmpdDebugSyslogPri = 7 + +begemotSnmpdCommunityString.0.1 = $(read) +begemotSnmpdCommunityDisable = 1 + +begemotSnmpdTransInetStatus.1.4.0.0.0.0.161.1 = 4 +begemotSnmpdTransInetStatus.2.16.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.161.1 = 4 + +begemotSnmpdLocalPortStatus."/var/run/snmpd.sock" = 1 +begemotSnmpdLocalPortType."/var/run/snmpd.sock" = 4 + +sysContact = $(contact) +sysLocation = $(location) +sysObjectId = 1.3.6.1.4.1.12325.1.1.2.1.$(system) + +begemotSnmpdModulePath."mibII" = "/usr/lib/snmp_mibII.so" +begemotSnmpdModulePath."pf" = "/usr/lib/snmp_pf.so" diff --git a/tests/sys/netpfil/pf/snmp.sh b/tests/sys/netpfil/pf/snmp.sh new file mode 100644 index 000000000000..0d6b2eb10ec7 --- /dev/null +++ b/tests/sys/netpfil/pf/snmp.sh @@ -0,0 +1,71 @@ +# +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2025 Kristof Provost +# +# 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 pf_snmp test' + atf_set require.user root +} + +basic_body() +{ + pft_init + + epair=$(vnet_mkepair) + + ifconfig ${epair}b 192.0.2.2/24 up + + vnet_mkjail alcatraz ${epair}a + jexec alcatraz ifconfig ${epair}a 192.0.2.1/24 up + + # Start bsnmpd + jexec alcatraz bsnmpd -c $(atf_get_srcdir)/bsnmpd.conf + + jexec alcatraz pfctl -e + pft_set_rules alcatraz \ + "pass" + + # Sanity check, and create state + atf_check -s exit:0 -o ignore \ + ping -c 1 192.0.2.1 + + # pf should be enabled + atf_check -s exit:0 -o match:'pfStatusRunning.0 = true' \ + bsnmpwalk -s public@192.0.2.1 -i pf_tree.def begemot +} + +basic_cleanup() +{ + pft_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case "basic" +}