From 64c00708facb6e2203f88654837ede2a6a92f8cb Mon Sep 17 00:00:00 2001 From: Vladimir Homutov Date: Wed, 10 Jun 2020 21:37:08 +0300 Subject: [PATCH] Limited max udp payload size for outgoing packets. This allows to avoid problems with packet fragmentation in real networks. This is a temporary workaround. --- src/event/ngx_event_quic.c | 8 +++++++- src/event/ngx_event_quic.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/event/ngx_event_quic.c b/src/event/ngx_event_quic.c index 56cf9d06f..d685d4514 100644 --- 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_t *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 *c, ngx_ssl_t *ssl, ngx_quic_tp_t *tp, 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; diff --git a/src/event/ngx_event_quic.h b/src/event/ngx_event_quic.h index 17ea64700..495e07996 100644 --- 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