Skip to content

Transport socket for internal listeners #19274

Closed

Description

@kyessenov

Description: add support for custom transport socket options for the internal listeners.

Issue: Internal address in an HTTP connection pool assumes re-use of the TCP stream between multiple downstream HTTP requests. This is not always desired, e.g. if the internal listener partitions requests into multiple streams based on some request attributes, because it puts those attributes into the outer envelope upstream from the internal listener.

As an analogy, Proxy Protocol upstream transport uses the source address in the protocol header, which means HTTP connection pool establishes a new Proxy Protocol connection for different source addresses. The proposal is to generalize this behavior, so that internal listeners can serve as the generic L4 tunneling protocol encapsulation and define what request attributes to use to mux multiple L7 requests onto a single L4 stream.

Concretely, we would like to define a transport socket that enumerates the request attributes to use to form a hash when using an internal address. This would be a generalization of ProxyProtocolData.

It also makes sense to propagate this information to the internal address stream info by default (see [1]). It might also be desirable to declare the hash in the internal listener itself instead of the upstream internal address, this is up to discussion.

cc @lambdai @wjtracey

Reference:

  1. metadata transfer over internal listener.

Activity

  1. added
    enhancement
    triage
    on Dec 13, 2021
  2. added and removed
    triage
    on Dec 14, 2021
  3. kyessenov commented on Dec 14, 2021

    @kyessenov
    ContributorAuthor

    @alyssawilk For thoughts since it's related to ALPN propagation in transport socket options.

  4. alyssawilk commented on Dec 14, 2021

    @alyssawilk
    Contributor

    will that be relevant? I thought the config was basically
    one envoy filter chain --- internal upstream transport socket -- internal listener --- another envoy filter chain --- upstream
    where there would be no ALPN on the intenal hop, and the upstream hop wouldn't have any internal config?

  5. kyessenov commented on Dec 14, 2021

    @kyessenov
    ContributorAuthor

    ALPN is not directly relevant. But I'd appreciate your expertise in the HTTP CONNECT and transport socket areas in how to extend xDS here. The pathological case is setting some HTTP header on HTTP CONNECT from first downstream HTTP request, e.g.

    HTTP request with header X = Y -- internal upstream transport socket -- internal listener -- HTTP CONNECT tcp_proxy that sets header X = Y.

    The basic proposal is to add config to internal upstream transport socket that says something like "add header X to hash"

  6. lambdai commented on Jan 7, 2022

    @lambdai
    Contributor

    @kyessenov @alyssawilk

    The ALPN concern should be extended to any "out-of-band" connection data.

    If we zoom into the connection establish phase, we can see it's asynchronous

    1. router request a "connection" from the cluster providing the transport socket
    2. the cluster return the router a established "connection" asynchronously. The transport socket object of the returned connection may not be the exact one. That's the point of the conn pool.

    That says, the connection pool must track what connections are exchangeable and the connection pool key is used.

    The de facto is that the conn pool key combines the router setting(e.g. use downstream connection id as key) and transport socket setting(alpn and proxyprotocol address).

    The proposed new transport socket protocol demands more context participating in the conn key

  7. alyssawilk commented on Jan 10, 2022

    @alyssawilk
    Contributor

    This may be naive but I'm not sure if we can do all of that? I would think we'd be doing a literal replacement of the 2 hop system with a 1 hop system. right now you generally wouldn't configure the loopback upstream with "do alpn" or "add a proxy protocol header", you'd rely on the actual upstream to do that. Similarly we wouldn't expect the loopback upstream to be able to infer what the next hop upstream would do.
    Now there's definitely areas where we're going to want to communicate information from one hop to the next - ideally I'd think we'd want to communicate actual ALPN negotiated or second hop upstream info. I wonder if we can make the upstream stream info a shared pointer, and have the virtual loopback one just point to the actual upstream stream info once it has been established?

  8. alyssawilk commented on Jan 10, 2022

    @alyssawilk
    Contributor

    alternately, potentially also naive, do we need the full listener stack for this? in-house when we do http/2 over http/2 we don't mock out the equivalent of the entire filter chain, we do a more simple pre-processing. The Envoy mobile stack has the ability to create a virtual codec getting headers, body, and data, and put them through an HCM, and if the use case here is 2 rounds of HTTP processing, we could have the upstream request do something similar to that. That said if you need the two hops to handle [tcp/http http/tcp http/http tcp/tcp] and not just [http/http] the current route is definitely more flexible

  9. kyessenov commented on Jan 10, 2022

    @kyessenov
    ContributorAuthor

    @alyssawilk In general, I agree that "flattened" version would probably be simpler and more efficient. E.g. something like upstream network filters for muxing and listener filters for de-muxing. We are not ruling out that option long term. We actually spent a long time arguing that. But currently, we think it's more flexible to have 2 hop solution because it lets us do things:

    • avoid complete re-design of xDS in the control plane, chaining two listeners is easier to accomplish in convoluted control plane code;
    • explore some "layer-breaking" protocols, like TLS within HTTP. Envoy makes it hard to plug network-level features like listener filter chain matching or sniffing within HCM.

    What we essentially would like from internal listeners now is a mechanism to define a custom transport protocol (e.g. think of ability to write custom TLS encoder as an extension). Hence, we want a flexible integration with HTTP pooling that takes into account additional transport socket options.

  10. lambdai commented on Jan 10, 2022

    @lambdai
    Contributor

    In short term we'd like to assume all the downstream traffic is tcp, so 2 rounds of HTTP processing does not happen.

    The longer term plan is to support parsing downstream http GET to upstream http CONNECT.

    What is the shortest path to achieve? My understanding is that HCM cannot magically create CONNECT request from a non-CONNECT request.

  11. kyessenov commented on Feb 8, 2022

    @kyessenov
    ContributorAuthor

    This is a diagram for composition with the internal listener. The gist is that internal listener allows us to implement a custom transport socket using existing primitives from listener (filters, chains, etc):

    internal-composition.pdf

    @mattklein123 FYI.

  12. kyessenov commented on Feb 14, 2022

    @kyessenov
    ContributorAuthor

    To elaborate more on the wire specifics, and provide more context for the above diagram:

    Consider an originating connection to service X:80 from pod A. Normally, X VIP would resolve to some member pod-port B:8080. If we want Envoy to proxy this traffic, we would use EDS for X and have a regular TCP connection to B:8080.

    Our goal is to wrap this connection into a shared, secure tunnel in the form of HTTP CONNECT inside mTLS. So what we would like to Envoy to produce is:

    • TLS to B:xxxx where xxxx is some random reserved port.
    • h2 connection within TLS
    • h2 CONNECT stream sending the original connection byte stream within h2 connection with the following identifying headers:
      • source-ip: A
      • destination-ip: B
      • destination-port: 8080

    Because we need to place the resolved address into the tunnel headers, we have to perform EDS resolution prior to initiating CONNECT request in HCM. Hence, the need arises for the two-phase internal listener design. We also have additional policies and telemetry that need to be applied in the internal (tunnel) listener. Because we would like to avoid creating internal listeners for each service and/or each member pod, we would like these policies to be expressed on the internal listener in terms of dynamic metadata and filter state that are propagated from the original listener.

  13. github-actions commented on Mar 17, 2022

    @github-actions

    This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

  14. added
    stale
    on Mar 17, 2022
  15. kyessenov commented on Mar 17, 2022

    @kyessenov
    ContributorAuthor
  16. removed
    stale
    on Mar 17, 2022
  17. added
    help wanted
    and removed
    enhancement
    on Apr 3, 2022
  18. added a commit that references this issue on Jun 23, 2022
    637a92a
  19. added a commit that references this issue on Jun 28, 2022
    4004f5f
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