Skip to content

Question about different listeners listen same port when enable_reuse_port set to true. #19099

Closed

Description

@pyrl247

When enable_reuse_port set to ture,different listeners can listen same port without error,and the accept behavior depand on kernel,maybe cause route unpredictable?

admin:
  address:
    socket_address: { address: 127.0.0.1, port_value: 9901 }
stats_config:
  stats_matcher:
    reject_all: true
static_resources:
  listeners:
    - name: listener_0
      address:
        socket_address:
          address: 0.0.0.0
          port_value: 8888
      filter_chains:
        - filters:
            - name: envoy.filters.network.tcp_proxy
              typed_config:
                "@type": type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy
                stat_prefix: destination
                cluster: cluster_0
    - name: listener_1
      address:
        socket_address:
          address: 0.0.0.0
          port_value: 8888
      filter_chains:
        - filters:
            - name: envoy.filters.network.tcp_proxy
              typed_config:
                "@type": type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy
                stat_prefix: destination
                cluster: cluster_1
  clusters:
    - name: cluster_0
      connect_timeout: 30s
      type: STATIC
      load_assignment:
        cluster_name: cluster_0
        endpoints:
          - lb_endpoints:
              - endpoint:
                  address:
                    socket_address:
                      address: 127.0.0.1
                      port_value: 5001
    - name: cluster_1
      connect_timeout: 30s
      type: STATIC
      load_assignment:
        cluster_name: cluster_1
        endpoints:
          - lb_endpoints:
              - endpoint:
                  address:
                    socket_address:
                      address: 127.0.0.1
                      port_value: 5002

Since envoy1.20 ,enable_reuse_port is default to true.
When use the static config above,the request to port 8888 will randomly route to cluster_0 or cluster_1.
Is that a reasonable behavior?

Activity

  1. added
    triage
    on Nov 25, 2021
  2. ggreenway commented on Nov 29, 2021

    @ggreenway
    Member

    No, this is a bug. The configuration should have failed validation in this case.

  3. added and removed
    triage
    on Nov 29, 2021
  4. ggreenway commented on Nov 29, 2021

    @ggreenway
    Member
  5. mattklein123 commented on Nov 29, 2021

    @mattklein123
    Member

    Yeah definitely a bug. I can look into fixing.

  6. self-assigned this
    on Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions