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

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

Closed
pyrl247 opened this issue Nov 25, 2021 · 3 comments · Fixed by #19145
Closed
Assignees

Comments

@pyrl247
Copy link
Contributor

pyrl247 commented Nov 25, 2021

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?

@pyrl247 pyrl247 added the triage Issue requires triage label Nov 25, 2021
@ggreenway
Copy link
Contributor

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

@ggreenway ggreenway added area/listener bug and removed triage Issue requires triage labels Nov 29, 2021
@ggreenway
Copy link
Contributor

cc @mattklein123

@mattklein123
Copy link
Member

Yeah definitely a bug. I can look into fixing.

@mattklein123 mattklein123 self-assigned this Nov 29, 2021
@mattklein123 mattklein123 added the help wanted Needs help! label Nov 29, 2021
mattklein123 added a commit that referenced this issue Nov 30, 2021
This bug existed previously, but with the recent reuse port
as the default change is now more obvious. Previously, we would
allow multiple listeners to listen on the same port, which is
obviously very wrong. This change blocks that at config load time.

Fixes #19099

Signed-off-by: Matt Klein <[email protected]>
mattklein123 added a commit that referenced this issue Dec 1, 2021
This bug existed previously, but with the recent reuse port
as the default change is now more obvious. Previously, we would
allow multiple listeners to listen on the same port, which is
obviously very wrong. This change blocks that at config load time.

Fixes #19099

Signed-off-by: Matt Klein <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants