From: Amaury Denoyelle Date: Mon, 11 Dec 2023 14:34:42 +0000 (+0100) Subject: MINOR: mux-quic: clean up qcs Rx buffer allocation API X-Git-Tag: v3.0-dev1~107 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b526ffbfb94c8d447429ca18178b94f063a453db;p=thirdparty%2Fhaproxy.git MINOR: mux-quic: clean up qcs Rx buffer allocation API Replaces qcs_get_buf() function which naming does not reflect its purpose. Add a new function qcc_get_stream_rxbuf() which allocate if needed 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(). --- diff --git a/include/haproxy/mux_quic.h b/include/haproxy/mux_quic.h index 50baadae0c..ca5cd56e7f 100644 --- a/include/haproxy/mux_quic.h +++ b/include/haproxy/mux_quic.h @@ -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); diff --git a/src/h3.c b/src/h3.c index f535d85880..d7bf110105 100644 --- 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; diff --git a/src/mux_quic.c b/src/mux_quic.c index 2122509a6c..4fbef0d9df 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -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 for stream . - * - * 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 for stream . * * 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 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 with error code . */ 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; }