From a8602cd5d43c8c3cfe4b5a2ffefd5d37fbb7ea1a Mon Sep 17 00:00:00 2001 From: "data-plane-api(CircleCI)" Date: Fri, 1 Nov 2019 22:32:57 +0000 Subject: [PATCH] tcp proxy: use source IP for tcp proxy hash (#8778) Signed-off-by: Yan Xue Mirrored from https://github.com/envoyproxy/envoy @ 174ba21bb88b7d50d0b7efeefd0c43268b2afd5e --- .../config/filter/network/tcp_proxy/v2/BUILD | 1 + .../network/tcp_proxy/v2/tcp_proxy.proto | 8 +++++- .../filter/network/tcp_proxy/v3alpha/BUILD | 1 + .../network/tcp_proxy/v3alpha/tcp_proxy.proto | 8 +++++- envoy/type/hash_policy.proto | 25 +++++++++++++++++++ envoy/type/v3alpha/hash_policy.proto | 25 +++++++++++++++++++ 6 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 envoy/type/hash_policy.proto create mode 100644 envoy/type/v3alpha/hash_policy.proto diff --git a/envoy/config/filter/network/tcp_proxy/v2/BUILD b/envoy/config/filter/network/tcp_proxy/v2/BUILD index 824463e4..7a003a9a 100644 --- a/envoy/config/filter/network/tcp_proxy/v2/BUILD +++ b/envoy/config/filter/network/tcp_proxy/v2/BUILD @@ -8,5 +8,6 @@ api_proto_package( deps = [ "//envoy/api/v2/core:pkg", "//envoy/config/filter/accesslog/v2:pkg", + "//envoy/type:pkg", ], ) diff --git a/envoy/config/filter/network/tcp_proxy/v2/tcp_proxy.proto b/envoy/config/filter/network/tcp_proxy/v2/tcp_proxy.proto index fe66fff1..889a9a0c 100644 --- a/envoy/config/filter/network/tcp_proxy/v2/tcp_proxy.proto +++ b/envoy/config/filter/network/tcp_proxy/v2/tcp_proxy.proto @@ -9,6 +9,7 @@ option java_package = "io.envoyproxy.envoy.config.filter.network.tcp_proxy.v2"; import "envoy/api/v2/core/address.proto"; import "envoy/api/v2/core/base.proto"; import "envoy/config/filter/accesslog/v2/accesslog.proto"; +import "envoy/type/hash_policy.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/wrappers.proto"; @@ -18,7 +19,7 @@ import "validate/validate.proto"; // [#protodoc-title: TCP Proxy] // TCP Proxy :ref:`configuration overview `. -// [#next-free-field: 11] +// [#next-free-field: 12] message TcpProxy { // [#not-implemented-hide:] Deprecated. // TCP Proxy filter configuration using V1 format. @@ -148,4 +149,9 @@ message TcpProxy { // The maximum number of unsuccessful connection attempts that will be made before // giving up. If the parameter is not specified, 1 connection attempt will be made. google.protobuf.UInt32Value max_connect_attempts = 7 [(validate.rules).uint32 = {gte: 1}]; + + // Optional configuration for TCP proxy hash policy. If hash_policy is not set, the hash-based + // load balancing algorithms will select a host randomly. Currently the number of hash policies is + // limited to 1. + repeated type.HashPolicy hash_policy = 11 [(validate.rules).repeated = {max_items: 1}]; } diff --git a/envoy/config/filter/network/tcp_proxy/v3alpha/BUILD b/envoy/config/filter/network/tcp_proxy/v3alpha/BUILD index ba8540be..bd4f949a 100644 --- a/envoy/config/filter/network/tcp_proxy/v3alpha/BUILD +++ b/envoy/config/filter/network/tcp_proxy/v3alpha/BUILD @@ -8,5 +8,6 @@ api_proto_package( deps = [ "//envoy/api/v3alpha/core:pkg", "//envoy/config/filter/accesslog/v3alpha:pkg", + "//envoy/type/v3alpha:pkg", ], ) diff --git a/envoy/config/filter/network/tcp_proxy/v3alpha/tcp_proxy.proto b/envoy/config/filter/network/tcp_proxy/v3alpha/tcp_proxy.proto index a4f692ab..c8becda9 100644 --- a/envoy/config/filter/network/tcp_proxy/v3alpha/tcp_proxy.proto +++ b/envoy/config/filter/network/tcp_proxy/v3alpha/tcp_proxy.proto @@ -9,6 +9,7 @@ option java_package = "io.envoyproxy.envoy.config.filter.network.tcp_proxy.v3alp import "envoy/api/v3alpha/core/address.proto"; import "envoy/api/v3alpha/core/base.proto"; import "envoy/config/filter/accesslog/v3alpha/accesslog.proto"; +import "envoy/type/v3alpha/hash_policy.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/wrappers.proto"; @@ -18,7 +19,7 @@ import "validate/validate.proto"; // [#protodoc-title: TCP Proxy] // TCP Proxy :ref:`configuration overview `. -// [#next-free-field: 11] +// [#next-free-field: 12] message TcpProxy { // Allows for specification of multiple upstream clusters along with weights @@ -93,4 +94,9 @@ message TcpProxy { // The maximum number of unsuccessful connection attempts that will be made before // giving up. If the parameter is not specified, 1 connection attempt will be made. google.protobuf.UInt32Value max_connect_attempts = 7 [(validate.rules).uint32 = {gte: 1}]; + + // Optional configuration for TCP proxy hash policy. If hash_policy is not set, the hash-based + // load balancing algorithms will select a host randomly. Currently the number of hash policies is + // limited to 1. + repeated type.v3alpha.HashPolicy hash_policy = 11 [(validate.rules).repeated = {max_items: 1}]; } diff --git a/envoy/type/hash_policy.proto b/envoy/type/hash_policy.proto new file mode 100644 index 00000000..077e2c25 --- /dev/null +++ b/envoy/type/hash_policy.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; + +package envoy.type; + +option java_outer_classname = "HashPolicyProto"; +option java_multiple_files = true; +option java_package = "io.envoyproxy.envoy.type"; + +import "validate/validate.proto"; + +// [#protodoc-title: Hash Policy] + +// Specifies the hash policy +message HashPolicy { + // The source IP will be used to compute the hash used by hash-based load balancing + // algorithms. + message SourceIp { + } + + oneof policy_specifier { + option (validate.required) = true; + + SourceIp source_ip = 1; + } +} diff --git a/envoy/type/v3alpha/hash_policy.proto b/envoy/type/v3alpha/hash_policy.proto new file mode 100644 index 00000000..88cabee2 --- /dev/null +++ b/envoy/type/v3alpha/hash_policy.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; + +package envoy.type.v3alpha; + +option java_outer_classname = "HashPolicyProto"; +option java_multiple_files = true; +option java_package = "io.envoyproxy.envoy.type.v3alpha"; + +import "validate/validate.proto"; + +// [#protodoc-title: Hash Policy] + +// Specifies the hash policy +message HashPolicy { + // The source IP will be used to compute the hash used by hash-based load balancing + // algorithms. + message SourceIp { + } + + oneof policy_specifier { + option (validate.required) = true; + + SourceIp source_ip = 1; + } +}