]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: adjust error code in init failure
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 18 Dec 2023 18:13:09 +0000 (19:13 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 20 Dec 2023 14:27:11 +0000 (15:27 +0100)
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

index 9585bb4cc147bc91958d064bedf1cb159721a652..a2bf855819782eb00eea4e44a3c4daba4d8ebd31 100644 (file)
@@ -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;