]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux-quic: prevent quic_conn error code to be overwritten
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 4 May 2023 13:36:17 +0000 (15:36 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 4 May 2023 14:36:51 +0000 (16:36 +0200)
When MUX performs a graceful shutdown, quic_conn error code is set to a
"no error" code which depends on the application layer used. However,
this may overwrite a previous error code if quic_conn layer has detected
an error on its side.

In practice, this behavior has not been seen on production. In fact, it
may have undesirable effect only if this error code modification happens
between the quic_conn error detection and the emission of the
CONNECTION_CLOSE, so it should be pretty rare. However, there is still a
tiny possibility it may happen.

To prevent this, first check that quic_conn error code is not set before
setting it. Ideally, transport layer API should be adjusted to be able
to set this without fiddling with the quic_conn directly.

This should be backported up to 2.6.

src/mux_quic.c

index 82d2076c6f231a76af5bcb3f36752d4077e0d219..bd67417019ace468fc04741a040e97d0ba676110 100644 (file)
@@ -851,8 +851,12 @@ void qcc_emit_cc_app(struct qcc *qcc, int err, int immediate)
                tasklet_wakeup(qcc->wait_event.tasklet);
        }
        else {
-               /* Only register the error code for graceful shutdown. */
-               qcc->conn->handle.qc->err = quic_err_app(err);
+               /* Only register the error code for graceful shutdown.
+                * Do not overwrite quic-conn existing code if already set.
+                * TODO implement a wrapper function for this in quic-conn module
+                */
+               if (!(qcc->conn->handle.qc->flags & QUIC_FL_CONN_IMMEDIATE_CLOSE))
+                       qcc->conn->handle.qc->err = quic_err_app(err);
        }
 
        TRACE_LEAVE(QMUX_EV_QCC_END, qcc->conn);