Latest update - 9089

This commit is contained in:
2023-05-12 11:20:44 +09:00
parent ba55c6c6eb
commit 932841389b
11 changed files with 212 additions and 110 deletions
-1
View File
@@ -69,7 +69,6 @@ typedef struct {
ngx_flag_t disable_active_migration;
ngx_msec_t timeout;
ngx_str_t host_key;
size_t mtu;
size_t stream_buffer_size;
ngx_uint_t max_concurrent_streams_bidi;
ngx_uint_t max_concurrent_streams_uni;
+7 -9
View File
@@ -736,7 +736,8 @@ ngx_quic_set_lost_timer(ngx_connection_t *c)
q = ngx_queue_last(&ctx->sent);
f = ngx_queue_data(q, ngx_quic_frame_t, queue);
w = (ngx_msec_int_t) (f->last + ngx_quic_pto(c, ctx) - now);
w = (ngx_msec_int_t) (f->last + (ngx_quic_pto(c, ctx) << qc->pto_count)
- now);
if (w < 0) {
w = 0;
@@ -782,17 +783,12 @@ ngx_quic_pto(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx)
qc = ngx_quic_get_connection(c);
/* RFC 9002, Appendix A.8. Setting the Loss Detection Timer */
duration = qc->avg_rtt;
duration += ngx_max(4 * qc->rttvar, NGX_QUIC_TIME_GRANULARITY);
duration <<= qc->pto_count;
if (qc->congestion.in_flight == 0) { /* no in-flight packets */
return duration;
}
if (ctx->level == ssl_encryption_application && c->ssl->handshaked) {
duration += qc->ctp.max_ack_delay << qc->pto_count;
duration += qc->ctp.max_ack_delay;
}
return duration;
@@ -850,7 +846,9 @@ ngx_quic_pto_handler(ngx_event_t *ev)
continue;
}
if ((ngx_msec_int_t) (f->last + ngx_quic_pto(c, ctx) - now) > 0) {
if ((ngx_msec_int_t) (f->last + (ngx_quic_pto(c, ctx) << qc->pto_count)
- now) > 0)
{
continue;
}
+53 -13
View File
@@ -16,6 +16,7 @@ static ngx_int_t ngx_quic_validate_path(ngx_connection_t *c,
ngx_quic_path_t *path);
static ngx_int_t ngx_quic_send_path_challenge(ngx_connection_t *c,
ngx_quic_path_t *path);
static void ngx_quic_set_path_timer(ngx_connection_t *c);
static ngx_quic_path_t *ngx_quic_get_path(ngx_connection_t *c, ngx_uint_t tag);
@@ -169,6 +170,8 @@ valid:
path->validating = 0;
path->limited = 0;
ngx_quic_set_path_timer(c);
return NGX_OK;
}
@@ -384,16 +387,13 @@ ngx_quic_free_path(ngx_connection_t *c, ngx_quic_path_t *path)
static void
ngx_quic_set_connection_path(ngx_connection_t *c, ngx_quic_path_t *path)
{
size_t len;
ngx_memcpy(c->sockaddr, path->sockaddr, path->socklen);
c->socklen = path->socklen;
if (c->addr_text.data) {
len = ngx_min(c->addr_text.len, path->addr_text.len);
ngx_memcpy(c->addr_text.data, path->addr_text.data, len);
c->addr_text.len = len;
c->addr_text.len = ngx_sock_ntop(c->sockaddr, c->socklen,
c->addr_text.data,
c->listening->addr_text_max_len, 0);
}
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
@@ -496,6 +496,7 @@ ngx_quic_validate_path(ngx_connection_t *c, ngx_quic_path_t *path)
"quic initiated validation of path seq:%uL", path->seqnum);
path->validating = 1;
path->tries = 0;
if (RAND_bytes(path->challenge1, 8) != 1) {
return NGX_ERROR;
@@ -510,14 +511,11 @@ ngx_quic_validate_path(ngx_connection_t *c, ngx_quic_path_t *path)
}
ctx = ngx_quic_get_send_ctx(qc, ssl_encryption_application);
pto = ngx_quic_pto(c, ctx);
pto = ngx_max(ngx_quic_pto(c, ctx), 1000);
path->expires = ngx_current_msec + pto;
path->tries = NGX_QUIC_PATH_RETRIES;
if (!qc->path_validation.timer_set) {
ngx_add_timer(&qc->path_validation, pto);
}
ngx_quic_set_path_timer(c);
return NGX_OK;
}
@@ -563,6 +561,47 @@ ngx_quic_send_path_challenge(ngx_connection_t *c, ngx_quic_path_t *path)
}
static void
ngx_quic_set_path_timer(ngx_connection_t *c)
{
ngx_msec_t now;
ngx_queue_t *q;
ngx_msec_int_t left, next;
ngx_quic_path_t *path;
ngx_quic_connection_t *qc;
qc = ngx_quic_get_connection(c);
now = ngx_current_msec;
next = -1;
for (q = ngx_queue_head(&qc->paths);
q != ngx_queue_sentinel(&qc->paths);
q = ngx_queue_next(q))
{
path = ngx_queue_data(q, ngx_quic_path_t, queue);
if (!path->validating) {
continue;
}
left = path->expires - now;
left = ngx_max(left, 1);
if (next == -1 || left < next) {
next = left;
}
}
if (next != -1) {
ngx_add_timer(&qc->path_validation, next);
} else if (qc->path_validation.timer_set) {
ngx_del_timer(&qc->path_validation);
}
}
void
ngx_quic_path_validation_handler(ngx_event_t *ev)
{
@@ -578,7 +617,6 @@ ngx_quic_path_validation_handler(ngx_event_t *ev)
qc = ngx_quic_get_connection(c);
ctx = ngx_quic_get_send_ctx(qc, ssl_encryption_application);
pto = ngx_quic_pto(c, ctx);
next = -1;
now = ngx_current_msec;
@@ -605,7 +643,9 @@ ngx_quic_path_validation_handler(ngx_event_t *ev)
continue;
}
if (--path->tries) {
if (++path->tries < NGX_QUIC_PATH_RETRIES) {
pto = ngx_max(ngx_quic_pto(c, ctx), 1000) << path->tries;
path->expires = ngx_current_msec + pto;
if (next == -1 || pto < next) {
+30 -2
View File
@@ -637,10 +637,12 @@ ngx_quic_do_init_streams(ngx_connection_t *c)
static ngx_quic_stream_t *
ngx_quic_create_stream(ngx_connection_t *c, uint64_t id)
{
ngx_str_t addr_text;
ngx_log_t *log;
ngx_pool_t *pool;
ngx_uint_t reusable;
ngx_queue_t *q;
struct sockaddr *sockaddr;
ngx_connection_t *sc;
ngx_quic_stream_t *qs;
ngx_pool_cleanup_t *cln;
@@ -692,6 +694,31 @@ ngx_quic_create_stream(ngx_connection_t *c, uint64_t id)
*log = *c->log;
pool->log = log;
sockaddr = ngx_palloc(pool, c->socklen);
if (sockaddr == NULL) {
ngx_destroy_pool(pool);
ngx_queue_insert_tail(&qc->streams.free, &qs->queue);
return NULL;
}
ngx_memcpy(sockaddr, c->sockaddr, c->socklen);
if (c->addr_text.data) {
addr_text.data = ngx_pnalloc(pool, c->addr_text.len);
if (addr_text.data == NULL) {
ngx_destroy_pool(pool);
ngx_queue_insert_tail(&qc->streams.free, &qs->queue);
return NULL;
}
ngx_memcpy(addr_text.data, c->addr_text.data, c->addr_text.len);
addr_text.len = c->addr_text.len;
} else {
addr_text.len = 0;
addr_text.data = NULL;
}
reusable = c->reusable;
ngx_reusable_connection(c, 0);
@@ -710,9 +737,10 @@ ngx_quic_create_stream(ngx_connection_t *c, uint64_t id)
sc->type = SOCK_STREAM;
sc->pool = pool;
sc->ssl = c->ssl;
sc->sockaddr = c->sockaddr;
sc->sockaddr = sockaddr;
sc->socklen = c->socklen;
sc->listening = c->listening;
sc->addr_text = c->addr_text;
sc->addr_text = addr_text;
sc->local_sockaddr = c->local_sockaddr;
sc->local_socklen = c->local_socklen;
sc->number = ngx_atomic_fetch_add(ngx_connection_counter, 1);
+1 -1
View File
@@ -1987,7 +1987,7 @@ ngx_quic_init_transport_params(ngx_quic_tp_t *tp, ngx_quic_conf_t *qcf)
tp->max_idle_timeout = qcf->timeout;
tp->max_udp_payload_size = qcf->mtu;
tp->max_udp_payload_size = NGX_QUIC_MAX_UDP_PAYLOAD_SIZE;
nstreams = qcf->max_concurrent_streams_bidi
+ qcf->max_concurrent_streams_uni;
+1 -1
View File
@@ -34,7 +34,7 @@ ngx_quic_recvmsg(ngx_event_t *ev)
ngx_event_conf_t *ecf;
ngx_connection_t *c, *lc;
ngx_quic_socket_t *qsock;
static u_char buffer[65535];
static u_char buffer[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE];
#if (NGX_HAVE_ADDRINFO_CMSG)
u_char msg_control[CMSG_SPACE(sizeof(ngx_addrinfo_t))];