Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
4cfa9c5
udp: add route proto
zhxie Aug 24, 2021
9891c45
udp: add router
zhxie Aug 25, 2021
367db00
udp: route data to clusters
zhxie Aug 25, 2021
3bd3085
udp: fix format
zhxie Aug 25, 2021
4c1b126
udp: minor type change
zhxie Aug 26, 2021
3f762f7
udp: clean code
zhxie Aug 26, 2021
95e1094
test: add test for routing in UDP proxy
zhxie Aug 26, 2021
b592612
test: add test for route matching of UDP proxy
zhxie Aug 26, 2021
804aedd
test: fix format
zhxie Aug 26, 2021
37def08
udp: deprecate api in favor of router
zhxie Aug 27, 2021
77fb547
test: prioritize router
zhxie Aug 27, 2021
9c71fe4
docs: prioritize router
zhxie Aug 31, 2021
b4cbd8d
Merge remote-tracking branch 'envoyproxy/main' into udp-proxy-router
zhxie Oct 20, 2021
4a201e7
Merge remote-tracking branch 'envoyproxy/main' into udp-proxy-router
zhxie Oct 21, 2021
b5086f2
Merge remote-tracking branch 'envoyproxy/main' into udp-proxy-router
zhxie Oct 25, 2021
42ce9c3
router: add network data inputs
zhxie Oct 26, 2021
0b14da0
udp: migrate to generic matching API
zhxie Oct 26, 2021
744d74b
router: change cidr data input to IP and port
zhxie Oct 27, 2021
cf61bb7
udp: fix no cluster initialized when using generic matching
zhxie Oct 27, 2021
cc24008
example: update UDP proxy example
zhxie Oct 27, 2021
f5fd481
docs: update to generic matching
zhxie Oct 27, 2021
f613a87
docs: fix orphan proto
zhxie Oct 27, 2021
4a2f3f8
test: update to generic matching
zhxie Oct 27, 2021
115b532
test: remove redundant code
zhxie Oct 28, 2021
db04638
udp: fix bug using variable out of scope
zhxie Oct 28, 2021
e9f56d7
router: update network matching data structure
zhxie Oct 28, 2021
786386b
test: add router coverage
zhxie Oct 28, 2021
f615fd5
test: add test for network data inputs
zhxie Oct 28, 2021
854176a
test: fix spelling
zhxie Oct 28, 2021
7cff9bf
test: fix format
zhxie Oct 28, 2021
b0fb7d6
udp: change router method name
zhxie Nov 1, 2021
8cfdf65
Merge remote-tracking branch 'envoyproxy/main' into udp-proxy-router
zhxie Nov 1, 2021
cfee9b0
udp: remove generated api shadow
zhxie Nov 1, 2021
063cf40
router: remove unused data inputs
zhxie Nov 1, 2021
35b0f5e
udp: fix not throw on invalid data inputs
zhxie Nov 1, 2021
7303e6f
udp: add docs for method
zhxie Nov 1, 2021
8184199
test: mark some tests as deprecated feature test
zhxie Nov 1, 2021
8f3e8e0
udp: revert deprecating cluster syntax
zhxie Nov 2, 2021
ecddff7
test: lower coverage for untested simple method in matching data
zhxie Nov 2, 2021
fae4e72
Merge remote-tracking branch 'envoyproxy/main' into udp-proxy-router
zhxie Nov 2, 2021
69376a9
docs: add release notes
zhxie Nov 2, 2021
0fc55bf
ci: kick CI
zhxie Nov 2, 2021
e779a36
udp: use full path for include
zhxie Nov 11, 2021
fb2731e
udp: update router abstraction
zhxie Nov 11, 2021
68dc8fb
udp: deprecate cluster API again
zhxie Nov 11, 2021
8de2770
ci: kick CI
zhxie Nov 11, 2021
e9cf799
Merge remote-tracking branch 'envoyproxy/main' into udp-proxy-router
zhxie Nov 29, 2021
03005e5
udp: fix filter
zhxie Nov 29, 2021
e162cae
tests: prioritize router
zhxie Nov 29, 2021
d62539e
Merge remote-tracking branch 'envoyproxy/main' into udp-proxy-router
zhxie Dec 1, 2021
e49181a
Merge remote-tracking branch 'envoyproxy/main' into udp-proxy-router
zhxie Dec 31, 2021
b04a059
api: fix format
zhxie Jan 5, 2022
87d1361
Merge remote-tracking branch 'envoyproxy/main' into udp-proxy-router
zhxie Jan 10, 2022
bd7b917
Merge remote-tracking branch 'envoyproxy/main' into udp-proxy-router
zhxie Jan 12, 2022
b00cf9e
nit: add comments and rename methods
zhxie Jan 12, 2022
45165c6
Merge remote-tracking branch 'envoyproxy/main' into udp-proxy-router
zhxie Feb 14, 2022
5173760
docs: update release notes
zhxie Feb 14, 2022
0e19161
nit: change parameter names
zhxie Feb 14, 2022
8b30f25
docs: update examples
zhxie Feb 14, 2022
d3db96e
examples: update examples
zhxie Feb 14, 2022
b501e34
tests: use single on_no_match
zhxie Feb 14, 2022
bc33bd0
Merge remote-tracking branch 'envoyproxy/main' into udp-proxy-router
zhxie Feb 25, 2022
2b9fe8d
Merge remote-tracking branch 'envoyproxy/main' into udp-proxy-router
zhxie Feb 25, 2022
9d1abd2
docs: fix release notes
zhxie Feb 25, 2022
628855d
api: remove duplicate matching data from merging
zhxie Feb 25, 2022
cb3d52c
api: remove duplicate matching data from merging
zhxie Feb 25, 2022
d6911cc
udp: comply with network inputs
zhxie Feb 25, 2022
29e86f8
Merge remote-tracking branch 'envoyproxy/main' into udp-proxy-router
zhxie Mar 28, 2022
4478d77
udp: replace with network inputs
zhxie Mar 28, 2022
c1dc8b1
test: add UDP router test
zhxie Mar 28, 2022
086ea89
nit: add comment for cluster infos
zhxie Mar 28, 2022
cf77be6
nit: explicitize variable route
zhxie Mar 28, 2022
4830ec7
udp: route with different network inputs
zhxie Mar 28, 2022
5ff8de5
docs: add docs for UDP proxy router
zhxie Mar 28, 2022
43a1b80
docs: fix matcher example
zhxie Mar 28, 2022
2be0b73
docs: fix matcher example
zhxie Mar 28, 2022
03b55aa
udp: remove unused guard
zhxie Mar 29, 2022
549a487
docs: emphasize matcher only
zhxie Mar 29, 2022
a08f1e1
api: clarify deprecation and usage
zhxie Mar 30, 2022
d368ef3
Merge remote-tracking branch 'envoyproxy/main' into udp-proxy-router
zhxie Mar 30, 2022
9b46d46
mis: post merge conflict
zhxie Mar 30, 2022
79d1748
docs: fix missing label
zhxie Mar 30, 2022
f959f11
docs: add deprecation notes
zhxie Mar 31, 2022
b9ac01e
nit: typo
zhxie Mar 31, 2022
96d1ca1
udp: ensure matching
zhxie Mar 31, 2022
f0eead0
udp: fix cluster removal log
zhxie Mar 31, 2022
a5fc56d
udp: change specifier in route
zhxie Mar 31, 2022
00a84ef
udp: merge path of cluster and matcher
zhxie Mar 31, 2022
eede13d
nit: fix typo
zhxie Apr 1, 2022
0617a91
udp: update signature of route
zhxie Apr 1, 2022
4eeea14
test: fix route
zhxie Apr 1, 2022
dc59d27
Merge remote-tracking branch 'envoyproxy/main' into udp-proxy-router
zhxie Apr 1, 2022
3f9c62c
Merge remote-tracking branch 'envoyproxy/main' into udp-proxy-router
zhxie Apr 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/envoy/extensions/filters/udp/udp_proxy/v3/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ licenses(["notice"]) # Apache 2

api_proto_package(
deps = [
"//envoy/annotations:pkg",
"//envoy/config/accesslog/v3:pkg",
"//envoy/config/core/v3:pkg",
"@com_github_cncf_udpa//udpa/annotations:pkg",
"@com_github_cncf_udpa//xds/annotations/v3:pkg",
"@com_github_cncf_udpa//xds/type/matcher/v3:pkg",
],
)
20 changes: 20 additions & 0 deletions api/envoy/extensions/filters/udp/udp_proxy/v3/route.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";

package envoy.extensions.filters.udp.udp_proxy.v3;

import "udpa/annotations/status.proto";
import "validate/validate.proto";

option java_package = "io.envoyproxy.envoy.extensions.filters.udp.udp_proxy.v3";
option java_outer_classname = "RouteProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/udp/udp_proxy/v3;udp_proxyv3";
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: UDP proxy route configuration]
// UDP proxy :ref:`configuration overview <config_udp_listener_filters_udp_proxy>`.

message Route {
// Indicates the upstream cluster to which the request should be routed.
string cluster = 1 [(validate.rules).string = {min_len: 1}];
}
19 changes: 17 additions & 2 deletions api/envoy/extensions/filters/udp/udp_proxy/v3/udp_proxy.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import "envoy/config/core/v3/udp_socket_config.proto";

import "google/protobuf/duration.proto";

import "xds/annotations/v3/status.proto";
import "xds/type/matcher/v3/matcher.proto";

import "envoy/annotations/deprecation.proto";
import "udpa/annotations/status.proto";
import "udpa/annotations/versioning.proto";
import "validate/validate.proto";
Expand All @@ -22,7 +26,7 @@ option (udpa.annotations.file_status).package_version_status = ACTIVE;
// [#extension: envoy.filters.udp_listener.udp_proxy]

// Configuration for the UDP proxy filter.
// [#next-free-field: 9]
// [#next-free-field: 10]
message UdpProxyConfig {
option (udpa.annotations.versioning).previous_message_type =
"envoy.config.filter.udp.udp_proxy.v2alpha.UdpProxyConfig";
Expand Down Expand Up @@ -52,7 +56,18 @@ message UdpProxyConfig {
option (validate.required) = true;

// The upstream cluster to connect to.
string cluster = 2 [(validate.rules).string = {min_len: 1}];
// This field is deprecated in favor of
// :ref:`matcher <envoy_v3_api_field_extensions.filters.udp.udp_proxy.v3.UdpProxyConfig.matcher>`.
string cluster = 2 [
deprecated = true,
(validate.rules).string = {min_len: 1},
(envoy.annotations.deprecated_at_minor_version) = "3.0"
];

// The match tree to use when resolving route actions for incoming requests.
// See :ref:`Routing <config_udp_listener_filters_udp_proxy_routing>` for more information.
xds.type.matcher.v3.Matcher matcher = 9
[(xds.annotations.v3.field_status).work_in_progress = true];
}

// The idle timeout for sessions. Idle is defined as no datagrams between received or sent by
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
static_resources:
listeners:
- name: listener_0
address:
socket_address:
protocol: UDP
address: 0.0.0.0
port_value: 1234
listener_filters:
- name: envoy.filters.udp_listener.udp_proxy
typed_config:
'@type': type.googleapis.com/envoy.extensions.filters.udp.udp_proxy.v3.UdpProxyConfig
stat_prefix: service
matcher:
# The outer matcher list matches source IP.
matcher_list:
matchers:
- predicate:
single_predicate:
input:
name: envoy.matching.inputs.source_ip
typed_config:
'@type': type.googleapis.com/envoy.extensions.matching.common_inputs.network.v3.SourceIPInput
value_match:
exact: 127.0.0.1
on_match:
matcher:
# The inner matcher tree matches source port.
matcher_tree:
input:
name: envoy.matching.inputs.source_port
typed_config:
'@type': type.googleapis.com/envoy.extensions.matching.common_inputs.network.v3.SourcePortInput
exact_match_map:
map:
"80":
action:
name: route
typed_config:
'@type': type.googleapis.com/envoy.extensions.filters.udp.udp_proxy.v3.Route
cluster: udp_service
"443":
action:
name: route
typed_config:
'@type': type.googleapis.com/envoy.extensions.filters.udp.udp_proxy.v3.Route
cluster: udp_service2
on_no_match:
action:
name: route
typed_config:
'@type': type.googleapis.com/envoy.extensions.filters.udp.udp_proxy.v3.Route
cluster: udp_service3
clusters:
- name: service_udp
type: STATIC
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: service_udp
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 127.0.0.1
port_value: 1235
- name: service_udp2
type: STATIC
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: service_udp
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 127.0.0.1
port_value: 1236
- name: service_udp3
type: STATIC
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: service_udp
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 127.0.0.1
port_value: 1237
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ static_resources:
typed_config:
'@type': type.googleapis.com/envoy.extensions.filters.udp.udp_proxy.v3.UdpProxyConfig
stat_prefix: service
cluster: service_udp
matcher:
on_no_match:
action:
name: route
typed_config:
'@type': type.googleapis.com/envoy.extensions.filters.udp.udp_proxy.v3.Route
cluster: service_udp
upstream_socket_config:
max_rx_datagram_size: 9000
clusters:
Expand Down
22 changes: 22 additions & 0 deletions docs/root/configuration/listeners/udp_filters/udp_proxy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,28 @@ The number of sessions that can be created per upstream cluster is limited by th
:ref:`maximum connection circuit breaker <arch_overview_circuit_break_cluster_maximum_connections>`.
By default this is 1024.


.. _config_udp_listener_filters_udp_proxy_routing:

Routing
-------

The filter can route different datagrams to different upstream clusters with their source
addresses. The matching API can be used with UDP routing, by specifying a matcher, a
:ref:`UDP network input <extension_category_envoy.matching.network.input>` as the matching rule and
:ref:`Route <envoy_v3_api_msg_extensions.filters.udp.udp_proxy.v3.Route>` as the resulting action.

The following matcher configuration will lead Envoy to route UDP datagrams according to their
source IPs, ignore datagrams other than those with a source IP of 127.0.0.1, and then filter the
remaining datagrams to different clusters according to their source ports.

.. literalinclude:: _include/udp-proxy-router.yaml
:language: yaml
:linenos:
:lineno-start: 14
:lines: 14-53
:caption: :download:`udp-proxy-router.yaml <_include/udp-proxy-router.yaml>`

Example configuration
---------------------

Expand Down
2 changes: 2 additions & 0 deletions docs/root/version_history/current.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ New Features
useful in support systems such as CI, CD, etc. The
:ref:`schema validator check tool <install_tools_schema_validator_check_tool>` has been added
to the tools image.
* udp_proxy: added :ref:`matcher <envoy_v3_api_field_extensions.filters.udp.udp_proxy.v3.UdpProxyConfig.matcher>` to support matching and routing to different clusters.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a note in deprecated below for the deprecated field.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, added.

* udp_proxy: added support for :ref:`access_log <envoy_v3_api_field_extensions.filters.udp.udp_proxy.v3.UdpProxyConfig.access_log>`.

Deprecated
Expand All @@ -157,3 +158,4 @@ Deprecated
* http: removing support for long-deprecated old style filter names, e.g. envoy.router, envoy.lua.
* re2: removed undocumented histograms ``re2.program_size`` and ``re2.exceeded_warn_level``.
* thrift: deprecated TTwitter protocol since we believe it's not used and it's causing significant maintenance burden.
* udp_proxy: deprecated :ref:`cluster <envoy_v3_api_field_extensions.filters.udp.udp_proxy.v3.UdpProxyConfig.cluster>` in favor of :ref:`matcher <envoy_v3_api_field_extensions.filters.udp.udp_proxy.v3.UdpProxyConfig.matcher>`.
4 changes: 2 additions & 2 deletions envoy/network/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,8 @@ class UdpMatchingData {

virtual ~UdpMatchingData() = default;

virtual const Address::InstanceConstSharedPtr& localAddress() const PURE;
virtual const Address::InstanceConstSharedPtr& remoteAddress() const PURE;
virtual const Address::Instance& localAddress() const PURE;
virtual const Address::Instance& remoteAddress() const PURE;
};

} // namespace Network
Expand Down
8 changes: 7 additions & 1 deletion examples/udp/envoy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ static_resources:
typed_config:
'@type': type.googleapis.com/envoy.extensions.filters.udp.udp_proxy.v3.UdpProxyConfig
stat_prefix: service
cluster: service_udp
matcher:
on_no_match:
action:
name: route
typed_config:
'@type': type.googleapis.com/envoy.extensions.filters.udp.udp_proxy.v3.Route
cluster: service_udp

clusters:
- name: service_udp
Expand Down
12 changes: 6 additions & 6 deletions source/common/network/matching/data_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ class MatchingDataImpl : public MatchingData {
*/
class UdpMatchingDataImpl : public UdpMatchingData {
public:
UdpMatchingDataImpl(const Address::InstanceConstSharedPtr& local_address,
const Address::InstanceConstSharedPtr& remote_address)
UdpMatchingDataImpl(const Address::Instance& local_address,
const Address::Instance& remote_address)
: local_address_(local_address), remote_address_(remote_address) {}
const Address::InstanceConstSharedPtr& localAddress() const override { return local_address_; }
const Address::InstanceConstSharedPtr& remoteAddress() const override { return remote_address_; }
const Address::Instance& localAddress() const override { return local_address_; }
const Address::Instance& remoteAddress() const override { return remote_address_; }

private:
const Address::InstanceConstSharedPtr& local_address_;
const Address::InstanceConstSharedPtr& remote_address_;
const Address::Instance& local_address_;
const Address::Instance& remote_address_;
};

} // namespace Matching
Expand Down
16 changes: 8 additions & 8 deletions source/common/network/matching/inputs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ template <>
Matcher::DataInputGetResult
DestinationIPInput<UdpMatchingData>::get(const UdpMatchingData& data) const {
const auto& address = data.localAddress();
if (address->type() != Network::Address::Type::Ip) {
if (address.type() != Network::Address::Type::Ip) {
return {Matcher::DataInputGetResult::DataAvailability::AllDataAvailable, absl::nullopt};
}
return {Matcher::DataInputGetResult::DataAvailability::AllDataAvailable,
address->ip()->addressAsString()};
address.ip()->addressAsString()};
}

template <>
Expand All @@ -46,11 +46,11 @@ template <>
Matcher::DataInputGetResult
DestinationPortInput<UdpMatchingData>::get(const UdpMatchingData& data) const {
const auto& address = data.localAddress();
if (address->type() != Network::Address::Type::Ip) {
if (address.type() != Network::Address::Type::Ip) {
return {Matcher::DataInputGetResult::DataAvailability::AllDataAvailable, absl::nullopt};
}
return {Matcher::DataInputGetResult::DataAvailability::AllDataAvailable,
absl::StrCat(address->ip()->port())};
absl::StrCat(address.ip()->port())};
}

template <>
Expand All @@ -66,11 +66,11 @@ Matcher::DataInputGetResult SourceIPInput<MatchingData>::get(const MatchingData&
template <>
Matcher::DataInputGetResult SourceIPInput<UdpMatchingData>::get(const UdpMatchingData& data) const {
const auto& address = data.remoteAddress();
if (address->type() != Network::Address::Type::Ip) {
if (address.type() != Network::Address::Type::Ip) {
return {Matcher::DataInputGetResult::DataAvailability::AllDataAvailable, absl::nullopt};
}
return {Matcher::DataInputGetResult::DataAvailability::AllDataAvailable,
address->ip()->addressAsString()};
address.ip()->addressAsString()};
}

template <>
Expand All @@ -87,11 +87,11 @@ template <>
Matcher::DataInputGetResult
SourcePortInput<UdpMatchingData>::get(const UdpMatchingData& data) const {
const auto& address = data.remoteAddress();
if (address->type() != Network::Address::Type::Ip) {
if (address.type() != Network::Address::Type::Ip) {
return {Matcher::DataInputGetResult::DataAvailability::AllDataAvailable, absl::nullopt};
}
return {Matcher::DataInputGetResult::DataAvailability::AllDataAvailable,
absl::StrCat(address->ip()->port())};
absl::StrCat(address.ip()->port())};
}

Matcher::DataInputGetResult DirectSourceIPInput::get(const MatchingData& data) const {
Expand Down
2 changes: 2 additions & 0 deletions source/extensions/filters/udp/udp_proxy/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ envoy_cc_library(
"//envoy/upstream:cluster_manager_interface",
"//source/common/access_log:access_log_lib",
"//source/common/api:os_sys_calls_lib",
"//source/common/common:empty_string",
"//source/common/common:random_generator_lib",
"//source/common/network:socket_lib",
"//source/common/network:socket_option_factory_lib",
"//source/common/network:utility_lib",
"//source/common/stream_info:stream_info_lib",
"//source/common/upstream:load_balancer_lib",
"//source/extensions/filters/udp/udp_proxy/router:router_lib",
"@envoy_api//envoy/config/accesslog/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/filters/udp/udp_proxy/v3:pkg_cc_proto",
],
Expand Down
29 changes: 29 additions & 0 deletions source/extensions/filters/udp/udp_proxy/router/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
load(
"//bazel:envoy_build_system.bzl",
"envoy_cc_library",
"envoy_extension_package",
)

licenses(["notice"]) # Apache 2

envoy_extension_package()

envoy_cc_library(
name = "router_interface",
hdrs = ["router.h"],
)

envoy_cc_library(
name = "router_lib",
srcs = ["router_impl.cc"],
hdrs = ["router_impl.h"],
deps = [
":router_interface",
"//source/common/common:empty_string",
"//source/common/matcher:matcher_lib",
"//source/common/matcher:validation_visitor_lib",
"//source/common/network/matching:data_impl_lib",
"//source/common/network/matching:inputs_lib",
"@envoy_api//envoy/extensions/filters/udp/udp_proxy/v3:pkg_cc_proto",
],
)
Loading