"ipfw zero" and "ipfw resetlog" without a rule number send a range
with IPFW_RCFLAG_ALL. ipfw_match_range() never matches a rule in set
31 for that flag, which keeps those rules on "ipfw flush", and
clear_range() goes through the same check. So the counters of the
default rule, of the orphaned dynamic states counter and of user
rules in set 31 were never cleared, and a set 31 rule that reached
its logamount never logged again; only an explicit rule number, as
in "ipfw zero 65535", reached them. ipfw(8) lists no such
exception, and before the IP_FW3 rework zero_entry() cleared every
rule.
IPFW_RCFLAG_DEFAULT is set only by clear_range() and cannot come
from userland. Skip set 31 for IPFW_RCFLAG_ALL only when it is
clear, so flush and move requests keep their behaviour.
New test in tests/sys/netpfil/ipfw/zero.sh:
- zero_all: "ipfw zero" clears a rule in set 0, a rule in set 31, the orphaned dynamic states counter and the default rule.
It fails without the fix. "ipfw resetlog" takes the same path
through clear_range() and only log output shows its effect, so it
has no case of its own.
Fixes: a73d728d3164 ("Switch ipfw(8) to use new opcodes")
MFC after: 2 weeks
Assisted-by: Claude Opus 5.5