Bug 297839 - pf: "pfctl -a 'someanchor/*' -sr" is non-functional
Summary: pf: "pfctl -a 'someanchor/*' -sr" is non-functional
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 15.1-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-pf (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-08-24 10:27 UTC by Lexi Winter
Modified: 2026-09-03 14:04 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lexi Winter freebsd_committer freebsd_triage 2026-08-24 10:27:35 UTC
in pf.conf:

anchor "jail/*"

in pfctl:

--->o---
# pfctl -a jail/www -sr
pass in proto tcp from <lf> to <addrs> port = smtp flags S/SA keep state
pass in proto tcp from any to <addrs> port = ftp flags S/SA keep state
pass in proto tcp from any to <addrs> port = ftps flags S/SA keep state
pass in proto tcp from any to <addrs> port = http flags S/SA keep state
pass in proto tcp from any to <addrs> port = https flags S/SA keep state
pass in proto tcp from any to <addrs> port 50000:50100 flags S/SA keep state
pass in on vm.www from <addrs> to any flags S/SA keep state

# pfctl -a jail/ns -sr
pass in proto tcp from <lf> to <addrs> port = smtp flags S/SA keep state
pass in proto tcp from <lf> to <addrs> port = domain flags S/SA keep state
pass in proto tcp from <lf> to <addrs> port = domain-s flags S/SA keep state
pass in proto udp from <lf> to <addrs> port = domain keep state
pass in proto udp from <lf> to <addrs> port = domain-s keep state
pass in on vm.ns from <addrs> to any flags S/SA keep state

# pfctl -a 'jail/*' -sr
#
--->o---

according to pfctl(8), under the description of the '-a' flag, this should work.

"pfctl -a '*' -sr" does work and shows all recursive anchors, including under jail/*:

--->o---
# pfctl -a '*' -sr
block return in log all
pass out all flags S/SA keep state (if-bound)
anchor "jail/*" all {
  anchor "ldap3" all {
    pass in proto tcp from <lf> to <addrs> port = smtp flags S/SA keep state
    pass in proto tcp from <lf> to <addrs> port = ldap flags S/SA keep state
[...]
--->o---
Comment 1 Kristof Provost freebsd_committer freebsd_triage 2026-08-26 12:25:55 UTC
That's odd. I can't seem to reproduce this:

$ cat pf.conf
anchor "jail" {
	anchor "one" {
		pass label "jailone"
	}
	anchor "two" {
		pass label "jailtwo"
	}
}
pass
$ sudo pfctl -sr
anchor "jail" all
pass all flags S/SA keep state
$ sudo pfctl -sr -a "*"
anchor "jail" all {
  anchor "one" all {
    pass all flags S/SA keep state label "jailone"
  }
  anchor "two" all {
    pass all flags S/SA keep state label "jailtwo"
  }
}
pass all flags S/SA keep state
$ sudo pfctl -sr -a "jail/one"
pass all flags S/SA keep state label "jailone"
$ sudo pfctl -sr -a "jail/two"
pass all flags S/SA keep state label "jailtwo"
$ sudo pfctl -sr -a "jail/*"
anchor "one" all {
  pass all flags S/SA keep state label "jailone"
}
anchor "two" all {
  pass all flags S/SA keep state label "jailtwo"
}

What's your pf.conf? (I've also tried having 'anchor "jail/*"' in my pf.conf and populating the anchors separately, but that also seems to just work.
Comment 2 Lexi Winter freebsd_committer freebsd_triage 2026-08-26 13:29:30 UTC
i could reproduce this on main (57775b3be6be, from today) with this pf.conf:

--->o---
pass in no state
pass out no state

anchor "test/*"
--->o---

for example:

--->o---
# pfctl -s rules
pass in all no state
pass out all no state
anchor "test/*" all

# echo 'pass in' | pfctl -a test/testing -f -

# pfctl -a '*' -sr
pass in all no state
pass out all no state
anchor "test/*" all {
  anchor "testing" all {
    pass in all flags S/SA keep state
  }
}

# pfctl -a 'test/*' -sr
#
--->o---
Comment 3 commit-hook freebsd_committer freebsd_triage 2026-08-26 15:39:56 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=5de5140f06959f2724c626c7fab3e1c9187beefb

commit 5de5140f06959f2724c626c7fab3e1c9187beefb
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2026-08-26 14:52:07 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2026-08-26 15:03:58 +0000

    pfctl: fix printing of wildcard anchors

    PR:             297839
    MFC after:      1 week
    Obtained from:  OpenBSD, henning <henning@openbsd.org>, 5b6657d4d8
    Sponsored by:   Rubicon Communications, LLC ("Netgate")

 sbin/pfctl/pfctl.c             | 10 ++++++----
 tests/sys/netpfil/pf/anchor.sh | 30 ++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 4 deletions(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2026-09-03 14:04:17 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=678f107b5c7898570d33d9667217e8901fdc79c6

commit 678f107b5c7898570d33d9667217e8901fdc79c6
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2026-08-26 14:52:07 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2026-09-03 14:03:04 +0000

    pfctl: fix printing of wildcard anchors

    PR:             297839
    MFC after:      1 week
    Obtained from:  OpenBSD, henning <henning@openbsd.org>, 5b6657d4d8
    Sponsored by:   Rubicon Communications, LLC ("Netgate")

    (cherry picked from commit 5de5140f06959f2724c626c7fab3e1c9187beefb)

 sbin/pfctl/pfctl.c             | 10 ++++++----
 tests/sys/netpfil/pf/anchor.sh | 30 ++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 4 deletions(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2026-09-03 14:04:18 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=70b70acec7797961e6c6a8810b8fac4ca3dddd30

commit 70b70acec7797961e6c6a8810b8fac4ca3dddd30
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2026-08-26 14:52:07 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2026-09-03 14:03:15 +0000

    pfctl: fix printing of wildcard anchors

    PR:             297839
    MFC after:      1 week
    Obtained from:  OpenBSD, henning <henning@openbsd.org>, 5b6657d4d8
    Sponsored by:   Rubicon Communications, LLC ("Netgate")

    (cherry picked from commit 5de5140f06959f2724c626c7fab3e1c9187beefb)

 sbin/pfctl/pfctl.c             | 10 ++++++----
 tests/sys/netpfil/pf/anchor.sh | 30 ++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 4 deletions(-)