From nobody Tue Oct 28 11:49:24 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 4cwpZD4Qbbz6DlCf; Tue, 28 Oct 2025 11:49:24 +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 4cwpZD3tWmz3SGy; Tue, 28 Oct 2025 11:49:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761652164; 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=Sz2YXTeEpNwRzHQKtkWu+kvyP8cSlOvdFHQiIhwlkl8=; b=iyV08MFCdgEKZbOlwrtYZl5cdvJEFCvsO2tPtG5M5etoxx8SZvG7k2t1zUKi65qsd4xkcZ rggDgRoqkF2urbY0Mh2RTIOmMhntytzQcJtVHoYupvkkRwbhps2QyFYCnqfWdjF/YgdlTn CeEK69HRs9BcDttq+0BXxlUu64DCx/Tqhz2fZ/Tes5MH+s5elt1stHrfDALRp9tgphuLds 4BG9fBJ4/2fZocaEIcyRYITX6WZzDtxgsEa6+hn97Opg8uyGQTzDWhtH/ioYfWrOmGVcU1 foX1/VqtSx50Dc3GQ0RRmAlWjOaiIfFxMyosViJe3tQEUa7RWznZo+7vGvYNaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761652164; 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=Sz2YXTeEpNwRzHQKtkWu+kvyP8cSlOvdFHQiIhwlkl8=; b=VX+WoR0ANfzmQ5VRgdZaGOPUGCQL0j3Uhf0/EAu64VkM0T9AlnNCCOFNRtP3RME61M4ZFW 1NWQFEVSkgZ3mC8znYM/BHGukT87z7hhjwJAJOUxT3ag4SXwqtTWGNtB6woMhEueORgttY X+c0k6fWsuPms0XiCykuMv+yKd6vK5OVoqA9vgEJrpg6ZnhybkqPKBg4CGjtQ22Z6m3O8y 1o08F67uAtI3M0KosyWCmPfNfkvMlQkP+/q8YD9krvnjxPMpmVVOMT0ZAk0caBQm/sT7Bf UZmmrcRbySVZjo0JJsd3Zk/LbWVUm9TjeLIBzRL+hkPPY8/KMwE05bitZzOTmA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1761652164; a=rsa-sha256; cv=none; b=dRRxJjrURzGVvRhY4lSXxnZA9OsEhHXt72jI41MkvG1P3pXWDHZQKkL8x1uTYiVRm1sS// UpITctF6e/kkauzYEAVKCGFR6ABG6rhqL9bdvo85pzFvCh1aHblg2u/yv4JDb2C0ZrU1Fk +Gv8+PTucC+6vO3he5Stph96Qna71h2HF/+CNOyfG79jkGeQ1WAzNEkfOYTh4Pu6Kr7xkQ ANwrNPrLJcfPhg4feYP9o5TdxFyzBCgEwLEUtvdyGY0pBSFfK3apGz+wKCrNC+MqRX+avw cMBQ7lsgtcNRZQCgMgz/wndU4iSbzqWnF3bxtvBSkvGzwRMGtcc8ni2D9JJuhw== 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 4cwpZD2kCKzpgF; Tue, 28 Oct 2025 11:49:24 +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 59SBnOim083351; Tue, 28 Oct 2025 11:49:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59SBnOBe083348; Tue, 28 Oct 2025 11:49:24 GMT (envelope-from git) Date: Tue, 28 Oct 2025 11:49:24 GMT Message-Id: <202510281149.59SBnOBe083348@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jose Luis Duran Subject: git: a943a96a50ba - main - 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/main X-Git-Reftype: branch X-Git-Commit: a943a96a50ba7e9d1e1935bdd18df0e11d158acb Auto-Submitted: auto-generated The branch main has been updated by jlduran: URL: https://cgit.FreeBSD.org/src/commit/?id=a943a96a50ba7e9d1e1935bdd18df0e11d158acb commit a943a96a50ba7e9d1e1935bdd18df0e11d158acb Author: Jose Luis Duran AuthorDate: 2025-10-25 09:19:18 +0000 Commit: Jose Luis Duran CommitDate: 2025-10-28 11:29:19 +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 --- 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 8c4b26b98054..17576066fcfd 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -3202,6 +3202,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"