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

Consider adding routing capabilities to tcp_proxy #345

Closed
enricoschiattarella opened this issue Jan 11, 2017 · 9 comments
Closed

Consider adding routing capabilities to tcp_proxy #345

enricoschiattarella opened this issue Jan 11, 2017 · 9 comments
Labels
enhancement Feature requests. Not bugs or questions.
Milestone

Comments

@enricoschiattarella
Copy link
Contributor

Currently the tcp_proxy network filter can only open connections to hosts belonging to a single cluster specified by name in the configuration.

We propose the addition of an optional list of L3/L4 routing rules pointing to specific clusters by name.
The rules would be examined in-order and the first rule to match would be applied.

A rule would consist of a cluster name and 1 or more match criteria from this set:

  • src ip address (with optional subnet mask)
  • original destination ip address (with optional subnet mask). This is useful if the connection has been redirected with iptables
  • src TCP port
  • original destination port (might be different from listener port due to redirect)

If all specified match criteria are satisfied (src/dst ports are equal to the provided number, src/dest IP addresses belong to the range), the connection is opened towards the cluster named in the rule.

Later on we can add probabilistic fall-through similar to http_connection_manager routes.

The "cluster" parameter currently defined at the filter level becomes the default cluster (used if no rules match). If it is not defined (assuming it will become optional) the connection is terminated.

If the feature looks useful and the proposal reasonable, I will start filling in the details of the configuration model and the implementation.

@mattklein123
Copy link
Member

@enricoschiattarella this sounds reasonable and useful. As you suggest, I agree a good next step would be to do a short proposal of the route config schema (here or in doc) and we can all review.

@mattklein123
Copy link
Member

P.S., longer term it would also be pretty cool/useful to put rate limit stuff directly into the TCP route configuration much like @ccaraman is now working on for HTTP. As long as we have a generic TCP route table config it should be easy to extend in the future.

@enricoschiattarella
Copy link
Contributor Author

enricoschiattarella commented Jan 13, 2017

tcp_proxy configuration example

{
  "port": 8082,
  "filters": [
    {
      "type": "read",
      "name": "tcp_proxy",
      "config": {
        // Config-level "cluster" parameter becomes mutually-exclusive 
        // with route_config block. Exactly one of the two must be specified.
        // "cluster": "service2",
        "stat_prefix": "tcp"
        "route_config": {
          "routes": [
            // Routes are examined in order. The first match is used. 
            // If no rule matches the connection is dropped.
            {  
             // Any combination of source_ip, destination_ip, 
             //source_port, destination_port can be specified  

              // matches addresses in the range 192.168.0.0 - 192.168.0.255
              "source_ip": "192.168.0.0/24",

              // exact match, equivalent to "10.10.10.10/32"
              "destination_ip": "10.10.10.10",

              // destination port must be in range 1-1024 OR 2048-4096 OR be equal to 12345
              "destination_port": "1-1024,2048-4096,12345", 

              // if the match criteria for source_ip AND destination_ip AND destination_port
              // are satisfied, open the connection to cluster "service1".
              // source_port is ignored because it is not specified
              "cluster": "service1" // required
            },
            { 
              // this route has no criteria to satisfy, so it always matches
              // typically it is the last route, providing a default (as in "last resort") cluster
              "cluster": "service2"
            }
        ]      
      }     
    }                                                                                        
  ]   
}

@mattklein123
Copy link
Member

@enricoschiattarella personally I would vote to just get rid of the config-level cluster param and make everyone specify the route table config. It's more verbose and a breaking change but IMO it's better to have one config type if possible. I don't have a strong opinion on this if others feel differently though.

re: destination IP/port, we will obviously have to expose this out of the connection interface since we don't do this currently. This should't be difficult.

Otherwise this all seems reasonable to me.

@enricoschiattarella
Copy link
Contributor Author

@mattklein123 Thanks, Matt.
I will start working on it and continue this thread if other non-straightforward design choices come up.

@mattklein123 mattklein123 added the enhancement Feature requests. Not bugs or questions. label Jan 17, 2017
enricoschiattarella pushed a commit to enricoschiattarella/envoy that referenced this issue Jan 25, 2017
Allows the tcp_proxy filter to pick the destination cluster based
on a combination of L4 connection parameters (source/destination
IP address/port)

See envoyproxy#345
@mattklein123 mattklein123 added this to the 1.2.0 milestone Jan 29, 2017
@mattklein123
Copy link
Member

implemented

PiotrSikora referenced this issue in istio/envoy Jan 25, 2020
* expr_api

Signed-off-by: Kuat Yessenov <kuat@google.com>
kyessenov added a commit to kyessenov/envoy that referenced this issue Feb 6, 2020
* expr_api

Signed-off-by: Kuat Yessenov <kuat@google.com>
kyessenov referenced this issue in istio/envoy Feb 6, 2020
implement expression evaluation in Wasm (#345)
@abhinav1998agarwal
Copy link

abhinav1998agarwal commented Feb 16, 2021

Hey! I am looking for the api reference corresponding to this TCP routing on https://www.envoyproxy.io/docs/envoy/v1.12.1/configuration/listeners/network_filters/tcp_proxy_filter#config-network-filters-tcp-proxy , but unable to find. @PiotrSikora , @kyessenov can you guide me to the api reference for this TCP routing.

@YvesZHI
Copy link

YvesZHI commented Oct 17, 2022

So have these functions been merged into Envoy? I'm working with Envoy V1.22.0 but there doesn't exist a route_config in the TcpProxy...

@abhinav1998agarwal
Copy link

abhinav1998agarwal commented Oct 17, 2022

@YvesZHI Please check https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/listener/v3/listener_components.proto#config-listener-v3-filterchainmatch to perform layer 4 routing.

jpsim pushed a commit that referenced this issue Nov 28, 2022
Description: comment describing current ordering between setup_envoy and run_engine in the main_interface.
Risk Level: low - code comment

Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit that referenced this issue Nov 29, 2022
Description: comment describing current ordering between setup_envoy and run_engine in the main_interface.
Risk Level: low - code comment

Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: JP Simard <jp@jpsim.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests. Not bugs or questions.
Projects
None yet
Development

No branches or pull requests

4 participants