From nobody Thu Apr 03 16:42:53 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 4ZT6wt2Vm6z5s8Dx; Thu, 03 Apr 2025 16:42:54 +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 4ZT6wt0Qg2z4Hm3; Thu, 03 Apr 2025 16:42:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1743698574; 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=BwGgJep3d2Ztwi1GOgSNrjt/xFzDOI3vt7C/OYq2xT0=; b=Sd4Nlt1wKJ35VnVJijIadOrg9xQcxZmKGR9NONF4mJUiWSIU6o2tAcOZdDsgOQSdIXiPIn 2GzI43VdL0DRhnTxrwkH9ae0u8mi1KqmIswmJj7Lpl9Nv7TOatuWhwKgsRaS1PV7bgZJWr KalF5yC7lNV8OO1HxbWzhCWS/nTp8crlaNGv0mdPVbe2jleKZ86SJLeSLHnCHGCmXqb0SQ m5EN9QzneCYTBkSA07kqf2jlrIJPtyJZbnRFfhC1fiQFdC611pddm+sgdG/MIqLyiDxREu 107XTerFyn6jRH8KjuAnn9GANQcoM0D1Lsbosf/E4bzZUAgEy7SlI4JXOhI18A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1743698574; a=rsa-sha256; cv=none; b=du8lQVIW5HhI7ToztnRAemFjkgT1C4HMMdKjmfbl9MtZ/brOYvyVQzYU0aA/c/7hhtny+l tVomIFVBpVCuD5pKP07J1DeOrSFyZcnP3rWaGJrXvCSMKvq7k3gyKtLDmF4MyKYXEyuTsQ z3TXtwbsEDNNKKDPvd8Lk2H6WiPo8ViuSvrvlCL91TxhL6OV/5C7Q4lXunby3lTiaRzbUE Y8dMkd3tDtZsh17FJQ+3tOxVDs8KoSgVg4smAEueP2ua+EH3QQspD8YQZaSAoIn6OXHpwO YkYwwDR/zqGLullGupre8Wag9U+wbtoBLzqpEIkuuyvT5YD5lnHSkhnIJZ0JFg== 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=1743698574; 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=BwGgJep3d2Ztwi1GOgSNrjt/xFzDOI3vt7C/OYq2xT0=; b=h+bIxNNXr/FWwAlpxPQNd7Ecbl+xR8FwjMKbsXkiuzbDEJrmRTaqxAFEX0/V9TzW7pcRlr CufYzp7oqw2u4r0fX0VnuObt0PlmOrmiD+c/E8Frpvesh01mqId4QbO8XrSkEiedolNP/S pvFD0NVgsTxe8m1BuO1Nv+RL69Ry02BTfYfwVS6x/5Ugt4i5SW9SY3ESIj2Rj/tPqvKD9m LVl/gicJYdB8enC3RNkbKVW+QXL7kdxNZLkAsy4K8nVBYSCxEiXNVFyatA2oqmyF03E+Mj esStsQNvJgOr8BlimQ9QASG4Su9cGKQdn+WRDR1t3e2HDsPPRQXAEbfEQEHIAg== 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 4ZT6ws6vdLz17kC; Thu, 03 Apr 2025 16:42:53 +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 533GgrcD022516; Thu, 3 Apr 2025 16:42:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 533Ggr2T022513; Thu, 3 Apr 2025 16:42:53 GMT (envelope-from git) Date: Thu, 3 Apr 2025 16:42:53 GMT Message-Id: <202504031642.533Ggr2T022513@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: 3410b98ce2c3 - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: 3410b98ce2c36a49fffa9a975425333c1f05b0bc Auto-Submitted: auto-generated The branch stable/14 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=3410b98ce2c36a49fffa9a975425333c1f05b0bc commit 3410b98ce2c36a49fffa9a975425333c1f05b0bc Author: Kristof Provost AuthorDate: 2025-03-19 06:42:42 +0000 Commit: Kristof Provost CommitDate: 2025-04-03 16:41:25 +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 f2ccd5aa6ec2..1d9c685b2565 100644 --- a/tests/sys/netpfil/pf/Makefile +++ b/tests/sys/netpfil/pf/Makefile @@ -38,6 +38,7 @@ ATF_TESTS_SH+= altq \ sctp \ set_skip \ set_tos \ + snmp \ src_track \ syncookie \ synproxy \ @@ -54,7 +55,9 @@ TEST_METADATA+= execenv_jail_params="vnet allow.raw_sockets" PROGS= divapp -${PACKAGE}FILES+= CVE-2019-5597.py \ +${PACKAGE}FILES+= \ + bsnmpd.conf \ + CVE-2019-5597.py \ CVE-2019-5598.py \ daytime_inetd.conf \ echo_inetd.conf \ @@ -69,6 +72,7 @@ ${PACKAGE}FILES+= CVE-2019-5597.py \ rdr-srcport.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" +}