changeset 8432:391d06a51bc0 quic

Limited max udp payload size for outgoing packets. This allows to avoid problems with packet fragmentation in real networks. This is a temporary workaround.
author Vladimir Homutov <vl@nginx.com>
date Wed, 10 Jun 2020 21:37:08 +0300
parents 70335ec6e5d4
children 7672ec1e6227
files src/event/ngx_event_quic.c src/event/ngx_event_quic.h
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/event/ngx_event_quic.c
+++ b/src/event/ngx_event_quic.c
@@ -430,6 +430,12 @@ ngx_quic_add_handshake_data(ngx_ssl_conn
                 return 0;
             }
 
+            if (qc->ctp.max_udp_payload_size > NGX_QUIC_MAX_UDP_PAYLOAD_OUT) {
+                qc->ctp.max_udp_payload_size = NGX_QUIC_MAX_UDP_PAYLOAD_OUT;
+                ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0,
+                              "quic client maximum packet size truncated");
+            }
+
 #if (NGX_QUIC_DRAFT_VERSION >= 28)
             if (qc->scid.len != qc->ctp.initial_scid.len
                 || ngx_memcmp(qc->scid.data, qc->ctp.initial_scid.data,
@@ -640,7 +646,7 @@ ngx_quic_new_connection(ngx_connection_t
     qc->streams.handler = handler;
 
     ctp = &qc->ctp;
-    ctp->max_udp_payload_size = NGX_QUIC_MAX_UDP_PAYLOAD_SIZE;
+    ctp->max_udp_payload_size = NGX_QUIC_MAX_UDP_PAYLOAD_OUT;
     ctp->ack_delay_exponent = NGX_QUIC_DEFAULT_ACK_DELAY_EXPONENT;
     ctp->max_ack_delay = NGX_QUIC_DEFAULT_MAX_ACK_DELAY;
 
--- a/src/event/ngx_event_quic.h
+++ b/src/event/ngx_event_quic.h
@@ -23,6 +23,8 @@
     /* 1 flags + 4 version + 2 x (1 + 20) s/dcid + 4 pn + 4 len + token len */
 
 #define NGX_QUIC_MAX_UDP_PAYLOAD_SIZE        65527
+#define NGX_QUIC_MAX_UDP_PAYLOAD_OUT         1300  /* TODO */
+
 #define NGX_QUIC_DEFAULT_ACK_DELAY_EXPONENT  3
 #define NGX_QUIC_DEFAULT_MAX_ACK_DELAY       25