Page MenuHomeFreeBSD

divert: Define semantics for SO_REUSEPORT_LB on divert sockets
ClosedPublic

Authored by markj on Apr 21 2026, 7:36 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Jul 8, 11:52 AM
Unknown Object (File)
Wed, Jun 24, 7:52 AM
Unknown Object (File)
Wed, Jun 17, 10:52 AM
Unknown Object (File)
Tue, Jun 16, 11:09 AM
Unknown Object (File)
Jun 5 2026, 6:56 PM
Unknown Object (File)
Jun 4 2026, 10:47 AM
Unknown Object (File)
May 25 2026, 3:53 AM
Unknown Object (File)
May 19 2026, 10:06 AM

Details

Summary

Allow SO_REUSEPORT_LB to be set on divert sockets. If set, then bind()
will add the socket to a "load-balancing group". When a divert-to rule
matches a port with an associated group, the corresponding state ID is
used to select a specific socket from the group. Packets without an
associated state are simply forwarded to the first socket in the group.
For now I only pass a state ID from pf, as I couldn't see a useful
identifier on the ipfw side.

This implementation is simple but has some caveats, the main one being
that if sockets are added to the group while flows are being processed,
the size of the group will change and this changes the mapping of state
IDs to sockets. So, to get a consistent mapping, the divert socket
application must bind all of its sockets before any traffic is processed
by pf.

Diff Detail

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