Bug 262971 - pfctl: can't start pf or clear rules, DIOCADDRULENV, pfctl_clear_eth_rules: Device busy
Summary: pfctl: can't start pf or clear rules, DIOCADDRULENV, pfctl_clear_eth_rules: D...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: arm64 Any
: --- Affects Only Me
Assignee: Mateusz Guzik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-01 07:03 UTC by Dave Cottlehuber
Modified: 2022-04-01 18:03 UTC (History)
1 user (show)

See Also:


Attachments
pf.conf (1.59 KB, text/plain)
2022-04-01 07:03 UTC, Dave Cottlehuber
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Cottlehuber freebsd_committer freebsd_triage 2022-04-01 07:03:41 UTC
Created attachment 232853 [details]
pf.conf

on reboot, pf doesn't start from rc.conf phase. I'm assuming this is some
malformed pf.conf on my side, but a line or rule # might help.

Enabling pfpfctl: DIOCADDRULENV: Invalid argument
/etc/rc: WARNING: Unable to load /etc/pf.conf.

pf.conf is attached:

# pfctl -vge -F all -f /etc/pf.conf
No ALTQ support in kernel
ALTQ related functions disabled
pfctl: pfctl_clear_eth_rules: Device busy

Seems to have broken between src commit aeb91e9 & 7d1ab86

a minimal test case is using pf.empty, literally an empty file:

# pfctl -vegf /etc/pf.empty
No ALTQ support in kernel
ALTQ related functions disabled
pfctl: pfctl_rules

# pfctl -F all
pfctl: pfctl_clear_eth_rules: Device busy
Comment 1 Mateusz Guzik freebsd_committer freebsd_triage 2022-04-01 15:39:24 UTC
try this: https://people.freebsd.org/~mjg/pf-rules.diff

you need to build libpfctl, pfctl and the kernel
Comment 2 commit-hook freebsd_committer freebsd_triage 2022-04-01 18:02:25 UTC
A commit in branch main references this bug:

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

commit c4a08ef2af6fe0b0d1b03f7ec4f20bed96de20e8
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2022-04-01 15:04:03 +0000
Commit:     Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2022-04-01 18:01:48 +0000

    pf: handle duplicate rules gracefully

    Reviewed by:    kp
    Reported by:    dch
    PR:             262971
    Sponsored by:   Rubicon Communications, LLC ("Netgate")

 lib/libpfctl/libpfctl.c   |  2 ++
 sbin/pfctl/pfctl.c        | 19 +++++++++++++++++--
 sys/netpfil/pf/pf_ioctl.c |  5 +++--
 3 files changed, 22 insertions(+), 4 deletions(-)
Comment 3 Mateusz Guzik freebsd_committer freebsd_triage 2022-04-01 18:03:27 UTC
provided testcase passes now for me, it also passes internal testing

please reopen if there are still issues