Page MenuHomeFreeBSD

pf: getstates: avoid taking the hashrow lock if the row is empty
ClosedPublic

Authored by kp on Jun 29 2021, 7:38 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 20 2024, 11:09 PM
Unknown Object (File)
Feb 20 2024, 7:30 AM
Unknown Object (File)
Jan 29 2024, 4:20 AM
Unknown Object (File)
Dec 20 2023, 6:09 AM
Unknown Object (File)
Dec 16 2023, 3:26 AM
Unknown Object (File)
Dec 14 2023, 10:17 PM
Unknown Object (File)
Dec 2 2023, 7:03 PM
Unknown Object (File)
Nov 28 2023, 10:32 AM

Diff Detail

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

Event Timeline

kp requested review of this revision.Jun 29 2021, 7:38 PM
This revision is now accepted and ready to land.Jun 30 2021, 2:04 PM
donner added inline comments.
sys/netpfil/pf/pf_ioctl.c
5058

Accessing this value without a lock ... may it cause a race condition?

sys/netpfil/pf/pf_ioctl.c
5058

It is a data race, but it is tolerable in this case. Absolute worst which can happen is that the row will be skipped when it should not be. But let's say garbage was read. The acquire fence provided by PF_HASHROW_LOCK below makes the previously read possibly bogus state irrelevant as it is forcibly refreshed.

sys/netpfil/pf/pf_ioctl.c
5058

That said ideally it would use a data structure which is safe to iterate in presence of modification. I have a rough sketch to implement this, so the state as proposed here should be temporary.