Page MenuHomeFreeBSD

pf: use hashalloc(9) for key, id, src-node and udp-endpoint hashes
ClosedPublic

Authored by glebius on Mar 27 2026, 7:21 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 28, 1:01 AM
Unknown Object (File)
Mon, Apr 27, 4:01 PM
Unknown Object (File)
Fri, Apr 24, 1:06 AM
Unknown Object (File)
Sun, Apr 19, 12:20 AM
Unknown Object (File)
Sat, Apr 18, 9:55 PM
Unknown Object (File)
Sat, Apr 18, 9:51 PM
Unknown Object (File)
Tue, Apr 14, 12:24 PM
Unknown Object (File)
Mon, Apr 13, 2:52 PM

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

glebius added inline comments.
sys/netpfil/pf/pf.c
1434

.head = HASH_HEAD_LIST is not needed, but I decided to be more explicit.

glebius retitled this revision from pf: use hashalloc(9) for key and id hashes to pf: use hashalloc(9) for key, id, src-node and udp-endpoint hashes.Mar 28 2026, 6:59 PM
  • Extend to src-nodes and udp-endpoints hashes.
sys/netpfil/pf/pf.c
1435–1436

Initialization of .type and .head to the default values. May be omitted.

I'm seeing panics with this patch ("panic: lock "pf_keyhash" 0xfffffe00e8dffff8 already initialized").
I believe the problem is that hashalloc() allocates unzero'd memory, and which leads to incorrect assertions on the lock, if LO_INITIALIZED happens to be set in lo_flags.

In D56113#1284599, @kp wrote:

I'm seeing panics with this patch ("panic: lock "pf_keyhash" 0xfffffe00e8dffff8 already initialized").
I believe the problem is that hashalloc() allocates unzero'd memory, and which leads to incorrect assertions on the lock, if LO_INITIALIZED happens to be set in lo_flags.

That's because you have it on top of older version of D55904. In the updated version MTX_NEW is passed. For me this revision passes all pf tests.

Ah, yes, thanks!

This revision is now accepted and ready to land.Mar 30 2026, 8:03 PM