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
F159716619: D56563.id178629.diff
Wed, Jun 17, 10:52 AM
Unknown Object (File)
Tue, Jun 16, 11:09 AM
Unknown Object (File)
Fri, Jun 5, 6:56 PM
Unknown Object (File)
Thu, Jun 4, 10:47 AM
Unknown Object (File)
Mon, May 25, 3:53 AM
Unknown Object (File)
Tue, May 19, 10:06 AM
Unknown Object (File)
May 18 2026, 11:22 AM
Unknown Object (File)
May 18 2026, 11:18 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

Event Timeline

markj requested review of this revision.Apr 21 2026, 7:36 PM

P.S. Touch to raw_ip.c reminds me of my long desire to move those pointers to some more appropriate place at least.

This revision is now accepted and ready to land.Apr 21 2026, 8:01 PM

The pf change looks fine to me.