]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: remove qcc_decode_qcs() call in XPRT
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 18 May 2022 09:38:22 +0000 (11:38 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 18 May 2022 13:50:57 +0000 (15:50 +0200)
Slightly change the interface for qcc_recv() between MUX and XPRT. The
MUX is now responsible to call qcc_decode_qcs(). This is cleaner as now
the XPRT does not have to deal with an extra QCS parameter and the MUX
will call qcc_decode_qcs() only if really needed.

This change is possible since there is no extra buffering for
out-of-order STREAM frames and the XPRT does not have to handle buffered
frames.

include/haproxy/mux_quic.h
src/mux_quic.c
src/xprt_quic.c

index dc14277ce78f44f3315482e0608076f095cc5fd9..55c6b00663f8b5a2a8df9192e57715c71fa89eec 100644 (file)
@@ -25,10 +25,9 @@ void qcs_notify_recv(struct qcs *qcs);
 void qcs_notify_send(struct qcs *qcs);
 
 int qcc_recv(struct qcc *qcc, uint64_t id, uint64_t len, uint64_t offset,
-             char fin, char *data, struct qcs **out_qcs);
+             char fin, char *data);
 int qcc_recv_max_data(struct qcc *qcc, uint64_t max);
 int qcc_recv_max_stream_data(struct qcc *qcc, uint64_t id, uint64_t max);
-int qcc_decode_qcs(struct qcc *qcc, struct qcs *qcs);
 void qcc_streams_sent_done(struct qcs *qcs, uint64_t data, uint64_t offset);
 
 /* Bit shift to get the stream sub ID for internal use which is obtained
index bd671af9de99479f795f18adc573e50c97b64f19..1f15fa76aeb47f8ada9c02acc9dcfc2648a8d74b 100644 (file)
@@ -364,23 +364,41 @@ struct qcs *qcc_get_qcs(struct qcc *qcc, uint64_t id)
        return NULL;
 }
 
-/* Handle a new STREAM frame <strm_frm>. The frame content will be copied in
- * the buffer of the stream instance. The stream instance will be stored in
- * <out_qcs>. In case of success, the caller can immediatly call qcc_decode_qcs
- * to process the frame content.
+/* Decode the content of STREAM frames already received on the stream instance
+ * <qcs>.
+ *
+ * Returns 0 on success else non-zero.
+ */
+static int qcc_decode_qcs(struct qcc *qcc, struct qcs *qcs)
+{
+       TRACE_ENTER(QMUX_EV_QCS_RECV, qcc->conn, qcs);
+
+       if (qcc->app_ops->decode_qcs(qcs, qcs->flags & QC_SF_FIN_RECV, qcc->ctx) < 0) {
+               TRACE_DEVEL("leaving on decoding error", QMUX_EV_QCS_RECV, qcc->conn, qcs);
+               return 1;
+       }
+
+       qcs_notify_recv(qcs);
+
+       TRACE_LEAVE(QMUX_EV_QCS_RECV, qcc->conn, qcs);
+
+       return 0;
+}
+
+/* Handle a new STREAM frame for stream with id <id>. Payload is pointed by
+ * <data> with length <len> and represents the offset <offset>. <fin> is set if
+ * the QUIC frame FIN bit is set.
  *
  * Returns 0 on success else non-zero.
  */
 int qcc_recv(struct qcc *qcc, uint64_t id, uint64_t len, uint64_t offset,
-             char fin, char *data, struct qcs **out_qcs)
+             char fin, char *data)
 {
        struct qcs *qcs;
        enum ncb_ret ret;
 
        TRACE_ENTER(QMUX_EV_QCC_RECV, qcc->conn);
 
-       *out_qcs = NULL;
-
        qcs = qcc_get_qcs(qcc, id);
        if (!qcs) {
                if ((id >> QCS_ID_TYPE_SHIFT) <= qcc->strms[qcs_id_type(id)].largest_id) {
@@ -393,8 +411,6 @@ int qcc_recv(struct qcc *qcc, uint64_t id, uint64_t len, uint64_t offset,
                }
        }
 
-       *out_qcs = qcs;
-
        if (offset + len <= qcs->rx.offset) {
                TRACE_DEVEL("leaving on already received offset", QMUX_EV_QCC_RECV|QMUX_EV_QCS_RECV, qcc->conn, qcs);
                return 0;
@@ -439,6 +455,9 @@ int qcc_recv(struct qcc *qcc, uint64_t id, uint64_t len, uint64_t offset,
        if (fin)
                qcs->flags |= QC_SF_FIN_RECV;
 
+       if (ncb_data(&qcs->rx.ncbuf, 0) && !(qcs->flags & QC_SF_DEM_FULL))
+               qcc_decode_qcs(qcc, qcs);
+
        TRACE_LEAVE(QMUX_EV_QCC_RECV, qcc->conn);
        return 0;
 }
@@ -487,27 +506,6 @@ int qcc_recv_max_stream_data(struct qcc *qcc, uint64_t id, uint64_t max)
        return 0;
 }
 
-/* Decode the content of STREAM frames already received on the stream instance
- * <qcs>.
- *
- * Returns 0 on success else non-zero.
- */
-int qcc_decode_qcs(struct qcc *qcc, struct qcs *qcs)
-{
-       TRACE_ENTER(QMUX_EV_QCS_RECV, qcc->conn, qcs);
-
-       if (qcc->app_ops->decode_qcs(qcs, qcs->flags & QC_SF_FIN_RECV, qcc->ctx) < 0) {
-               TRACE_DEVEL("leaving on decoding error", QMUX_EV_QCS_RECV, qcc->conn, qcs);
-               return 1;
-       }
-
-       qcs_notify_recv(qcs);
-
-       TRACE_LEAVE(QMUX_EV_QCS_RECV, qcc->conn, qcs);
-
-       return 0;
-}
-
 static int qc_is_max_streams_needed(struct qcc *qcc)
 {
        return qcc->lfctl.cl_bidi_r > qcc->lfctl.ms_bidi_init / 2;
index ed6321865ed0503c0eed55cb9dea9f66a7c5b2ed..de01f93cb3ea9d5465460022c118df0cd1056644 100644 (file)
@@ -2158,19 +2158,16 @@ static int qc_handle_bidi_strm_frm(struct quic_rx_packet *pkt,
                                    struct quic_stream *strm_frm,
                                    struct quic_conn *qc)
 {
-       struct qcs *qcs = NULL;
        int ret;
 
        ret = qcc_recv(qc->qcc, strm_frm->id, strm_frm->len,
                       strm_frm->offset.key, strm_frm->fin,
-                      (char *)strm_frm->data, &qcs);
+                      (char *)strm_frm->data);
 
        /* frame rejected - packet must not be acknowledeged */
        if (ret)
                return 0;
 
-       if (qcs)
-               qcc_decode_qcs(qc->qcc, qcs);
        return 1;
 }