Mercurial > hg > nginx-quic
changeset 8078:d45961e062fa quic
QUIC: refactored ngx_quic_retry_input().
The function now returns NGX_DECLINED for packets that need to be ignored
and integrates nicely into ngx_quic_input().
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Fri, 04 Sep 2020 15:48:53 +0300 |
parents | 62db595a86b5 |
children | dcbb58e7ed11 |
files | src/event/ngx_event_quic.c |
diffstat | 1 files changed, 10 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/event/ngx_event_quic.c +++ b/src/event/ngx_event_quic.c @@ -1098,10 +1098,6 @@ ngx_quic_validate_token(ngx_connection_t ngx_quic_connection_t *qc; u_char tdec[NGX_QUIC_MAX_TOKEN_SIZE]; - if (pkt->token.len == 0) { - return NGX_ERROR; - } - qc = c->quic; /* Retry token */ @@ -1616,10 +1612,9 @@ ngx_quic_input(ngx_connection_t *c, ngx_ pkt.flags = p[0]; if (c->quic->in_retry) { - return ngx_quic_retry_input(c, &pkt); - } - - if (ngx_quic_long_pkt(pkt.flags)) { + rc = ngx_quic_retry_input(c, &pkt); + + } else if (ngx_quic_long_pkt(pkt.flags)) { if (ngx_quic_pkt_in(pkt.flags)) { rc = ngx_quic_initial_input(c, &pkt); @@ -1698,7 +1693,7 @@ ngx_quic_retry_input(ngx_connection_t *c if (ngx_buf_size(pkt->raw) < NGX_QUIC_MIN_INITIAL_SIZE) { ngx_log_error(NGX_LOG_INFO, c->log, 0, "quic UDP datagram is too small for initial packet"); - return NGX_OK; + return NGX_DECLINED; } if (ngx_quic_parse_long_header(pkt) != NGX_OK) { @@ -1714,7 +1709,7 @@ ngx_quic_retry_input(ngx_connection_t *c if (ngx_quic_pkt_zrtt(pkt->flags)) { ngx_log_error(NGX_LOG_INFO, c->log, 0, "quic discard inflight 0-RTT packet"); - return NGX_OK; + return NGX_DECLINED; } if (!ngx_quic_pkt_in(pkt->flags)) { @@ -1727,6 +1722,10 @@ ngx_quic_retry_input(ngx_connection_t *c return NGX_DECLINED; } + if (!pkt->token.len) { + return NGX_DECLINED; + } + if (ngx_quic_new_dcid(c, &pkt->dcid) != NGX_OK) { return NGX_ERROR; } @@ -1773,12 +1772,7 @@ ngx_quic_retry_input(ngx_connection_t *c return NGX_ERROR; } - /* pos is at header end, adjust by actual packet length */ - pkt->raw->pos += pkt->len; - - (void) ngx_quic_skip_zero_padding(pkt->raw); - - return ngx_quic_input(c, pkt->raw); + return NGX_OK; }