Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[erts, kernel] reuseaddr/reuseport/exclusiveaddruse support/fixes #6522

Conversation

rickard-green
Copy link
Contributor

@rickard-green rickard-green commented Nov 29, 2022

  • Introduce socket option reuseport which may or may not have load balancing.

  • Introduce socket option reuseport_lb with load balancing.

  • Introduce socket option exclusiveaddruse. This socket option is Windows specific and will silently be ignored on other systems.

  • Change behavior on Windows so that SO_REUSEADDR is only set if both reusaddr and reuseport have been set. This since SO_REUSEADDR on Windows behaves as BSD behaves if both SO_REUSEADDR and SO_REUSEPORT have been set.

@rickard-green rickard-green added team:PS Assigned to OTP team PS enhancement fix testing currently being tested, tag is used by OTP internal CI labels Nov 29, 2022
@rickard-green rickard-green added this to the OTP-26.0 milestone Nov 29, 2022
@rickard-green rickard-green self-assigned this Nov 29, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Nov 29, 2022

CT Test Results

       4 files     186 suites   1h 48m 1s ⏱️
2 857 tests 2 581 ✔️ 275 💤 1
3 449 runs  3 109 ✔️ 339 💤 1

For more details on these failures, see this check.

Results for commit 2ac142a.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@okeuday
Copy link
Contributor

okeuday commented Nov 30, 2022

@rickard-green There is a problem with using SO_REUSEPORT regarding its meaning on Linux and FreeBSD. FreeBSD had SO_REUSEPORT in the past, before it was present on Linux (mainly for UDP multicast usage probably) and Linux added the SO_REUSEPORT with extra load-balancing functionality. After that, FreeBSD added SO_REUSEPORT_LB to be equivalent to the SO_REUSEPORT option on Linux. Other BSDs also have the older meaning of SO_REUSEPORT, so all BSDs would need to have support for the SO_REUSEPORT_LB option to have the equivalent functionality to SO_REUSEPORT on Linux. So, you likely need to support reuseport and reuseportlb (or some other name) as separate options to avoid confusion.

@rickard-green
Copy link
Contributor Author

@okeuday Yes, your right. We probably need to expose the load balancing option as well.

@rickard-green rickard-green force-pushed the rickard/reuseaddr-reuseport-exclusiveaddruse/OTP-18344 branch from 2219019 to 2ac142a Compare December 1, 2022 01:38
@rickard-green
Copy link
Contributor Author

@okeuday

Added an reuseport_lb option as well (using FreeBSD's name for it).

reuseport is documented as may or may not be load balancing while reuseport_lb is documented as with load balancing. On Linux they will both set SO_REUSEPORT.

@okeuday
Copy link
Contributor

okeuday commented Dec 1, 2022

@rickard-green You may want to consider reuseport on Linux causing an error, due to lack of support, to ensure it represents the BSD-meaning of SO_REUSEPORT because the use-case of the BSD SO_REUSEPORT should be very different. The potential for the use of the BSD SO_REUSEPORT in Erlang is interesting too, even though load-balancing is not provided, because it could be used to have a backup TCP connection with a backup Erlang process to own the backup connection (it would be only used if the other Erlang process dies). However, doing something like that, would be clearly different from needing the BSD SO_REUSEPORT_LB functionality which is what people would normally use for ensuring TCP traffic is evenly distributed among Erlang processes. So, the reuseport_lb option use is likely more common to ensure efficient load-balancing can occur.

@KennethL KennethL modified the milestones: OTP-26.0, OTP-26.0-rc1 Feb 2, 2023
* Introduce socket option 'reuseport' which may or may not have
  load balancing.

* Introduce socket option 'reuseport_lb' with load balancing.

* Introduce socket option 'exclusiveaddruse'. This socket option is
  Windows specific and will silently be ignored on other systems.

* Change behavior on Windows so that SO_REUSEADDR is only set if
  both 'reusaddr' and 'reuseport' have been set. This since
  SO_REUSEADDR on Windows behaves as BSD behaves if both SO_REUSEADDR
  and SO_REUSEPORT have been set.
@rickard-green rickard-green force-pushed the rickard/reuseaddr-reuseport-exclusiveaddruse/OTP-18344 branch from 2ac142a to 27258e9 Compare February 2, 2023 17:57
@rickard-green
Copy link
Contributor Author

@okeuday We've decided not to error out when reuseport without load balancing is not available in this API. The socket API is expected to get a more fine-grained option API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement fix team:PS Assigned to OTP team PS testing currently being tested, tag is used by OTP internal CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants