Mercurial > hg > nginx
changeset 8912:50d73bf20e73 quic
QUIC: refactored multiple QUIC packets handling.
Single UDP datagram may contain multiple QUIC datagrams. In order to
facilitate handling of such cases, 'first' flag in the ngx_quic_header_t
structure is introduced.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Mon, 29 Nov 2021 11:49:09 +0300 |
parents | b09f055daa4e |
children | 40445fc7c403 |
files | src/event/quic/ngx_event_quic.c src/event/quic/ngx_event_quic_migration.c src/event/quic/ngx_event_quic_transport.h |
diffstat | 3 files changed, 10 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/event/quic/ngx_event_quic.c Thu Nov 18 14:19:36 2021 +0300 +++ b/src/event/quic/ngx_event_quic.c Mon Nov 29 11:49:09 2021 +0300 @@ -358,7 +358,7 @@ qc = ngx_quic_get_connection(c); /* A stateless reset uses an entire UDP datagram */ - if (pkt->raw->start != pkt->data) { + if (!pkt->first) { return NGX_DECLINED; } @@ -666,7 +666,7 @@ ngx_quic_input(ngx_connection_t *c, ngx_buf_t *b, ngx_quic_conf_t *conf) { size_t size; - u_char *p; + u_char *p, *start; ngx_int_t rc; ngx_uint_t good; ngx_quic_header_t pkt; @@ -676,7 +676,7 @@ size = b->last - b->pos; - p = b->pos; + p = start = b->pos; while (p < b->last) { @@ -685,6 +685,7 @@ pkt.data = p; pkt.len = b->last - p; pkt.log = c->log; + pkt.first = (p == start) ? 1 : 0; pkt.flags = p[0]; pkt.raw->pos++; @@ -979,8 +980,10 @@ pkt->decrypted = 1; - if (ngx_quic_update_paths(c, pkt) != NGX_OK) { - return NGX_ERROR; + if (pkt->first) { + if (ngx_quic_update_paths(c, pkt) != NGX_OK) { + return NGX_ERROR; + } } if (c->ssl == NULL) {
--- a/src/event/quic/ngx_event_quic_migration.c Thu Nov 18 14:19:36 2021 +0300 +++ b/src/event/quic/ngx_event_quic_migration.c Mon Nov 29 11:49:09 2021 +0300 @@ -388,12 +388,7 @@ update: - if (pkt->raw->start == pkt->data) { - len = pkt->raw->last - pkt->raw->start; - - } else { - len = 0; - } + len = pkt->raw->last - pkt->raw->start; /* TODO: this may be too late in some cases; * for example, if error happens during decrypt(), we cannot