Allow custom local address resolvers. (#27705)

* Allow custom local address resolvers.

#27881 introduces the concept of EDS clusters with hosts that have multiple (potentially > 2) IP addresses.

The current implementation of UpstreamLocalAddressSelector limits the number of source addresses in BindConfig artificially to 2, and further requires that the addresses be of different address families.

The workaround for this (if we need to specify more than 2 source addresses or have multiple addresses from the same family) is to use a custom address resolver that resolves the bind config address to nullptr (and therefore ignore it) and call bind in a customised SocketInterfaceImpl to a local source address determined by the SocketInterfaceImpl specialisation.

This PR makes it possible to define a custom local address selector, that makes it easy to work with a custom address resolver to pick the right source address based on the upstream address selected by HappyEyeballsConnectionImpl

Signed-off-by: pcrao <pcrao@google.com>

Mirrored from https://github.com/envoyproxy/envoy @ da47a54a8ccbaa384c4cb62a5f4fcd4745a72c37
main
update-envoy[bot] 1 year ago
parent fc90f1b72c
commit 9d38187abc
  1. 1
      BUILD
  2. 19
      envoy/config/core/v3/address.proto
  3. 9
      envoy/config/upstream/local_address_selector/v3/BUILD
  4. 31
      envoy/config/upstream/local_address_selector/v3/default_local_address_selector.proto
  5. 1
      versioning/BUILD

@ -123,6 +123,7 @@ proto_library(
"//envoy/config/route/v3:pkg",
"//envoy/config/tap/v3:pkg",
"//envoy/config/trace/v3:pkg",
"//envoy/config/upstream/local_address_selector/v3:pkg",
"//envoy/data/accesslog/v3:pkg",
"//envoy/data/cluster/v3:pkg",
"//envoy/data/core/v3:pkg",

@ -2,6 +2,7 @@ syntax = "proto3";
package envoy.config.core.v3;
import "envoy/config/core/v3/extension.proto";
import "envoy/config/core/v3/socket_option.proto";
import "google/protobuf/wrappers.proto";
@ -130,7 +131,7 @@ message ExtraSourceAddress {
SocketOptionsOverride socket_options = 2;
}
// [#next-free-field: 6]
// [#next-free-field: 7]
message BindConfig {
option (udpa.annotations.versioning).previous_message_type = "envoy.api.v2.core.BindConfig";
@ -151,19 +152,21 @@ message BindConfig {
repeated SocketOption socket_options = 3;
// Extra source addresses appended to the address specified in the `source_address`
// field. This enables to specify multiple source addresses. Currently, only one extra
// address can be supported, and the extra address should have a different IP version
// with the address in the `source_address` field. The address which has the same IP
// version with the target host's address IP version will be used as bind address. If more
// than one extra address specified, only the first address matched IP version will be
// returned. If there is no same IP version address found, the address in the `source_address`
// will be returned.
// field. This enables to specify multiple source addresses.
// The source address selection is determined by :ref:`local_address_selector
// <envoy_v3_api_field_config.core.v3.BindConfig.local_address_selector>`.
repeated ExtraSourceAddress extra_source_addresses = 5;
// Deprecated by
// :ref:`extra_source_addresses <envoy_v3_api_field_config.core.v3.BindConfig.extra_source_addresses>`
repeated SocketAddress additional_source_addresses = 4
[deprecated = true, (envoy.annotations.deprecated_at_minor_version) = "3.0"];
// Custom local address selector to override the default (i.e.
// :ref:`DefaultLocalAddressSelector
// <envoy_v3_api_msg_config.upstream.local_address_selector.v3.DefaultLocalAddressSelector>`).
// [#extension-category: envoy.upstream.local_address_selector]
TypedExtensionConfig local_address_selector = 6;
}
// Addresses specify either a logical or physical address and port, which are

@ -0,0 +1,9 @@
# DO NOT EDIT. This file is generated by tools/proto_format/proto_sync.py.
load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package")
licenses(["notice"]) # Apache 2
api_proto_package(
deps = ["@com_github_cncf_udpa//udpa/annotations:pkg"],
)

@ -0,0 +1,31 @@
syntax = "proto3";
package envoy.config.upstream.local_address_selector.v3;
import "udpa/annotations/status.proto";
option java_package = "io.envoyproxy.envoy.config.upstream.local_address_selector.v3";
option java_outer_classname = "DefaultLocalAddressSelectorProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/envoy/config/upstream/local_address_selector/v3;local_address_selectorv3";
option (udpa.annotations.file_status).package_version_status = ACTIVE;
// [#protodoc-title: Default Local Address Selector]
// [#extension: envoy.upstream.local_address_selector.default_local_address_selector]
// Default implementation of a local address selector. This implementation is
// used if :ref:`local_address_selector
// <envoy_v3_api_field_config.core.v3.BindConfig.local_address_selector>` is not
// specified.
// This implementation supports the specification of only one address in
// :ref:`extra_source_addresses
// <envoy_v3_api_field_config.core.v3.BindConfig.extra_source_addresses>` which
// is appended to the address specified in the
// :ref:`source_address <envoy_v3_api_field_config.core.v3.BindConfig.source_address>`
// field. The extra address should have a different IP version than the address in the
// `source_address` field. The address which has the same IP
// version with the target host's address IP version will be used as bind address.
// If there is no same IP version address found, the address in the `source_address` field will
// be returned.
message DefaultLocalAddressSelector {
}

@ -61,6 +61,7 @@ proto_library(
"//envoy/config/route/v3:pkg",
"//envoy/config/tap/v3:pkg",
"//envoy/config/trace/v3:pkg",
"//envoy/config/upstream/local_address_selector/v3:pkg",
"//envoy/data/accesslog/v3:pkg",
"//envoy/data/cluster/v3:pkg",
"//envoy/data/core/v3:pkg",

Loading…
Cancel
Save