Page MenuHomeFreeBSD

inpcb: Factor out parts of in6_pcbbind() and in_pcbbind_setup()
ClosedPublic

Authored by markj on Nov 15 2024, 3:55 PM.
Tags
None
Referenced Files
F160283850: D47590.id146521.diff
Mon, Jun 22, 10:28 PM
Unknown Object (File)
Sun, Jun 21, 2:18 PM
Unknown Object (File)
Sun, Jun 14, 5:11 AM
Unknown Object (File)
Sat, Jun 13, 7:32 PM
Unknown Object (File)
May 12 2026, 12:40 AM
Unknown Object (File)
May 12 2026, 12:40 AM
Unknown Object (File)
May 12 2026, 12:17 AM
Unknown Object (File)
May 10 2026, 12:30 AM
Subscribers

Details

Summary

A large portion of these functions just determines whether the inpcb can
bind to the address/port. This portion has no side effects, so is a
good candidate to move into its own helper function. This patch does
so, making the callers less complicated and reducing indentation.

While moving this code, also make some changes:

  • Load socket options (SO_REUSEADDR etc.) only once. There is nothing preventing another thread from toggling the socket options, so make this function easier to reason about by avoiding races.
  • When checking whether the bind address is an interface address, make a separate sockaddr rather than temporarily modifying the one passed to in_pcbbind().

No functional change intended.

Sponsored by: Klara, Inc.
Sponsored by: Stormshield

Diff Detail

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