-
Notifications
You must be signed in to change notification settings - Fork 5.4k
udp: add router for UDP proxy #18791
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
Changes from 88 commits
4cfa9c5
9891c45
367db00
3bd3085
4c1b126
3f762f7
95e1094
b592612
804aedd
37def08
77fb547
9c71fe4
b4cbd8d
4a201e7
b5086f2
42ce9c3
0b14da0
744d74b
cf61bb7
cc24008
f5fd481
f613a87
4a2f3f8
115b532
db04638
e9f56d7
786386b
f615fd5
854176a
7cff9bf
b0fb7d6
8cfdf65
cfee9b0
063cf40
35b0f5e
7303e6f
8184199
8f3e8e0
ecddff7
fae4e72
69376a9
0fc55bf
e779a36
fb2731e
68dc8fb
8de2770
e9cf799
03005e5
e162cae
d62539e
e49181a
b04a059
87d1361
bd7b917
b00cf9e
45165c6
5173760
0e19161
8b30f25
d3db96e
b501e34
bc33bd0
2b9fe8d
9d1abd2
628855d
cb3d52c
d6911cc
29e86f8
4478d77
c1dc8b1
086ea89
cf77be6
4830ec7
5ff8de5
43a1b80
2be0b73
03b55aa
549a487
a08f1e1
d368ef3
9b46d46
79d1748
f959f11
b9ac01e
96d1ca1
f0eead0
a5fc56d
00a84ef
eede13d
0617a91
4eeea14
dc59d27
3f9c62c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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}]; | ||
| } |
| 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 |
|---|---|---|
|
|
@@ -142,6 +142,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. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a note in deprecated below for the deprecated field.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
@@ -153,3 +154,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>`. | ||
| 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", | ||
| ], | ||
| ) |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,46 @@ | ||||
| #pragma once | ||||
|
|
||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|
|
||||
| #include "envoy/common/pure.h" | ||||
| #include "envoy/network/address.h" | ||||
|
|
||||
| namespace Envoy { | ||||
| namespace Extensions { | ||||
| namespace UdpFilters { | ||||
| namespace UdpProxy { | ||||
| namespace Router { | ||||
|
|
||||
| /** | ||||
| * The router which holds all clusters and determines the cluster which UDP data should be routed | ||||
| * to. | ||||
| */ | ||||
| class Router { | ||||
| public: | ||||
| virtual ~Router() = default; | ||||
|
|
||||
| /** | ||||
| * Based on the address of the incoming UDP data, determine the target route for the data. | ||||
| * @return the cluster name or empty string if there is not matching route for the data. | ||||
| */ | ||||
| virtual const std::string | ||||
| route(const Network::Address::InstanceConstSharedPtr destination_address, | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I meant
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In the caller method, we will get a const std::string& route = config_->route(*data.addresses_.local_, *data.addresses_.peer_); Do you think it is acceptable?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed, I have updated all methods in the caller chain. |
||||
| const Network::Address::InstanceConstSharedPtr source_address) const PURE; | ||||
|
|
||||
| /** | ||||
| * Returns all cluster names in the router. The UDP proxy filter requires every cluster name for | ||||
| * initialization which will call this method on construction. | ||||
| * @return vector of all cluster names. | ||||
| */ | ||||
| virtual const std::vector<std::string>& allClusterNames() const PURE; | ||||
| }; | ||||
|
|
||||
| using RouterConstSharedPtr = std::shared_ptr<const Router>; | ||||
|
|
||||
| } // namespace Router | ||||
| } // namespace UdpProxy | ||||
| } // namespace UdpFilters | ||||
| } // namespace Extensions | ||||
| } // namespace Envoy | ||||
Uh oh!
There was an error while loading. Please reload this page.