summaryrefslogtreecommitdiffhomepage
path: root/src/event/quic/ngx_event_quic_output.c
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2023-08-14 09:21:27 +0400
committerRoman Arutyunyan <arut@nginx.com>2023-08-14 09:21:27 +0400
commiteeb8a9f56f727d2543c8ae7feae0de784e329b27 (patch)
treea3b6dbde4411df979e93ca7df075cb15a5156850 /src/event/quic/ngx_event_quic_output.c
parent58fc5e2830a0fa70810005ca03fdb9a531719696 (diff)
downloadnginx-eeb8a9f56f727d2543c8ae7feae0de784e329b27.tar.gz
nginx-eeb8a9f56f727d2543c8ae7feae0de784e329b27.tar.bz2
QUIC: path MTU discovery.
MTU selection starts by doubling the initial MTU until the first failure. Then binary search is used to find the path MTU.
Diffstat (limited to 'src/event/quic/ngx_event_quic_output.c')
-rw-r--r--src/event/quic/ngx_event_quic_output.c30
1 files changed, 3 insertions, 27 deletions
diff --git a/src/event/quic/ngx_event_quic_output.c b/src/event/quic/ngx_event_quic_output.c
index a72504b6a..587671bc6 100644
--- a/src/event/quic/ngx_event_quic_output.c
+++ b/src/event/quic/ngx_event_quic_output.c
@@ -10,9 +10,6 @@
#include <ngx_event_quic_connection.h>
-#define NGX_QUIC_MAX_UDP_PAYLOAD_OUT 1252
-#define NGX_QUIC_MAX_UDP_PAYLOAD_OUT6 1232
-
#define NGX_QUIC_MAX_UDP_SEGMENT_BUF 65487 /* 65K - IPv6 header */
#define NGX_QUIC_MAX_SEGMENTS 64 /* UDP_MAX_SEGMENTS */
@@ -61,21 +58,6 @@ static size_t ngx_quic_path_limit(ngx_connection_t *c, ngx_quic_path_t *path,
size_t size);
-size_t
-ngx_quic_max_udp_payload(ngx_connection_t *c)
-{
- /* TODO: path MTU discovery */
-
-#if (NGX_HAVE_INET6)
- if (c->sockaddr->sa_family == AF_INET6) {
- return NGX_QUIC_MAX_UDP_PAYLOAD_OUT6;
- }
-#endif
-
- return NGX_QUIC_MAX_UDP_PAYLOAD_OUT;
-}
-
-
ngx_int_t
ngx_quic_output(ngx_connection_t *c)
{
@@ -142,10 +124,7 @@ ngx_quic_create_datagrams(ngx_connection_t *c)
p = dst;
- len = ngx_min(qc->ctp.max_udp_payload_size,
- NGX_QUIC_MAX_UDP_PAYLOAD_SIZE);
-
- len = ngx_quic_path_limit(c, path, len);
+ len = ngx_quic_path_limit(c, path, path->mtu);
pad = ngx_quic_get_padding_level(c);
@@ -299,9 +278,7 @@ ngx_quic_allow_segmentation(ngx_connection_t *c)
ctx = ngx_quic_get_send_ctx(qc, ssl_encryption_application);
bytes = 0;
-
- len = ngx_min(qc->ctp.max_udp_payload_size,
- NGX_QUIC_MAX_UDP_SEGMENT_BUF);
+ len = ngx_min(qc->path->mtu, NGX_QUIC_MAX_UDP_SEGMENT_BUF);
for (q = ngx_queue_head(&ctx->frames);
q != ngx_queue_sentinel(&ctx->frames);
@@ -345,8 +322,7 @@ ngx_quic_create_segments(ngx_connection_t *c)
return NGX_ERROR;
}
- segsize = ngx_min(qc->ctp.max_udp_payload_size,
- NGX_QUIC_MAX_UDP_SEGMENT_BUF);
+ segsize = ngx_min(path->mtu, NGX_QUIC_MAX_UDP_SEGMENT_BUF);
p = dst;
end = dst + sizeof(dst);