From 8dbaaccdf05f4beb68edd23ea7c2a1871c34dec1 Mon Sep 17 00:00:00 2001 From: Frederic Lecaille Date: Thu, 11 Sep 2025 18:20:47 +0200 Subject: [PATCH] WIP: TO CHECK!!! quic-be: Start asap the mux for 0-RTT The mux is created and woken up as soon as possible. This means as soon as the TX early data encryption level keys are installed. These keys are installed on the first SSL_do_handshake() call. This call is done as soon as the connection is created. This way the mux is able to send 0-RTT packets alongside Initial packets. --- src/quic_ssl.c | 2 +- src/xprt_quic.c | 27 ++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/quic_ssl.c b/src/quic_ssl.c index f49bd2c2c..144878e11 100644 --- a/src/quic_ssl.c +++ b/src/quic_ssl.c @@ -978,7 +978,7 @@ int qc_ssl_do_hanshake(struct quic_conn *qc, struct ssl_sock_ctx *ctx) goto err; } } - else { + else if (qc->mux_state != QC_MUX_READY) { const unsigned char *alpn; size_t alpn_len; diff --git a/src/xprt_quic.c b/src/xprt_quic.c index dbcbb4caf..04b6424f2 100644 --- a/src/xprt_quic.c +++ b/src/xprt_quic.c @@ -152,7 +152,7 @@ static int qc_conn_init(struct connection *conn, void **xprt_ctx) /* Start the QUIC transport layer */ static int qc_xprt_start(struct connection *conn, void *ctx) { - int ret = 0; + int ret = -1; struct quic_conn *qc; qc = conn->handle.qc; @@ -167,7 +167,25 @@ static int qc_xprt_start(struct connection *conn, void *ctx) * the SSL object. */ if (!qc_ssl_do_hanshake(qc, ctx)) - goto out; + goto err; + + if (qc->eel) { + struct ssl_sock_ctx *ssl_ctx = ctx; + + /* Start the mux asap when early data encryption level is available. */ + conn->flags |= CO_FL_WAIT_XPRT; + if (conn_create_mux(ssl_ctx->conn, NULL) < 0) { + TRACE_ERROR("mux creation failed", QUIC_EV_CONN_IO_CB, qc, &qc->state); + goto err; + } + + ssl_ctx->conn->flags &= ~CO_FL_WAIT_XPRT; + qc->mux_state = QC_MUX_READY; + /* Wake up MUX after its creation. Operation similar to TLS+ALPN on + * TCP stack. + */ + ssl_ctx->conn->mux->wake(ssl_ctx->conn); + } } /* Schedule quic-conn to ensure post handshake frames are emitted. This @@ -178,9 +196,12 @@ static int qc_xprt_start(struct connection *conn, void *ctx) tasklet_wakeup(qc->wait_event.tasklet); ret = 1; - out: + leave: TRACE_LEAVE(QUIC_EV_CONN_NEW, qc); return ret; + err: + TRACE_DEVEL("leaving on error", QUIC_EV_CONN_NEW, qc); + goto leave; } static struct ssl_sock_ctx *qc_get_ssl_sock_ctx(struct connection *conn) -- 2.47.3