From: Amaury Denoyelle Date: Wed, 18 May 2022 09:38:22 +0000 (+0200) Subject: MINOR: mux-quic: remove qcc_decode_qcs() call in XPRT X-Git-Tag: v2.6-dev11~57 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3a0864067a72ebb6a1180c78b8b32869e74b9390;p=thirdparty%2Fhaproxy.git MINOR: mux-quic: remove qcc_decode_qcs() call in XPRT 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. --- diff --git a/include/haproxy/mux_quic.h b/include/haproxy/mux_quic.h index dc14277ce7..55c6b00663 100644 --- a/include/haproxy/mux_quic.h +++ b/include/haproxy/mux_quic.h @@ -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 diff --git a/src/mux_quic.c b/src/mux_quic.c index bd671af9de..1f15fa76ae 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -364,23 +364,41 @@ struct qcs *qcc_get_qcs(struct qcc *qcc, uint64_t id) return NULL; } -/* Handle a new STREAM frame . The frame content will be copied in - * the buffer of the stream instance. The stream instance will be stored in - * . 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 + * . + * + * 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 . Payload is pointed by + * with length and represents the offset . 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 - * . - * - * 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; diff --git a/src/xprt_quic.c b/src/xprt_quic.c index ed6321865e..de01f93cb3 100644 --- a/src/xprt_quic.c +++ b/src/xprt_quic.c @@ -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; }