Skip to content

udp: default-on SO_REUSEPORT doesn't work with listening on port 0 #19283

Open

Description

@danzh2010

This is for tracking the issue we discussed about SO_REUSEPORT in #19188. In Linux, if multiple Envoy instances are all configured to listen on port 0 for their UDP listeners, they may end up sharing the same port because of the default-on SO_REUSEPORT socket option if they are under the same user ID. This kernel behavior somewhat aligns with the contract of binding port 0 and SO_REUSEPORT. And a similar issue is explored here https://gavv.github.io/articles/ephemeral-port-reuse/.

This unexpected behavior was uncovered in QUIC integration tests because it affects UDP listeners which do not listen() more than TCP listeners. Currently SO_REUSEPORT is disabled in most of the integration tests(#19188) to prevent parallel bazel tests sharing the same port.

The mitigation is only in tests, not in production. Given that we aren't aware of any use case where Envoy is configured to listen on port 0 in production. But if there is, the Envoy should also explicitly disable SO_REUSEPORT like #19188 does. If both SO_REUSEPORT and listening on port 0 are desired, we need to revisit this issue and look into more sound solution, i.e. making Envoy manage a pool of ports.

Activity

  1. added
    triage
    on Dec 14, 2021
  2. added
    enhancement
    and removed
    triage
    on Dec 15, 2021
  3. phlax commented on Dec 15, 2021

    @phlax
    Member
  4. added
    help wanted
    and removed
    enhancement
    on Dec 15, 2021
  5. ankatare commented on Dec 28, 2021

    @ankatare
    Contributor

    Seems interesting. I would like to take this.

  6. danzh2010 commented on Jan 5, 2022

    @danzh2010
    ContributorAuthor

    @ankatare this issue is mitigated in test already. Are you running into the same issue in production so that a more comprehensive solution is needed?

  7. ankatare commented on Jan 6, 2022

    @ankatare
    Contributor

    @danzh2010 Ohh.got it. We are not using envoy in production

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions