Page MenuHomeFreeBSD

Improve pfctl rule load times with thousands of interfaces

Authored by on Mar 17 2020, 5:04 PM.
Referenced Files
Unknown Object (File)
Tue, Mar 21, 8:41 PM
Unknown Object (File)
Sat, Mar 4, 10:56 AM
Unknown Object (File)
Jan 15 2023, 4:18 AM
Unknown Object (File)
Dec 24 2022, 4:11 AM
Unknown Object (File)
Nov 30 2022, 4:27 AM
Unknown Object (File)
Nov 26 2022, 5:58 PM



r343287 / D18759 introduced ifa_add_groups_to_map() which is now run by ifa_load/ifa_lookup/host_if. When loading an anchor or ruleset via pfctl that does NOT contain ifnames as hosts, host() still ends up iterating all interfaces twice, grabbing SIOCGIFGROUP ioctl twice for each. This adds an unnecessary amount of time on systems with thousands or tens of thousands of interfaces.

Prioritize the IPv4/6 check over the interface name lookup, which skips loading the iftab and iterating all interfaces when the configuration does not contain interface names.

Diff Detail

rS FreeBSD src repository - subversion
Lint Not Applicable
Tests Not Applicable

Event Timeline

At first glance that looks very reasonable. I'm building world with your change for a quick run through the tests, but I expect those to be fine.
I should be able to commit this in the next day or two.

This revision was not accepted when it landed; it landed in state Needs Review.Mar 19 2020, 12:54 PM
This revision was automatically updated to reflect the committed changes.