From nobody Thu Oct 30 04:36:51 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 4cxrtD1vv8z6Dl1t; Thu, 30 Oct 2025 04:36:52 +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 4cxrtD0cz3z3MP7; Thu, 30 Oct 2025 04:36:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761799012; 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=KmOjANjqIozmkxdnJ4qXFHYwpV6i0gk87Qute8wX0q0=; b=bh1IcleI5RIM1VK8Z092TGKNfPrfLXhdCt5cKWeiZ5wh+OhEUwe38nvE6bmSfVfYfeAbFF EZK5r6nOfu+T557uyhqIw6q8ejU1vwqLZbbL60LfZYIxn8D0wlSnQKUi3IE+OsJBJI2LUk NbmUAJZD5X7LbpmB9KK7R7xkGdXrQnfkOX6wezGcCxjjfomj/YUazRJ+Q62FtcBVc17z5N k3BV4a3akUlFKWCjxpcmO6lGxKOtniCuZ133Zhereb5dCvQI3GzDRHnmyMrVwfyw/WlNES jQd34pQd94IcB3JlFXqp4bqdF+TufhfJbbVwZzPchACAvLhAKTfJVQOleEAgpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761799012; 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=KmOjANjqIozmkxdnJ4qXFHYwpV6i0gk87Qute8wX0q0=; b=KBRODxIQkRaKU99tHSWX93u21MutbzhSA9zYGNm/LoLL7RmZokkS3SU6CZGsA9tNnpeiiq iVuQdXyq0r7ej8BCyCK4Gp11MlymqQdZ9jzAosv8cS8R2zlKPUlS+PtLHYvcI8s8XYa63Y mWRNzUtOS9fTV4IUoZu+U/xHcSOu7MA2UXwU7wNOX9Ou4HjGHsmi4q1eyQMt7sRvyDs9YI 6UxxHu04M+ajeEpK49uj/Uuz9lvK9eKSu9bvKWXNqXXd51s/b0fbU/Wv01t7/rNUWJ7IyG Z4Wl4eX3YZ967EHB6NSbMkvehAmZRX3kWQCx0mqkZx8r99Lq9HjmhUWYOAotLA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1761799012; a=rsa-sha256; cv=none; b=NdbC6MUeaI5tO3UAPbbDj8pCx4GTPIn3I/KJeiAKHmm+J2wNEervqhnrZ4m1AaAakBI4Ys 4GK+BnBFnehr/kUrJY8rvHGTDt+YIRCsiw9LTiGU9Ums9Lyq9HCDAHxDlko6dW5QO3rW2M zxc+BvuD5ZjQoIHxR4NEr+wXxcv8ZMP2AhJwGgsXTISly6mvb7zX529tenWQ705pcbbBzD hFFHSxvv9ul9kzGWw1YpTKhDKFYKZrCGF60deiewjiljGAM0cFQ8m1+DNNFOe5KcwTxtwG Ta7reCKjqVKgbfasf/ieLNo8Mi4VHLiEsqYRZzqnvD1o8sxHRFUmebCre7kTtg== 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 4cxrtC6vf1z16Z6; Thu, 30 Oct 2025 04:36:51 +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 59U4apnS004951; Thu, 30 Oct 2025 04:36:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59U4ap6v004948; Thu, 30 Oct 2025 04:36:51 GMT (envelope-from git) Date: Thu, 30 Oct 2025 04:36:51 GMT Message-Id: <202510300436.59U4ap6v004948@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Colin Percival Subject: git: b39a387442db - releng/15.0 - 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: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/releng/15.0 X-Git-Reftype: branch X-Git-Commit: b39a387442db422ff3e962a440cf7dc7ec277df3 Auto-Submitted: auto-generated The branch releng/15.0 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=b39a387442db422ff3e962a440cf7dc7ec277df3 commit b39a387442db422ff3e962a440cf7dc7ec277df3 Author: Jose Luis Duran AuthorDate: 2025-10-25 09:19:18 +0000 Commit: Colin Percival CommitDate: 2025-10-30 04:36:20 +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. Approved by: re (cperciva) 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) (cherry picked from commit 1c8a554f757de06f64e6fd0d86fc674a215ee314) --- 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"