Bug 294858 - pfctl -o none fails to skip optimization
Summary: pfctl -o none fails to skip optimization
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 15.1-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: Kristof Provost
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-04-29 00:48 UTC by Andrew Philips
Modified: 2026-06-11 20:23 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Philips 2026-04-29 00:48:28 UTC
OS: 15.0-RELEASE-p6 FreeBSD 15.0-RELEASE-p6 GENERIC amd64

Expected behavior:

pfctl -o none should skip pf rule optimization.

Observed behavior:

pfctl -o none fails to skip optimization.

# Example: pf.conf
block in tagged FOO
pass in tag FOO
block in tagged FOO

> pfctl -o none -vnf pf.conf
block drop in all tagged FOO
pass in all flags S/SA keep state tag FOO
block drop in all tagged FOO

> pfctl -vf pf.conf
No ALTQ support in kernel
ALTQ related functions disabled
block drop in all tagged FOO
pass in all flags S/SA keep state tag FOO
block drop in all tagged FOO -- rule was already present

> pfctl -sr
block drop in all tagged FOO
pass in all flags S/SA keep state tag FOO

Turning optimizer off within the file also fails:

# Example: pf-set-opt-off.conf
set ruleset-optimization none
block in tagged FOO
pass in tag FOO
block in tagged FOO

> pfctl -vf pf-set-opt-off.conf
No ALTQ support in kernel
ALTQ related functions disabled
block drop in all tagged FOO
pass in all flags S/SA keep state tag FOO
block drop in all tagged FOO -- rule was already present
Comment 1 commit-hook freebsd_committer freebsd_triage 2026-05-05 21:26:33 UTC
A commit in branch main references this bug:

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

commit a0e4c65f1814a7a677364dc29bb703f84323d175
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2026-04-29 15:04:44 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2026-05-05 20:20:42 +0000

    pf: do not reject rules with colliding hashes

    We insert rules in pf_krule_global solely for the benefit of the
    'keepcounters' feature. Failing to insert (beause the rule hash
    collides, or an identical rule already exists) would be worse than
    restoring counts to the wrong rule (or failing to restore them at all).

    PR:             282863, 294860, 294859, 294858
    MFC after:      3 days
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D56745

 sys/netpfil/pf/pf_ioctl.c     | 24 ++++++++----------------
 tests/sys/netpfil/pf/match.sh | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 16 deletions(-)
Comment 2 commit-hook freebsd_committer freebsd_triage 2026-05-09 13:31:00 UTC
A commit in branch stable/15 references this bug:

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

commit fab9bfc92751ac7c676a2f59e44c5ce5ff414e20
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2026-04-29 15:04:44 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2026-05-09 08:06:01 +0000

    pf: do not reject rules with colliding hashes

    We insert rules in pf_krule_global solely for the benefit of the
    'keepcounters' feature. Failing to insert (beause the rule hash
    collides, or an identical rule already exists) would be worse than
    restoring counts to the wrong rule (or failing to restore them at all).

    PR:             282863, 294860, 294859, 294858
    MFC after:      3 days
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D56745

    (cherry picked from commit a0e4c65f1814a7a677364dc29bb703f84323d175)

 sys/netpfil/pf/pf_ioctl.c     | 24 ++++++++----------------
 tests/sys/netpfil/pf/match.sh | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 16 deletions(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2026-05-09 13:31:01 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=0cd655f71b46ada2c353c371e2a2f9f0dac29613

commit 0cd655f71b46ada2c353c371e2a2f9f0dac29613
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2026-04-29 15:04:44 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2026-05-09 13:29:04 +0000

    pf: do not reject rules with colliding hashes

    We insert rules in pf_krule_global solely for the benefit of the
    'keepcounters' feature. Failing to insert (beause the rule hash
    collides, or an identical rule already exists) would be worse than
    restoring counts to the wrong rule (or failing to restore them at all).

    PR:             282863, 294860, 294859, 294858
    MFC after:      3 days
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D56745

    (cherry picked from commit a0e4c65f1814a7a677364dc29bb703f84323d175)

 sys/netpfil/pf/pf_ioctl.c     | 24 ++++++++----------------
 tests/sys/netpfil/pf/match.sh | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 16 deletions(-)
Comment 4 Mark Linimon freebsd_committer freebsd_triage 2026-06-11 20:23:17 UTC
^Triage: committed and MFCed.