# HG changeset patch # User Sergey Kandaurov # Date 1590746168 -10800 # Node ID 125cbfa77013365c385dd5415f9858c1f2d02c27 # Parent 49a98760afd29a757a79fe9f490060c258c26204 Renamed max_packet_size to max_udp_payload_size, from draft-28. No functional changes. 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 @@ -415,8 +415,8 @@ ngx_quic_add_handshake_data(ngx_ssl_conn qc->tp.max_idle_timeout = qc->ctp.max_idle_timeout; } - if (qc->ctp.max_packet_size < NGX_QUIC_MIN_INITIAL_SIZE - || qc->ctp.max_packet_size > NGX_QUIC_DEFAULT_MAX_PACKET_SIZE) + if (qc->ctp.max_udp_payload_size < NGX_QUIC_MIN_INITIAL_SIZE + || qc->ctp.max_udp_payload_size > NGX_QUIC_MAX_UDP_PAYLOAD_SIZE) { qc->error = NGX_QUIC_ERR_TRANSPORT_PARAMETER_ERROR; qc->error_reason = "invalid maximum packet size"; @@ -434,7 +434,7 @@ ngx_quic_add_handshake_data(ngx_ssl_conn * we need to fit at least 1 frame into a packet, thus account head/tail; * 17 = 1 + 8x2 is max header for CRYPTO frame, with 1 byte for frame type */ - limit = qc->ctp.max_packet_size - NGX_QUIC_MAX_LONG_HEADER - 17 + limit = qc->ctp.max_udp_payload_size - NGX_QUIC_MAX_LONG_HEADER - 17 - EVP_GCM_TLS_TAG_LEN; fs = &qc->crypto[level]; @@ -555,7 +555,7 @@ ngx_quic_new_connection(ngx_connection_t ngx_quic_secrets_t *keys; ngx_quic_send_ctx_t *ctx; ngx_quic_connection_t *qc; - static u_char buf[NGX_QUIC_DEFAULT_MAX_PACKET_SIZE]; + static u_char buf[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE]; if (ngx_buf_size(pkt->raw) < NGX_QUIC_MIN_INITIAL_SIZE) { ngx_log_error(NGX_LOG_INFO, c->log, 0, @@ -625,14 +625,15 @@ ngx_quic_new_connection(ngx_connection_t qc->streams.handler = handler; ctp = &qc->ctp; - ctp->max_packet_size = NGX_QUIC_DEFAULT_MAX_PACKET_SIZE; + ctp->max_udp_payload_size = NGX_QUIC_MAX_UDP_PAYLOAD_SIZE; ctp->ack_delay_exponent = NGX_QUIC_DEFAULT_ACK_DELAY_EXPONENT; ctp->max_ack_delay = NGX_QUIC_DEFAULT_MAX_ACK_DELAY; qc->streams.recv_max_data = qc->tp.initial_max_data; - qc->congestion.window = ngx_min(10 * qc->tp.max_packet_size, - ngx_max(2 * qc->tp.max_packet_size, 14720)); + qc->congestion.window = ngx_min(10 * qc->tp.max_udp_payload_size, + ngx_max(2 * qc->tp.max_udp_payload_size, + 14720)); qc->congestion.ssthresh = NGX_MAX_SIZE_T_VALUE; qc->congestion.recovery_start = ngx_current_msec; @@ -1081,7 +1082,7 @@ ngx_quic_input_handler(ngx_event_t *rev) ngx_buf_t b; ngx_connection_t *c; ngx_quic_connection_t *qc; - static u_char buf[NGX_QUIC_DEFAULT_MAX_PACKET_SIZE]; + static u_char buf[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE]; ngx_memzero(&b, sizeof(ngx_buf_t)); b.start = buf; @@ -1446,7 +1447,7 @@ ngx_quic_retry_input(ngx_connection_t *c ngx_quic_secrets_t *keys; ngx_quic_send_ctx_t *ctx; ngx_quic_connection_t *qc; - static u_char buf[NGX_QUIC_DEFAULT_MAX_PACKET_SIZE]; + static u_char buf[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE]; c->log->action = "retrying quic connection"; @@ -1534,7 +1535,7 @@ ngx_quic_initial_input(ngx_connection_t ngx_ssl_conn_t *ssl_conn; ngx_quic_secrets_t *keys; ngx_quic_send_ctx_t *ctx; - static u_char buf[NGX_QUIC_DEFAULT_MAX_PACKET_SIZE]; + static u_char buf[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE]; c->log->action = "processing initial quic packet"; @@ -1573,7 +1574,7 @@ ngx_quic_handshake_input(ngx_connection_ ngx_quic_secrets_t *keys; ngx_quic_send_ctx_t *ctx; ngx_quic_connection_t *qc; - static u_char buf[NGX_QUIC_DEFAULT_MAX_PACKET_SIZE]; + static u_char buf[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE]; c->log->action = "processing handshake quic packet"; @@ -1630,7 +1631,7 @@ ngx_quic_early_input(ngx_connection_t *c ngx_quic_secrets_t *keys; ngx_quic_send_ctx_t *ctx; ngx_quic_connection_t *qc; - static u_char buf[NGX_QUIC_DEFAULT_MAX_PACKET_SIZE]; + static u_char buf[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE]; c->log->action = "processing early data quic packet"; @@ -1710,7 +1711,7 @@ ngx_quic_app_input(ngx_connection_t *c, ngx_quic_secrets_t *keys, *next, tmp; ngx_quic_send_ctx_t *ctx; ngx_quic_connection_t *qc; - static u_char buf[NGX_QUIC_DEFAULT_MAX_PACKET_SIZE]; + static u_char buf[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE]; c->log->action = "processing application data quic packet"; @@ -2963,7 +2964,7 @@ ngx_quic_output_frames(ngx_connection_t n = ngx_quic_create_frame(NULL, f); - if (len && hlen + len + n > qc->ctp.max_packet_size) { + if (len && hlen + len + n > qc->ctp.max_udp_payload_size) { break; } @@ -3062,8 +3063,8 @@ ngx_quic_send_frames(ngx_connection_t *c ngx_quic_send_ctx_t *ctx; ngx_quic_connection_t *qc; static ngx_str_t initial_token = ngx_null_string; - static u_char src[NGX_QUIC_DEFAULT_MAX_PACKET_SIZE]; - static u_char dst[NGX_QUIC_DEFAULT_MAX_PACKET_SIZE]; + static u_char src[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE]; + static u_char dst[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE]; ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, "quic ngx_quic_send_frames"); @@ -3632,7 +3633,7 @@ ngx_quic_stream_send(ngx_connection_t *c * we need to fit at least 1 frame into a packet, thus account head/tail; * 25 = 1 + 8x3 is max header for STREAM frame, with 1 byte for frame type */ - limit = qc->ctp.max_packet_size - NGX_QUIC_MAX_SHORT_HEADER - 25 + limit = qc->ctp.max_udp_payload_size - NGX_QUIC_MAX_SHORT_HEADER - 25 - EVP_GCM_TLS_TAG_LEN; len = size; @@ -3912,7 +3913,7 @@ ngx_quic_congestion_ack(ngx_connection_t cg->window, cg->ssthresh, cg->in_flight); } else { - cg->window += qc->tp.max_packet_size * n / cg->window; + cg->window += qc->tp.max_udp_payload_size * n / cg->window; ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, "quic congestion avoidance win:%uz, ss:%uz, if:%uz", @@ -3948,8 +3949,8 @@ ngx_quic_congestion_lost(ngx_connection_ cg->recovery_start = ngx_current_msec; cg->window /= 2; - if (cg->window < qc->tp.max_packet_size * 2) { - cg->window = qc->tp.max_packet_size * 2; + if (cg->window < qc->tp.max_udp_payload_size * 2) { + cg->window = qc->tp.max_udp_payload_size * 2; } cg->ssthresh = cg->window; 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 @@ -19,7 +19,7 @@ #define NGX_QUIC_MAX_LONG_HEADER 56 /* 1 flags + 4 version + 2 x (1 + 20) s/dcid + 4 pn + 4 len + token len */ -#define NGX_QUIC_DEFAULT_MAX_PACKET_SIZE 65527 +#define NGX_QUIC_MAX_UDP_PAYLOAD_SIZE 65527 #define NGX_QUIC_DEFAULT_ACK_DELAY_EXPONENT 3 #define NGX_QUIC_DEFAULT_MAX_ACK_DELAY 25 @@ -46,7 +46,7 @@ typedef struct { ngx_msec_t max_idle_timeout; ngx_msec_t max_ack_delay; - size_t max_packet_size; + size_t max_udp_payload_size; size_t initial_max_data; size_t initial_max_stream_data_bidi_local; size_t initial_max_stream_data_bidi_remote; diff --git a/src/event/ngx_event_quic_protection.c b/src/event/ngx_event_quic_protection.c --- a/src/event/ngx_event_quic_protection.c +++ b/src/event/ngx_event_quic_protection.c @@ -1115,7 +1115,7 @@ ngx_quic_decrypt(ngx_quic_header_t *pkt, pkt->payload.len = in.len - EVP_GCM_TLS_TAG_LEN; - if (NGX_QUIC_DEFAULT_MAX_PACKET_SIZE - ad.len < pkt->payload.len) { + if (NGX_QUIC_MAX_UDP_PAYLOAD_SIZE - ad.len < pkt->payload.len) { return NGX_ERROR; } diff --git a/src/event/ngx_event_quic_transport.c b/src/event/ngx_event_quic_transport.c --- a/src/event/ngx_event_quic_transport.c +++ b/src/event/ngx_event_quic_transport.c @@ -1366,7 +1366,7 @@ ngx_quic_parse_transport_param(u_char *p return NGX_OK; case NGX_QUIC_TP_MAX_IDLE_TIMEOUT: - case NGX_QUIC_TP_MAX_PACKET_SIZE: + case NGX_QUIC_TP_MAX_UDP_PAYLOAD_SIZE: case NGX_QUIC_TP_INITIAL_MAX_DATA: case NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL: case NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE: @@ -1393,8 +1393,8 @@ ngx_quic_parse_transport_param(u_char *p dst->max_idle_timeout = varint; break; - case NGX_QUIC_TP_MAX_PACKET_SIZE: - dst->max_packet_size = varint; + case NGX_QUIC_TP_MAX_UDP_PAYLOAD_SIZE: + dst->max_udp_payload_size = varint; break; case NGX_QUIC_TP_INITIAL_MAX_DATA: @@ -1509,8 +1509,9 @@ ngx_quic_parse_transport_params(u_char * ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "quic tp idle_timeout: %ui", tp->max_idle_timeout); - ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "quic tp max_packet_size: %ui", - tp->max_packet_size); + ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, + "quic tp max_udp_payload_size: %ui", + tp->max_udp_payload_size); ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "quic tp max_data: %ui", tp->initial_max_data); diff --git a/src/event/ngx_event_quic_transport.h b/src/event/ngx_event_quic_transport.h --- a/src/event/ngx_event_quic_transport.h +++ b/src/event/ngx_event_quic_transport.h @@ -99,7 +99,7 @@ #define NGX_QUIC_TP_ORIGINAL_CONNECTION_ID 0x00 #define NGX_QUIC_TP_MAX_IDLE_TIMEOUT 0x01 #define NGX_QUIC_TP_STATELESS_RESET_TOKEN 0x02 -#define NGX_QUIC_TP_MAX_PACKET_SIZE 0x03 +#define NGX_QUIC_TP_MAX_UDP_PAYLOAD_SIZE 0x03 #define NGX_QUIC_TP_INITIAL_MAX_DATA 0x04 #define NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL 0x05 #define NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE 0x06 diff --git a/src/http/v3/ngx_http_v3_module.c b/src/http/v3/ngx_http_v3_module.c --- a/src/http/v3/ngx_http_v3_module.c +++ b/src/http/v3/ngx_http_v3_module.c @@ -11,14 +11,14 @@ static char *ngx_http_v3_max_ack_delay(ngx_conf_t *cf, void *post, void *data); -static char *ngx_http_v3_max_packet_size(ngx_conf_t *cf, void *post, +static char *ngx_http_v3_max_udp_payload_size(ngx_conf_t *cf, void *post, void *data); static ngx_conf_post_t ngx_http_v3_max_ack_delay_post = { ngx_http_v3_max_ack_delay }; -static ngx_conf_post_t ngx_http_v3_max_packet_size_post = - { ngx_http_v3_max_packet_size }; +static ngx_conf_post_t ngx_http_v3_max_udp_payload_size_post = + { ngx_http_v3_max_udp_payload_size }; static ngx_conf_num_bounds_t ngx_http_v3_ack_delay_exponent_bounds = { ngx_conf_check_num_bounds, 0, 20 }; static ngx_conf_num_bounds_t ngx_http_v3_active_connection_id_limit_bounds = @@ -41,12 +41,12 @@ static ngx_command_t ngx_http_v3_comman offsetof(ngx_http_v3_srv_conf_t, quic.max_ack_delay), &ngx_http_v3_max_ack_delay_post }, - { ngx_string("quic_max_packet_size"), + { ngx_string("quic_max_udp_payload_size"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, ngx_conf_set_size_slot, NGX_HTTP_SRV_CONF_OFFSET, - offsetof(ngx_http_v3_srv_conf_t, quic.max_packet_size), - &ngx_http_v3_max_packet_size_post }, + offsetof(ngx_http_v3_srv_conf_t, quic.max_udp_payload_size), + &ngx_http_v3_max_udp_payload_size_post }, { ngx_string("quic_initial_max_data"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, @@ -253,7 +253,7 @@ ngx_http_v3_create_srv_conf(ngx_conf_t * v3cf->quic.max_idle_timeout = NGX_CONF_UNSET_MSEC; v3cf->quic.max_ack_delay = NGX_CONF_UNSET_MSEC; - v3cf->quic.max_packet_size = NGX_CONF_UNSET_SIZE; + v3cf->quic.max_udp_payload_size = NGX_CONF_UNSET_SIZE; v3cf->quic.initial_max_data = NGX_CONF_UNSET_SIZE; v3cf->quic.initial_max_stream_data_bidi_local = NGX_CONF_UNSET_SIZE; v3cf->quic.initial_max_stream_data_bidi_remote = NGX_CONF_UNSET_SIZE; @@ -283,9 +283,9 @@ ngx_http_v3_merge_srv_conf(ngx_conf_t *c prev->quic.max_ack_delay, NGX_QUIC_DEFAULT_MAX_ACK_DELAY); - ngx_conf_merge_size_value(conf->quic.max_packet_size, - prev->quic.max_packet_size, - NGX_QUIC_DEFAULT_MAX_PACKET_SIZE); + ngx_conf_merge_size_value(conf->quic.max_udp_payload_size, + prev->quic.max_udp_payload_size, + NGX_QUIC_MAX_UDP_PAYLOAD_SIZE); ngx_conf_merge_size_value(conf->quic.initial_max_data, prev->quic.initial_max_data, @@ -349,17 +349,18 @@ ngx_http_v3_max_ack_delay(ngx_conf_t *cf static char * -ngx_http_v3_max_packet_size(ngx_conf_t *cf, void *post, void *data) +ngx_http_v3_max_udp_payload_size(ngx_conf_t *cf, void *post, void *data) { size_t *sp = data; if (*sp < NGX_QUIC_MIN_INITIAL_SIZE - || *sp > NGX_QUIC_DEFAULT_MAX_PACKET_SIZE) + || *sp > NGX_QUIC_MAX_UDP_PAYLOAD_SIZE) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "\"quic_max_packet_size\" must be between %d and %d", + "\"quic_max_udp_payload_size\" must be between " + "%d and %d", NGX_QUIC_MIN_INITIAL_SIZE, - NGX_QUIC_DEFAULT_MAX_PACKET_SIZE); + NGX_QUIC_MAX_UDP_PAYLOAD_SIZE); return NGX_CONF_ERROR; }