From nobody Thu Oct 30 01:52:20 2025 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 4cxnDP25VWz6DTQJ; Thu, 30 Oct 2025 01:52:21 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cxnDP040Rz3pfR; Thu, 30 Oct 2025 01:52:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761789141; 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=hueK6WTuIgys8d86jq4sxdnI7qdmXmujEfL8cAVa0n0=; b=hxwXltrOTp9KnM1lRMfmEFQptg2T93u/0Fln9Esxv0vHXtbDF6WA4QhRrsiGyAWE/BRIwI CKgClT+SPRNNepq0Mti96O/tjU5VCfpy7PTCMs/LTrkdIqAKRUkwjW8vB1kMWu9ssxNu3f 2Bdi11d3K31sxJfdZUxW1bf/MqWdbkQzSBS8oCmtIRd0zfrWBQug6KNVy0HVk+V0kopf0w bCRX86Py9svIqJCaYuTIKMZKlYw4w4VgY729L9B/53voVCnrY5mSk+RkV6mCNkdQxwswaG dm0cbm4JU9thC5JU+2/Dg5NUoVH3QNa6rEa+wSxtJmoFOITg6JsJPUkNyZCnRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761789141; 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=hueK6WTuIgys8d86jq4sxdnI7qdmXmujEfL8cAVa0n0=; b=JIxnfwbP+RH1wOQsHQdzMubhRn8YGnSUPFyiOE5E6MacKzTCjQtA2iYdbyr2gnAcj2/+tq GMHuRJ9Bp5zX9fvoIoluW0qm20UaezTNID7fkz34L5bIXGiIKI9BGwxxx/HiARSsurVqI+ nenSXpN3104mJPCCG+qzcrO6jp2CSy/hWcFImvQ9e8nJ7rT4JzyWLLYUws9i8uB/jVAVE8 +RK5OqNPmstwvOZ0Ngp1G1XGwRRL/qWI76iv6hNtDc89RBsyAmjbotdkf0EqaV/c+B48qh D55rc3U1awKwJjERC3hcR+xHY3iNbf6X2yPS0OBBosHsB6VaybqvzVTCySQsFg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1761789141; a=rsa-sha256; cv=none; b=b4QpIH44wLnOABGogmROHEW2RlMLDO7P0W4nmZaNgKRri3280vcDcyLBR6/7kOiEY+9xi1 9P4ZdqdRxOgJg0Xnl/0MMPs3z2j0XnVPKEBJ5OGIFzyxeGOrHUJ58SSqPgmu4+hvMRvYww Z96nJqBeW1vTZCCZCeF7uSVz58UdihNbfVcLVGVNpNnkNCTiNVrsW7mOtsHpNuDsfsge9G hB0QzqGKgc76wikcmKMtSJwmykbRhsNXdywhEB2oVk22tCk7Y9iueBjvkdzogYuC0TU596 VxIiOQZdpyzxqiQ1znncj/DhgN2ohGj4PsIlBi1E0Y8fdqXxN66nYpCr2nNWRg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4cxnDN6NCbz12Gy; Thu, 30 Oct 2025 01:52:20 +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 59U1qKat097539; Thu, 30 Oct 2025 01:52:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59U1qKBw097536; Thu, 30 Oct 2025 01:52:20 GMT (envelope-from git) Date: Thu, 30 Oct 2025 01:52:20 GMT Message-Id: <202510300152.59U1qKBw097536@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jose Luis Duran Subject: git: 1c8a554f757d - stable/15 - libpfctl: Fix displaying deeply nested anchors 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jlduran X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 1c8a554f757de06f64e6fd0d86fc674a215ee314 Auto-Submitted: auto-generated The branch stable/15 has been updated by jlduran: URL: https://cgit.FreeBSD.org/src/commit/?id=1c8a554f757de06f64e6fd0d86fc674a215ee314 commit 1c8a554f757de06f64e6fd0d86fc674a215ee314 Author: Jose Luis Duran AuthorDate: 2025-10-25 09:19:18 +0000 Commit: Jose Luis Duran CommitDate: 2025-10-30 01:48:03 +0000 libpfctl: Fix displaying deeply nested anchors Set the number of rulesets (i.e., anchors) directly attached to the anchor and its path in pfctl_get_ruleset(). While here, add a test to document this behavior. PR: 290478 Reviewed by: kp Fixes: 041ce1d690f1 ("pfctl: recursively flush rules and tables") MFC after: 2 days Differential Revision: https://reviews.freebsd.org/D53358 (cherry picked from commit a943a96a50ba7e9d1e1935bdd18df0e11d158acb) --- lib/libpfctl/libpfctl.c | 3 +++ tests/sys/netpfil/pf/anchor.sh | 46 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 190ee46baf21..fbf9796d9887 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -3194,6 +3194,9 @@ pfctl_get_ruleset(struct pfctl_handle *h, const char *path, uint32_t nr, struct continue; } + rs->nr = nr; + strlcpy(rs->path, path, sizeof(rs->path)); + return (e.error); } diff --git a/tests/sys/netpfil/pf/anchor.sh b/tests/sys/netpfil/pf/anchor.sh index 64ca84b34c3d..034fe0d3d574 100644 --- a/tests/sys/netpfil/pf/anchor.sh +++ b/tests/sys/netpfil/pf/anchor.sh @@ -123,6 +123,51 @@ nested_anchor_cleanup() pft_cleanup } +atf_test_case "deeply_nested" "cleanup" +deeply_nested_head() +{ + atf_set descr 'Test setting and retrieving deeply nested anchors' + atf_set require.user root +} + +deeply_nested_body() +{ + pft_init + + epair=$(vnet_mkepair) + vnet_mkjail alcatraz ${epair}a + + pft_set_rules alcatraz \ + "anchor \"foo\" { \n\ + anchor \"bar\" { \n\ + anchor \"foobar\" { \n\ + pass on ${epair}a \n\ + } \n\ + anchor \"quux\" { \n\ + pass on ${epair}a \n\ + } \n\ + } \n\ + anchor \"baz\" { \n\ + pass on ${epair}a \n\ + } \n\ + anchor \"qux\" { \n\ + pass on ${epair}a \n\ + } \n\ + }" + + atf_check -s exit:0 -o \ + inline:" foo\n foo/bar\n foo/bar/foobar\n foo/bar/quux\n foo/baz\n foo/qux\n" \ + -e ignore jexec alcatraz pfctl -sA + + atf_check -s exit:0 -o inline:" foo/bar/foobar\n foo/bar/quux\n" \ + -e ignore jexec alcatraz pfctl -a foo/bar -sA +} + +deeply_nested_cleanup() +{ + pft_cleanup +} + atf_test_case "wildcard" "cleanup" wildcard_head() { @@ -498,6 +543,7 @@ atf_init_test_cases() atf_add_test_case "pr183198" atf_add_test_case "pr279225" atf_add_test_case "nested_anchor" + atf_add_test_case "deeply_nested" atf_add_test_case "wildcard" atf_add_test_case "nested_label" atf_add_test_case "quick"