From 403492af8e8e369d54d57909bef72b1e4db8e419 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Mon, 18 Dec 2023 19:13:09 +0100 Subject: [PATCH] MINOR: mux-quic: adjust error code in init failure If QUIC MUX cannot be initialized for any reason, the connection is shut down with a CONNECTION_CLOSE frame. Previously, no error code was explicitely specified, resulting in "no error" code. Change this by always set error code in case of QUIC MUX failure. Use the already defined QUIC MUX error code or "internal error" if unset. Call quic_set_connection_close() on error label to register it to the quic_conn layer. This should help to improve error reporting in case of MUX initialization failure. --- src/mux_quic.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mux_quic.c b/src/mux_quic.c index 9585bb4cc..a2bf85581 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -2552,6 +2552,7 @@ static int qmux_init(struct connection *conn, struct proxy *prx, conn->ctx = qcc; qcc->nb_hreq = qcc->nb_sc = 0; qcc->flags = 0; + qcc->err = quic_err_transport(QC_ERR_NO_ERROR); /* Server parameters, params used for RX flow control. */ lparams = &conn->handle.qc->rx.params; @@ -2635,7 +2636,7 @@ static int qmux_init(struct connection *conn, struct proxy *prx, if (qcc_install_app_ops(qcc, conn->handle.qc->app_ops)) { TRACE_PROTO("Cannot install app layer", QMUX_EV_QCC_NEW|QMUX_EV_QCC_ERR, conn); /* prepare a CONNECTION_CLOSE frame */ - quic_set_connection_close(conn->handle.qc, quic_err_transport(QC_ERR_APPLICATION_ERROR)); + qcc_set_error(qcc, QC_ERR_APPLICATION_ERROR, 0); goto err; } @@ -2653,6 +2654,13 @@ static int qmux_init(struct connection *conn, struct proxy *prx, return 0; err: + /* Prepare CONNECTION_CLOSE, using INTERNAL_ERROR as fallback code if unset. */ + if (!(conn->handle.qc->flags & QUIC_FL_CONN_IMMEDIATE_CLOSE)) { + struct quic_err err = qcc && qcc->err.code ? + qcc->err : quic_err_transport(QC_ERR_INTERNAL_ERROR); + quic_set_connection_close(conn->handle.qc, err); + } + if (qcc) { /* In case of MUX init failure, session will ensure connection is freed. */ qcc->conn = NULL;