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
Unknown Object (File)
Sat, May 18, 11:43 AM
Unknown Object (File)
May 3 2024, 1:46 AM
Unknown Object (File)
Apr 27 2024, 1:38 AM
Unknown Object (File)
Apr 26 2024, 5:07 AM
Unknown Object (File)
Apr 23 2024, 8:54 AM
Unknown Object (File)
Apr 16 2024, 1:01 AM
Unknown Object (File)
Apr 15 2024, 5:31 PM
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