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.
This commit is contained in:
parent
2730e38d8b
commit
1c29db5dba
3 changed files with 10 additions and 11 deletions
|
@ -358,7 +358,7 @@ ngx_quic_process_stateless_reset(ngx_connection_t *c, ngx_quic_header_t *pkt)
|
||||||
qc = ngx_quic_get_connection(c);
|
qc = ngx_quic_get_connection(c);
|
||||||
|
|
||||||
/* A stateless reset uses an entire UDP datagram */
|
/* A stateless reset uses an entire UDP datagram */
|
||||||
if (pkt->raw->start != pkt->data) {
|
if (!pkt->first) {
|
||||||
return NGX_DECLINED;
|
return NGX_DECLINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,7 +666,7 @@ static ngx_int_t
|
||||||
ngx_quic_input(ngx_connection_t *c, ngx_buf_t *b, ngx_quic_conf_t *conf)
|
ngx_quic_input(ngx_connection_t *c, ngx_buf_t *b, ngx_quic_conf_t *conf)
|
||||||
{
|
{
|
||||||
size_t size;
|
size_t size;
|
||||||
u_char *p;
|
u_char *p, *start;
|
||||||
ngx_int_t rc;
|
ngx_int_t rc;
|
||||||
ngx_uint_t good;
|
ngx_uint_t good;
|
||||||
ngx_quic_header_t pkt;
|
ngx_quic_header_t pkt;
|
||||||
|
@ -676,7 +676,7 @@ ngx_quic_input(ngx_connection_t *c, ngx_buf_t *b, ngx_quic_conf_t *conf)
|
||||||
|
|
||||||
size = b->last - b->pos;
|
size = b->last - b->pos;
|
||||||
|
|
||||||
p = b->pos;
|
p = start = b->pos;
|
||||||
|
|
||||||
while (p < b->last) {
|
while (p < b->last) {
|
||||||
|
|
||||||
|
@ -685,6 +685,7 @@ ngx_quic_input(ngx_connection_t *c, ngx_buf_t *b, ngx_quic_conf_t *conf)
|
||||||
pkt.data = p;
|
pkt.data = p;
|
||||||
pkt.len = b->last - p;
|
pkt.len = b->last - p;
|
||||||
pkt.log = c->log;
|
pkt.log = c->log;
|
||||||
|
pkt.first = (p == start) ? 1 : 0;
|
||||||
pkt.flags = p[0];
|
pkt.flags = p[0];
|
||||||
pkt.raw->pos++;
|
pkt.raw->pos++;
|
||||||
|
|
||||||
|
@ -979,8 +980,10 @@ ngx_quic_process_payload(ngx_connection_t *c, ngx_quic_header_t *pkt)
|
||||||
|
|
||||||
pkt->decrypted = 1;
|
pkt->decrypted = 1;
|
||||||
|
|
||||||
if (ngx_quic_update_paths(c, pkt) != NGX_OK) {
|
if (pkt->first) {
|
||||||
return NGX_ERROR;
|
if (ngx_quic_update_paths(c, pkt) != NGX_OK) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->ssl == NULL) {
|
if (c->ssl == NULL) {
|
||||||
|
|
|
@ -388,12 +388,7 @@ ngx_quic_update_paths(ngx_connection_t *c, ngx_quic_header_t *pkt)
|
||||||
|
|
||||||
update:
|
update:
|
||||||
|
|
||||||
if (pkt->raw->start == pkt->data) {
|
len = pkt->raw->last - pkt->raw->start;
|
||||||
len = pkt->raw->last - pkt->raw->start;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
len = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO: this may be too late in some cases;
|
/* TODO: this may be too late in some cases;
|
||||||
* for example, if error happens during decrypt(), we cannot
|
* for example, if error happens during decrypt(), we cannot
|
||||||
|
|
|
@ -334,6 +334,7 @@ typedef struct {
|
||||||
unsigned decrypted:1;
|
unsigned decrypted:1;
|
||||||
unsigned validated:1;
|
unsigned validated:1;
|
||||||
unsigned retried:1;
|
unsigned retried:1;
|
||||||
|
unsigned first:1;
|
||||||
} ngx_quic_header_t;
|
} ngx_quic_header_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue