]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MEDIUM: backend: only start the mux early when 0-RTT may be used
authorOlivier Houchard <ohouchard@haproxy.com>
Thu, 26 Nov 2026 17:51:47 +0000 (18:51 +0100)
committerOlivier Houchard <cognet@ci0.org>
Fri, 27 Nov 2026 12:47:09 +0000 (13:47 +0100)
Since commit d4c51a4f5 ("MEDIUM: server: Make use of the stored ALPN
stored in the server"), the mux is installed before the handshake, from
the cached ALPN, for every SSL server with an ALPN, while this is only
needed to send early data. If the handshake then negotiates another
protocol, the wrong mux stays in place and the request ends in a 502.

Let's only do it for servers with "allow-0rtt". This should help with
github issue #3473, and must be backported to 3.3.

src/backend.c

index 140922c058d86a406fbd3bd94fb5a74cc26da63c..4232be31eba635d0f2dd0e8d505feae5ab167010 100644 (file)
@@ -2080,10 +2080,14 @@ int connect_server(struct stream *s)
                         */
                        if (IS_HTX_STRM(s) && srv->use_ssl &&
                            (srv->ssl_ctx.alpn_str || srv->ssl_ctx.npn_str)) {
-                               HA_RWLOCK_RDLOCK(SERVER_LOCK, &srv->path_params.param_lock);
-                               if (srv->path_params.srv_hash != hash || srv->path_params.nego_alpn[0] == 0)
+                               if (!(srv->ssl_ctx.options & SRV_SSL_O_EARLY_DATA))
                                        may_start_mux_now = 0;
-                               HA_RWLOCK_RDUNLOCK(SERVER_LOCK, &srv->path_params.param_lock);
+                               else {
+                                       HA_RWLOCK_RDLOCK(SERVER_LOCK, &srv->path_params.param_lock);
+                                       if (srv->path_params.srv_hash != hash || srv->path_params.nego_alpn[0] == 0)
+                                               may_start_mux_now = 0;
+                                       HA_RWLOCK_RDUNLOCK(SERVER_LOCK, &srv->path_params.param_lock);
+                               }
                        }
 #endif /* TLSEXT_TYPE_application_layer_protocol_negotiation */