]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: clean up qcs Rx buffer allocation API
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 11 Dec 2023 14:34:42 +0000 (15:34 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 11 Dec 2023 15:02:30 +0000 (16:02 +0100)
Replaces qcs_get_buf() function which naming does not reflect its
purpose. Add a new function qcc_get_stream_rxbuf() which allocate if
needed <qcs.rx.app_buf> and returns the buffer pointer. This function is
reserved for application protocol layer. This buffer is then accessed by
stconn layer.

For other qcs_get_buf() invocation which was used in effect for a local
buffer, replace these by a plain b_alloc().

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

index 50baadae0c08f62384e163c5f53db579ff1f55d9..ca5cd56e7fea941e1b74dd744aa1877cdf4f2226 100644 (file)
@@ -17,12 +17,12 @@ struct qcs *qcc_init_stream_local(struct qcc *qcc, int bidi);
 struct stconn *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);
-struct buffer *qcs_get_buf(struct qcs *qcs, struct buffer *bptr);
 
 int qcs_subscribe(struct qcs *qcs, int event_type, struct wait_event *es);
 void qcs_notify_recv(struct qcs *qcs);
 void qcs_notify_send(struct qcs *qcs);
 
+struct buffer *qcc_get_stream_rxbuf(struct qcs *qcs);
 void qcc_reset_stream(struct qcs *qcs, int err);
 void qcc_send_stream(struct qcs *qcs, int urg);
 void qcc_abort_stream_read(struct qcs *qcs);
index f535d858808017892e5ae730c252c371f8285db3..d7bf1101053ff5d75a306a02a713f100259de241 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -559,7 +559,7 @@ static ssize_t h3_headers_to_htx(struct qcs *qcs, const struct buffer *buf,
                goto out;
        }
 
-       if (!qcs_get_buf(qcs, &htx_buf)) {
+       if (!b_alloc(&htx_buf)) {
                TRACE_ERROR("HTX buffer alloc failure", H3_EV_RX_FRAME|H3_EV_RX_HDR, qcs->qcc->conn, qcs);
                h3c->err = H3_INTERNAL_ERROR;
                len = -1;
@@ -938,7 +938,7 @@ static ssize_t h3_trailers_to_htx(struct qcs *qcs, const struct buffer *buf,
                goto out;
        }
 
-       if (!(appbuf = qcs_get_buf(qcs, &qcs->rx.app_buf))) {
+       if (!(appbuf = qcc_get_stream_rxbuf(qcs))) {
                TRACE_ERROR("HTX buffer alloc failure", H3_EV_RX_FRAME|H3_EV_RX_HDR, qcs->qcc->conn, qcs);
                h3c->err = H3_INTERNAL_ERROR;
                len = -1;
@@ -1070,7 +1070,7 @@ static ssize_t h3_data_to_htx(struct qcs *qcs, const struct buffer *buf,
 
        TRACE_ENTER(H3_EV_RX_FRAME|H3_EV_RX_DATA, qcs->qcc->conn, qcs);
 
-       if (!(appbuf = qcs_get_buf(qcs, &qcs->rx.app_buf))) {
+       if (!(appbuf = qcc_get_stream_rxbuf(qcs))) {
                TRACE_ERROR("data buffer alloc failure", H3_EV_RX_FRAME|H3_EV_RX_DATA, qcs->qcc->conn, qcs);
                h3c->err = H3_INTERNAL_ERROR;
                len = -1;
@@ -1261,7 +1261,7 @@ static ssize_t h3_decode_qcs(struct qcs *qcs, struct buffer *b, int fin)
                struct htx *htx;
 
                TRACE_PROTO("received FIN without data", H3_EV_RX_FRAME, qcs->qcc->conn, qcs);
-               if (!(appbuf = qcs_get_buf(qcs, &qcs->rx.app_buf))) {
+               if (!(appbuf = qcc_get_stream_rxbuf(qcs))) {
                        TRACE_ERROR("data buffer alloc failure", H3_EV_RX_FRAME, qcs->qcc->conn, qcs);
                        h3c->err = H3_INTERNAL_ERROR;
                        goto err;
index 2122509a6c8da5a52652671f437ef6965b2926a3..4fbef0d9df78723d085167468c13c0bc4cc30211 100644 (file)
@@ -423,15 +423,6 @@ int qcs_is_close_remote(struct qcs *qcs)
        return qcs->st == QC_SS_HREM || qcs->st == QC_SS_CLO;
 }
 
-/* Allocate if needed buffer <bptr> for stream <qcs>.
- *
- * Returns the buffer instance or NULL on allocation failure.
- */
-struct buffer *qcs_get_buf(struct qcs *qcs, struct buffer *bptr)
-{
-       return b_alloc(bptr);
-}
-
 /* Allocate if needed buffer <ncbuf> for stream <qcs>.
  *
  * Returns the buffer instance or NULL on allocation failure.
@@ -914,6 +905,15 @@ static int qcc_decode_qcs(struct qcc *qcc, struct qcs *qcs)
        return 1;
 }
 
+/* Allocate if needed and retrieve <qcs> stream buffer for data reception.
+ *
+ * Returns buffer pointer. May be NULL on allocation failure.
+ */
+struct buffer *qcc_get_stream_rxbuf(struct qcs *qcs)
+{
+       return b_alloc(&qcs->rx.app_buf);
+}
+
 /* Prepare for the emission of RESET_STREAM on <qcs> with error code <err>. */
 void qcc_reset_stream(struct qcs *qcs, int err)
 {
@@ -1510,7 +1510,7 @@ static int qcs_xfer_data(struct qcs *qcs, struct buffer *out, struct buffer *in)
 
        TRACE_ENTER(QMUX_EV_QCS_SEND, qcc->conn, qcs);
 
-       if (!qcs_get_buf(qcs, out)) {
+       if (!b_alloc(out)) {
                TRACE_ERROR("buffer alloc failure", QMUX_EV_QCS_SEND, qcc->conn, qcs);
                goto err;
        }