# HG changeset patch # User Vladimir Homutov # Date 1603099178 -10800 # Node ID 44991d728899bea5ee6f5bfe9197775a54837e4e # Parent 93be5658a2504e3c05698532a4540e8a407e9b5b QUIC: account packet header length in amplification limit. This is the restoration of 02ee77f8d53d accidentally reverted by 93be5658a250. diff --git a/src/event/ngx_event_quic.c b/src/event/ngx_event_quic.c --- a/src/event/ngx_event_quic.c +++ b/src/event/ngx_event_quic.c @@ -3757,6 +3757,7 @@ ngx_quic_output_frames(ngx_connection_t hlen = (f->level == ssl_encryption_application) ? NGX_QUIC_MAX_SHORT_HEADER : NGX_QUIC_MAX_LONG_HEADER; hlen += EVP_GCM_TLS_TAG_LEN; + hlen -= NGX_QUIC_MAX_CID_LEN - qc->scid.len; do { len = 0; @@ -3786,7 +3787,7 @@ ngx_quic_output_frames(ngx_connection_t * send more than three times the data it receives; */ - if (((c->sent + len + f->len) / 3) > qc->received) { + if (((c->sent + hlen + len + f->len) / 3) > qc->received) { ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, "quic hit amplification limit" " received %uz sent %O", diff --git a/src/event/ngx_event_quic.h b/src/event/ngx_event_quic.h --- a/src/event/ngx_event_quic.h +++ b/src/event/ngx_event_quic.h @@ -54,7 +54,8 @@ #define NGX_QUIC_STREAM_BUFSIZE 65536 -#define NGX_QUIC_SERVER_CID_LEN 20 +#define NGX_QUIC_MAX_CID_LEN 20 +#define NGX_QUIC_SERVER_CID_LEN NGX_QUIC_MAX_CID_LEN #define NGX_QUIC_SR_TOKEN_LEN 16