]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: change return value of qcs_attach_sc()
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 3 Jan 2025 15:16:45 +0000 (16:16 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 3 Jan 2025 16:19:21 +0000 (17:19 +0100)
A recent fix was introduced to ensure that a streamdesc instance won't
be attached to an already completed QCS which is eligible to purging.
This was performed by skipping application protocol decoding if a QCS is
in such a state. Here is the patch responsible for this change.
  caf60ac696a29799631a76beb16d0072f65eef12
  BUG/MEDIUM: mux-quic: do not attach on already closed stream

However, this is too restrictive, in particular for unidirection stream
where no streamdesc is never attached. To fix this behavior, first
qcs_attach_sc() API has been modified. Instead of returning a streamdesc
instance, it returns either 0 on success or a negative error code.

There should be no functional changes with this patch. It is only to be
able to extend qcs_attach_sc() with the possibility of skipping
streamdesc instantiation while still keeping a success return value.

This should be backported wherever the above patch has been merged. For
the record, it was scheduled for immediate backport on 3.1, plus merging
on older releases up to 2.8 after a period of observation.

include/haproxy/mux_quic.h
src/h3.c
src/hq_interop.c
src/mux_quic.c

index bfdf4dd1caad4823ccd245750c6120c4a9233086..8b2444ccc4c91b8daad5801cd6e62fa303ffa2b1 100644 (file)
@@ -21,7 +21,7 @@ void qcc_set_error(struct qcc *qcc, int err, int app);
 int _qcc_report_glitch(struct qcc *qcc, int inc);
 struct qcs *qcc_init_stream_local(struct qcc *qcc, int bidi);
 void qcs_send_metadata(struct qcs *qcs);
-struct stconn *qcs_attach_sc(struct qcs *qcs, struct buffer *buf, char fin);
+int qcs_attach_sc(struct qcs *qcs, struct buffer *buf, char fin);
 int qcs_is_close_local(struct qcs *qcs);
 int qcs_is_close_remote(struct qcs *qcs);
 
index 9f7bb02067672601c7e0429b87e89ef1bee165aa..48bf6d8de9ebe1e998ba2906c9f555a48202561d 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -915,7 +915,7 @@ static ssize_t h3_headers_to_htx(struct qcs *qcs, const struct buffer *buf,
        htx_to_buf(htx, &htx_buf);
        htx = NULL;
 
-       if (!qcs_attach_sc(qcs, &htx_buf, fin)) {
+       if (qcs_attach_sc(qcs, &htx_buf, fin)) {
                len = -1;
                goto out;
        }
index 18e9e2ccc2bccb147a9b3928a074cec8d088d1a3..1d7821fec9571c47b271da8361146bc37a8800d6 100644 (file)
@@ -77,7 +77,7 @@ static ssize_t hq_interop_rcv_buf(struct qcs *qcs, struct buffer *b, int fin)
        htx->flags |= HTX_FL_EOM;
        htx_to_buf(htx, &htx_buf);
 
-       if (!qcs_attach_sc(qcs, &htx_buf, fin))
+       if (qcs_attach_sc(qcs, &htx_buf, fin))
                return -1;
 
        b_free(&htx_buf);
index dac22af35d883470f7fdcbf6dd7427014f046fac..5ff0060903c574c5440d121173c9b5851768715d 100644 (file)
@@ -899,9 +899,9 @@ void qcs_send_metadata(struct qcs *qcs)
  * the first received request data. <fin> must be set if the whole request is
  * already received.
  *
- * Returns the newly allocated instance on success or NULL on error.
+ * Returns 0 on success else a negative error code.
  */
-struct stconn *qcs_attach_sc(struct qcs *qcs, struct buffer *buf, char fin)
+int qcs_attach_sc(struct qcs *qcs, struct buffer *buf, char fin)
 {
        struct qcc *qcc = qcs->qcc;
        struct session *sess = qcc->conn->owner;
@@ -913,7 +913,7 @@ struct stconn *qcs_attach_sc(struct qcs *qcs, struct buffer *buf, char fin)
 
        if (!sc_new_from_endp(qcs->sd, sess, buf)) {
                TRACE_DEVEL("leaving on error", QMUX_EV_STRM_RECV, qcc->conn, qcs);
-               return NULL;
+               return -1;
        }
 
        /* QC_SF_HREQ_RECV must be set once for a stream. Else, nb_hreq counter
@@ -959,7 +959,7 @@ struct stconn *qcs_attach_sc(struct qcs *qcs, struct buffer *buf, char fin)
        }
 
        TRACE_LEAVE(QMUX_EV_STRM_RECV, qcc->conn, qcs);
-       return qcs->sd->sc;
+       return 0;
 }
 
 /* Use this function for a stream <id> which is not in <qcc> stream tree. It