Page MenuHomeFreeBSD

Set SO_REUSEPORT socket option
Needs ReviewPublic

Authored by nkumarababu_gmail.com on Apr 13 2024, 3:07 AM.
Tags
None
Referenced Files
F132264405: D44771.id.diff
Wed, Oct 15, 7:47 AM
Unknown Object (File)
Sun, Sep 28, 7:31 PM
Unknown Object (File)
Sep 12 2025, 9:47 AM
Unknown Object (File)
Sep 8 2025, 2:08 PM
Unknown Object (File)
Sep 8 2025, 7:52 AM
Unknown Object (File)
Aug 18 2025, 1:28 PM
Unknown Object (File)
Aug 4 2025, 11:04 AM
Unknown Object (File)
Aug 1 2025, 2:17 AM
Subscribers

Details

Reviewers
rmacklem
Summary

SO_REUSEADDR is used to bind the socket in nfsd today. SO_REUSEADDR alone
might not help, if another socket is bound to exactly the same combination
of source address and port. Bind fails with EADDRINUSE, if that is the
case, even with SO_REUSEADDR.

If NFSD exited abruptly due to some error and is started again, there is
a delay in freeing the port and when it is attempted to bind again with
same source address and port, it fails with EADDRINUSE.

To address this, using SO_REUSEPORT helps. As the previous socket also
would have had this option set, subsequent bind succeeds even when there
is another socket bound to same source address and port.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 57077
Build 53965: arc lint + arc unit