]> git.kaiwu.me - nginx.git/commitdiff
QUIC: avoid updating connection address for a backup path master
authorVadim Zhestikov <v.zhestikov@f5.com>
Tue, 20 Oct 2026 20:02:35 +0000 (13:02 -0700)
committerSergey Kandaurov <pluknet@nginx.com>
Fri, 27 Nov 2026 15:22:14 +0000 (19:22 +0400)
On NAT rebinding, both the new path and the previously active path
are validated.  If the previous path, now a backup, was validated
last, the connection address was updated to its address, and new
streams used it while packets were exchanged on the new path.

Validation of the previous path only checks that it is still viable
and does not make it active again, see RFC 9000, 9.3.3.  The fix is
to update the connection address only for the active path.  If the
client migrates back to the previous path, the address is updated in
ngx_quic_handle_migration(), as the path is already validated.

The connection address is also updated when a backup path is restored
after the active path fails validation.  Commit f37ec3e5d removed this,
assuming the address never tracked a path that could later fail; an
incomplete MTU validation breaks that assumption, as the address is
set after the first, size-limited round and before the path is
re-validated with full-size datagrams.

The problem appeared in f37ec3e5d (1.31.0).

Reported by Keita Sode of SYZD Research LLC.

src/event/quic/ngx_event_quic_migration.c

index be8ff22aa99e553264967690813265424b9a9885..623f00354c93a3f4809101f289a1538f03ba15ab 100644 (file)
@@ -196,7 +196,9 @@ valid:
 
     path->validated = 1;
 
 
     path->validated = 1;
 
-    ngx_quic_set_connection_path(c, path);
+    if (path == qc->path) {
+        ngx_quic_set_connection_path(c, path);
+    }
 
     if (path->mtu_unvalidated) {
         path->mtu_unvalidated = 0;
 
     if (path->mtu_unvalidated) {
         path->mtu_unvalidated = 0;
@@ -821,6 +823,8 @@ ngx_quic_expire_path_validation(ngx_connection_t *c, ngx_quic_path_t *path)
         qc->path = bkp;
         qc->path->tag = NGX_QUIC_PATH_ACTIVE;
 
         qc->path = bkp;
         qc->path->tag = NGX_QUIC_PATH_ACTIVE;
 
+        ngx_quic_set_connection_path(c, qc->path);
+
         ngx_log_error(NGX_LOG_INFO, c->log, 0,
                       "quic path seq:%uL addr:%V is restored from backup",
                       qc->path->seqnum, &qc->path->addr_text);
         ngx_log_error(NGX_LOG_INFO, c->log, 0,
                       "quic path seq:%uL addr:%V is restored from backup",
                       qc->path->seqnum, &qc->path->addr_text);