While testing migration from blacklistd to blocklistd, I found that anchors are not listed correctly by the command "pf -sA". In the past, they were not listed recursively; however, at least the parent anchors were displayed. Now, only the first anchor with its first subanchor shows up: # pfctl -a blocklistd -sA 25 pfctl: Anchor does not exist. But, for example, such anchors do exist: # pfctl -a blocklistd/25 -sr block drop in quick proto tcp from <port25> to any port = smtp # pfctl -a blocklistd/465 -sr block drop in quick proto tcp from <port465> to any port = smtps
I should have begun by explaining that the affected system is the most recent 15.0-STABLE, and when no specific anchor is requested, still only two are displayed: # pfctl -sA blacklistd 22 This system has at least "blacklistd" anchor with several subanchors, and "blocklist" anchor, also with several subanchors.
(In reply to Marek Zarychta from comment #0) With regards to the message: pfctl: Anchor does not exist. It is referring to a nonexistent ethernet anchor named blacklist (bug #280516).
(In reply to Marek Zarychta from comment #1) What we can do in the meantime, is "hide" those error messages?
(In reply to Jose Luis Duran from comment #2) I apologize, please discard comment #2. It does not apply.
(In reply to Jose Luis Duran from comment #3) It's not the same bug, but a problem with recursive anchors. After entering the first subanchor, the loop gets exited, and no further anchors are displayed. IIRC, someone requested displaying nested anchors with the default listing; the request was fulfilled, but probably also introduced this regression. On another machine: # pfctl -sA blocklistd ftp-proxy student-vm virt-pc pc30 pfctl: Anchor does not exist. The "pc30" is the first subanchor nested in virt-pc, but there are more of them: # pfctl -a virt-pc/pc30 -sn rdr on vlan0 inet proto tcp from any to 89.x.x.x port = xxx30 -> x.y.z.30 port 3389 # pfctl -a virt-pc/pc31 -sn rdr on vlan0 inet proto tcp from any to 89.x.x.x port = xxx31 -> x.y.z.31 port 3389 # pfctl -a virt-pc/pc32 -sn rdr on vlan0 inet proto tcp from any to 89.x.x.x port = xxx32 -> x.y.z.32 port 3389 ... The reported issue is only mild, since the above rdr anchors are working fine.
(In reply to Marek Zarychta from comment #5) Yes, sorry for the confusion, and thank you for improving the tile. MWE: # pfctl -a parent/child1 -t table1 -T add 192.0.2.0/24 1 table created. 1/1 addresses added. # pfctl -a parent/child2 -t table2 -T add 198.51.100.0/24 1 table created. 1/1 addresses added. # pfctl -sA parent child1 pfctl: Anchor does not exist.
(In reply to Jose Luis Duran from comment #6) Yes, likely in bug 280516, you were also falling into this. Bug 262622 probably opened this Pandora's box with the nested anchors listing. I'm not sure if they were ever displayed correctly. In the past, I used syntax: #pfctl -a parrentanchor -sA to list the children, and it worked. But it was in the unspecified past.
(In reply to Marek Zarychta from comment #7) Please forgive blaming the patch committed to close bug 262622. Listing rules recursively is actually helpful, since commands: #pfctl -a "*" -sn and #pfctl -a "*" -sr are actually the only method to list all anchors correctly.
This patch fixes the issue for me: diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 190ee46baf21..83332433fd11 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -3158,6 +3158,7 @@ pfctl_get_rulesets(struct pfctl_handle *h, const char *path, uint32_t *nr) } *nr = rs.nr; + e.error = (e.error == ENOENT) ? 0 : e.error; return (e.error); }
It appears that for pfctl(8), the transition to netlink(4) still has some rough edges. The patch from comment #9 is only a temporary workaround, not a real fix. Since the issue is minor and a workaround is known, I’ll leave the bug for future attention.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=67ade69eb6079887215db1fde86eba2fb8e2acf7 commit 67ade69eb6079887215db1fde86eba2fb8e2acf7 Author: Jose Luis Duran <jlduran@FreeBSD.org> AuthorDate: 2025-10-25 23:14:48 +0000 Commit: Jose Luis Duran <jlduran@FreeBSD.org> CommitDate: 2025-10-25 23:21:07 +0000 blocklistd-helper: Silence another bogus pf warning It has been reported as PR 290478. In the meantime, just sweep under the carpet. It is worth noting that neither commit: 2347ca21d657 ("blocklist-helper: Silence a bogus pf warning") nor this one will be upstreamed, as this is a FreeBSD-specific issue. PR: 290478 MFC after: 2 days contrib/blocklist/libexec/blocklistd-helper | 2 +- libexec/blocklistd-helper/blacklistd-helper | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Created attachment 264888 [details] Add tests Add a test that illustrates the regression.
I believe the regression was introduced in: 041ce1d690f1 ("pfctl: recursively flush rules and tables")
Created attachment 264889 [details] Add tests
The patch proposed in review D53358 solves the issue. Thanks for chasing it. I have tested it with double-nested anchors, and they are also fine. TBH, I'm not sure if such anchors are very popular, but extending the test case would be appreciated.
(In reply to Marek Zarychta from comment #15) Thank you Marek for reporting and testing. Just to clarify, when you say: > I have tested it with double-nested anchors, and they are also fine. TBH, I'm not > sure if such anchors are very popular, but extending the test case would be > appreciated. By double-nested you mean deeply-nested anchors like: foo/bar/baz If so, I can absolutely extend the test case.
(In reply to Jose Luis Duran from comment #16) >By double-nested, you mean deeply-nested anchors like: > > foo/bar/baz Yes, extending the test case with the following entries would be nice: foo/bar/foobar foo/bar/quux foo/baz foo/qux This syntax, though rarely used, is definitely supported by pf(1).
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=a943a96a50ba7e9d1e1935bdd18df0e11d158acb commit a943a96a50ba7e9d1e1935bdd18df0e11d158acb Author: Jose Luis Duran <jlduran@FreeBSD.org> AuthorDate: 2025-10-25 09:19:18 +0000 Commit: Jose Luis Duran <jlduran@FreeBSD.org> 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(+)
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=1c8a554f757de06f64e6fd0d86fc674a215ee314 commit 1c8a554f757de06f64e6fd0d86fc674a215ee314 Author: Jose Luis Duran <jlduran@FreeBSD.org> AuthorDate: 2025-10-25 09:19:18 +0000 Commit: Jose Luis Duran <jlduran@FreeBSD.org> 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(+)
Thank you for the bug report!
A commit in branch releng/15.0 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=b39a387442db422ff3e962a440cf7dc7ec277df3 commit b39a387442db422ff3e962a440cf7dc7ec277df3 Author: Jose Luis Duran <jlduran@FreeBSD.org> AuthorDate: 2025-10-25 09:19:18 +0000 Commit: Colin Percival <cperciva@FreeBSD.org> 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(+)
(In reply to Jose Luis Duran from comment #20) Thank you for solving the problem and taking my comments into account.