Skip to content

Commit 73eec64

Browse files
authored
udp: allow configurable max packet size (envoyproxy#15388)
1) Add configuration for max packet size to UDP listeners 2) Add configuration for max packet size to UDP proxy filter 3) Fix crashing issue when a GRO receive is truncated. This was fixed in the open because GRO recieve does not support IP fragmentation, thus the previous size of 24000 bytes was large enough to receive a jumbo frame size datagram. The issue is now exposed by allowing packet size to be configured larger. 4) Reorganize code and some config around UDP listeners to streamline the logic when the listener is a UDP listener. Also moved the UDP batch writer configuration to a better place since it's still effectively alpha and was marked not implemented. Fixes envoyproxy#15327 Signed-off-by: Matt Klein <[email protected]>
1 parent af17302 commit 73eec64

File tree

83 files changed

+715
-499
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+715
-499
lines changed

api/envoy/config/listener/v3/listener.proto

+3-16
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package envoy.config.listener.v3;
55
import "envoy/config/accesslog/v3/accesslog.proto";
66
import "envoy/config/core/v3/address.proto";
77
import "envoy/config/core/v3/base.proto";
8-
import "envoy/config/core/v3/extension.proto";
98
import "envoy/config/core/v3/socket_option.proto";
109
import "envoy/config/listener/v3/api_listener.proto";
1110
import "envoy/config/listener/v3/listener_components.proto";
@@ -93,7 +92,7 @@ message Listener {
9392
message InternalListenerConfig {
9493
}
9594

96-
reserved 14;
95+
reserved 14, 23;
9796

9897
// The unique name by which this listener is known. If no name is provided,
9998
// Envoy will allocate an internal UUID for the listener. If the listener is to be dynamically
@@ -216,10 +215,8 @@ message Listener {
216215

217216
// If the protocol in the listener socket address in :ref:`protocol
218217
// <envoy_api_field_config.core.v3.SocketAddress.protocol>` is :ref:`UDP
219-
// <envoy_api_enum_value_config.core.v3.SocketAddress.Protocol.UDP>`, this field specifies the actual udp
220-
// listener to create, i.e. :ref:`udp_listener_name
221-
// <envoy_api_field_config.listener.v3.UdpListenerConfig.udp_listener_name>` = "raw_udp_listener" for
222-
// creating a packet-oriented UDP listener. If not present, treat it as "raw_udp_listener".
218+
// <envoy_api_enum_value_config.core.v3.SocketAddress.Protocol.UDP>`, this field specifies UDP
219+
// listener specific configuration.
223220
UdpListenerConfig udp_listener_config = 18;
224221

225222
// Used to represent an API listener, which is used in non-proxy clients. The type of API
@@ -261,16 +258,6 @@ message Listener {
261258
// emitted by this listener.
262259
repeated accesslog.v3.AccessLog access_log = 22;
263260

264-
// If the protocol in the listener socket address in :ref:`protocol
265-
// <envoy_api_field_config.core.v3.SocketAddress.protocol>` is :ref:`UDP
266-
// <envoy_api_enum_value_config.core.v3.SocketAddress.Protocol.UDP>`, this field specifies the actual udp
267-
// writer to create, i.e. :ref:`name <envoy_api_field_config.core.v3.TypedExtensionConfig.name>`
268-
// = "udp_default_writer" for creating a udp writer with writing in passthrough mode,
269-
// = "udp_gso_batch_writer" for creating a udp writer with writing in batch mode.
270-
// If not present, treat it as "udp_default_writer".
271-
// [#not-implemented-hide:]
272-
core.v3.TypedExtensionConfig udp_writer_config = 23;
273-
274261
// The maximum length a tcp listener's pending connections queue can grow to. If no value is
275262
// provided net.core.somaxconn will be used on Linux and 128 otherwise.
276263
google.protobuf.UInt32Value tcp_backlog_size = 24;

api/envoy/config/listener/v3/listener_components.proto

+1-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ message ListenerFilter {
338338
oneof config_type {
339339
// Filter specific configuration which depends on the filter being
340340
// instantiated. See the supported filters for further documentation.
341-
// [#extension-category: envoy.filters.listener]
341+
// [#extension-category: envoy.filters.listener,envoy.filters.udp_listener]
342342
google.protobuf.Any typed_config = 3;
343343
}
344344

api/envoy/config/listener/v3/quic_config.proto

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ option java_outer_classname = "QuicConfigProto";
1515
option java_multiple_files = true;
1616
option (udpa.annotations.file_status).package_version_status = ACTIVE;
1717

18-
// [#protodoc-title: QUIC listener Config]
19-
// [#extension: envoy.listener.quic]
18+
// [#protodoc-title: QUIC listener config]
19+
// [#comment:#extension: envoy.udp_listeners.quiche_quic_listener]
20+
// [#comment:TODO(#12829): Remove this as an extension point.]
2021

21-
// Configuration specific to the QUIC protocol.
22-
// Next id: 5
22+
// Configuration specific to the UDP QUIC listener.
2323
message QuicProtocolOptions {
2424
option (udpa.annotations.versioning).previous_message_type =
2525
"envoy.api.v2.listener.QuicProtocolOptions";

api/envoy/config/listener/v3/udp_gso_batch_writer_config.proto

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ option java_outer_classname = "UdpGsoBatchWriterConfigProto";
99
option java_multiple_files = true;
1010
option (udpa.annotations.file_status).package_version_status = ACTIVE;
1111

12-
// [#protodoc-title: Udp Gso Batch Writer Config]
12+
// [#protodoc-title: UDP GSO Batch Writer]
13+
// [#comment:#extension: envoy.udp_packet_writers.udp_gso_batch_writer]
1314

15+
// Configuration specific to the UDP GSO Batch Writer.
1416
// [#not-implemented-hide:]
15-
// Configuration specific to the Udp Gso Batch Writer.
17+
// [#comment:TODO(#12829): Remove this as an extension point.]
1618
message UdpGsoBatchWriterOptions {
1719
}

api/envoy/config/listener/v3/udp_listener_config.proto

+28-13
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,53 @@ syntax = "proto3";
22

33
package envoy.config.listener.v3;
44

5+
import "envoy/config/core/v3/extension.proto";
6+
57
import "google/protobuf/any.proto";
8+
import "google/protobuf/wrappers.proto";
69

710
import "udpa/annotations/status.proto";
811
import "udpa/annotations/versioning.proto";
12+
import "validate/validate.proto";
913

1014
option java_package = "io.envoyproxy.envoy.config.listener.v3";
1115
option java_outer_classname = "UdpListenerConfigProto";
1216
option java_multiple_files = true;
1317
option (udpa.annotations.file_status).package_version_status = ACTIVE;
1418

15-
// [#protodoc-title: UDP Listener Config]
19+
// [#protodoc-title: UDP listener config]
1620
// Listener :ref:`configuration overview <config_listeners>`
1721

22+
// [#next-free-field: 7]
1823
message UdpListenerConfig {
1924
option (udpa.annotations.versioning).previous_message_type =
2025
"envoy.api.v2.listener.UdpListenerConfig";
2126

22-
reserved 2;
27+
reserved 1, 2, 3;
2328

2429
reserved "config";
2530

26-
// Used to look up UDP listener factory, matches "raw_udp_listener" or
27-
// "quic_listener" to create a specific udp listener.
28-
// If not specified, treat as "raw_udp_listener".
29-
string udp_listener_name = 1;
30-
31-
// Used to create a specific listener factory. To some factory, e.g.
32-
// "raw_udp_listener", config is not needed.
33-
// [#extension-category: envoy.filters.udp_listener]
34-
oneof config_type {
35-
google.protobuf.Any typed_config = 3;
36-
}
31+
// Used to create a specific UDP listener factory. If not specified the default UDP listener is
32+
// used.
33+
// [#comment:#extension-category: envoy.udp_listeners]
34+
// [#not-implemented-hide:]
35+
// [#comment:TODO(#12829): Remove this as an extension point.]
36+
core.v3.TypedExtensionConfig listener_config = 4;
37+
38+
// The maximum size of received downstream UDP datagrams. Using a larger size will cause Envoy to allocate
39+
// more memory per listener. Received datagrams above this size will be dropped. If not set
40+
// defaults to 1500 bytes.
41+
google.protobuf.UInt64Value max_downstream_rx_datagram_size = 5
42+
[(validate.rules).uint64 = {lt: 65536 gt: 0}];
43+
44+
// If the protocol in the listener socket address in :ref:`protocol
45+
// <envoy_api_field_config.core.v3.SocketAddress.protocol>` is :ref:`UDP
46+
// <envoy_api_enum_value_config.core.v3.SocketAddress.Protocol.UDP>`, this field specifies the
47+
// actual UDP writer to create. If not specified the default UDP writer is used.
48+
// [#comment:#extension-category: envoy.udp_packet_writers]
49+
// [#not-implemented-hide:]
50+
// [#comment:TODO(#12829): Remove this as an extension point.]
51+
core.v3.TypedExtensionConfig writer_config = 6;
3752
}
3853

3954
message ActiveRawUdpListenerConfig {

api/envoy/config/listener/v4alpha/listener.proto

+3-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/envoy/config/listener/v4alpha/listener_components.proto

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/envoy/config/listener/v4alpha/quic_config.proto

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/envoy/config/listener/v4alpha/udp_gso_batch_writer_config.proto

+4-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/envoy/config/listener/v4alpha/udp_listener_config.proto

+28-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/envoy/extensions/filters/udp/udp_proxy/v3/udp_proxy.proto

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ syntax = "proto3";
33
package envoy.extensions.filters.udp.udp_proxy.v3;
44

55
import "google/protobuf/duration.proto";
6+
import "google/protobuf/wrappers.proto";
67

78
import "udpa/annotations/status.proto";
89
import "udpa/annotations/versioning.proto";
@@ -18,7 +19,7 @@ option (udpa.annotations.file_status).package_version_status = ACTIVE;
1819
// [#extension: envoy.filters.udp_listener.udp_proxy]
1920

2021
// Configuration for the UDP proxy filter.
21-
// [#next-free-field: 6]
22+
// [#next-free-field: 7]
2223
message UdpProxyConfig {
2324
option (udpa.annotations.versioning).previous_message_type =
2425
"envoy.config.filter.udp.udp_proxy.v2alpha.UdpProxyConfig";
@@ -68,4 +69,10 @@ message UdpProxyConfig {
6869
// load balancing algorithms will select a host randomly. Currently the number of hash policies is
6970
// limited to 1.
7071
repeated HashPolicy hash_policies = 5 [(validate.rules).repeated = {max_items: 1}];
72+
73+
// The maximum size of received upstream UDP datagrams. Using a larger size will cause Envoy to allocate
74+
// more memory per listener. Received datagrams above this size will be dropped. If not set
75+
// defaults to 1500 bytes.
76+
google.protobuf.UInt64Value max_upstream_rx_datagram_size = 6
77+
[(validate.rules).uint64 = {lt: 65536 gt: 0}];
7178
}

api/envoy/extensions/transport_sockets/quic/v3/quic_transport.proto

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ option java_multiple_files = true;
1313
option (udpa.annotations.file_status).package_version_status = ACTIVE;
1414

1515
// [#protodoc-title: quic transport]
16-
// [#extension: envoy.transport_sockets.quic]
16+
// [#comment:#extension: envoy.transport_sockets.quic]
17+
// [#comment:TODO(#12829): Remove this as an extension point.]
1718

1819
// Configuration for Downstream QUIC transport socket. This provides Google's implementation of Google QUIC and IETF QUIC to Envoy.
1920
message QuicDownstreamTransport {

api/envoy/extensions/transport_sockets/quic/v4alpha/quic_transport.proto

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bazel/repository_locations.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ REPOSITORY_LOCATIONS_SPEC = dict(
774774
sha256 = "3045254cbf03c29ee7166fb01b1072a463c58df405669b8573677d4638869290",
775775
urls = ["https://storage.googleapis.com/quiche-envoy-integration/{version}.tar.gz"],
776776
use_category = ["dataplane_ext"],
777-
extensions = ["envoy.transport_sockets.quic", "envoy.listener.quic"],
777+
extensions = ["envoy.transport_sockets.quic", "envoy.udp_listeners.quiche_quic_listener"],
778778
release_date = "2021-02-24",
779779
cpe = "N/A",
780780
),

docs/root/configuration/listeners/udp_filters/_include/udp-proxy.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ static_resources:
1414
protocol: UDP
1515
address: 127.0.0.1
1616
port_value: 1234
17+
udp_listener_config:
18+
max_downstream_rx_datagram_size: 9000
1719
listener_filters:
1820
- name: envoy.filters.udp_listener.udp_proxy
1921
typed_config:
2022
'@type': type.googleapis.com/envoy.extensions.filters.udp.udp_proxy.v3.UdpProxyConfig
2123
stat_prefix: service
2224
cluster: service_udp
25+
max_upstream_rx_datagram_size: 9000
2326
clusters:
2427
- name: service_udp
2528
connect_timeout: 0.25s

docs/root/configuration/listeners/udp_filters/udp_proxy.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ Example configuration
4747
---------------------
4848

4949
The following example configuration will cause Envoy to listen on UDP port 1234 and proxy to a UDP
50-
server listening on port 1235.
50+
server listening on port 1235, allowing 9000 byte packets in both directions (i.e., either jumbo
51+
frames or fragmented IP packets).
5152

5253
.. literalinclude:: _include/udp-proxy.yaml
5354
:language: yaml

docs/root/intro/life_of_a_request.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ response header/body with end-stream set are received. This is handled in
524524
It is possible for a request to terminate early. This may be due to (but not limited to):
525525

526526
* Request timeout.
527-
* Upstream endpoint steam reset.
527+
* Upstream endpoint stream reset.
528528
* HTTP filter stream reset.
529529
* Circuit breaking.
530530
* Unavailability of upstream resources, e.g. missing a cluster for a route.

0 commit comments

Comments
 (0)