diff src/event/quic/ngx_event_quic_migration.c @ 9096:c6db94ec3841 quic

QUIC: separated path validation retransmit backoff. Path validation packets containing PATH_CHALLENGE frames are sent separately from regular frame queue, because of the need to use a decicated path and pad the packets. The packets are sent periodically, separately from the regular probe/lost detection mechanism. A path validation packet is resent up to 3 times, each time after PTO expiration, with increasing per-path PTO backoff.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 09 May 2023 19:42:39 +0400
parents 28fc35b71d75
children a9fef6ca45a8
line wrap: on
line diff
--- a/src/event/quic/ngx_event_quic_migration.c
+++ b/src/event/quic/ngx_event_quic_migration.c
@@ -496,6 +496,7 @@ ngx_quic_validate_path(ngx_connection_t 
                    "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;
@@ -513,7 +514,6 @@ ngx_quic_validate_path(ngx_connection_t 
     pto = ngx_quic_pto(c, ctx);
 
     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);
@@ -578,7 +578,6 @@ ngx_quic_path_validation_handler(ngx_eve
     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 +604,9 @@ ngx_quic_path_validation_handler(ngx_eve
             continue;
         }
 
-        if (--path->tries) {
+        if (++path->tries < NGX_QUIC_PATH_RETRIES) {
+            pto = ngx_quic_pto(c, ctx) << path->tries;
+
             path->expires = ngx_current_msec + pto;
 
             if (next == -1 || pto < next) {