From: Amaury Denoyelle Date: Fri, 25 Oct 2024 14:31:26 +0000 (+0200) Subject: MINOR: quic: extend qc_send_mux() return type with a dedicated enum X-Git-Tag: v3.1-dev14~89 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7fd48a572386d55b1913ca9c8da91b8f8bcc8205;p=thirdparty%2Fhaproxy.git MINOR: quic: extend qc_send_mux() return type with a dedicated enum This commit is part of a adjustment on QUIC transport send API to support pacing. Here, qc_send_mux() return type has been changed to use a new enum quic_tx_err. This is useful to explain different failure causes of emission. For now, only two values have been defined : NONE and FATAL. When pacing will be implemented, a new value would be added to specify that emission was interrupted on pacing. This won't be a fatal error as this allows to retry emission but not immediately. --- diff --git a/include/haproxy/quic_tx-t.h b/include/haproxy/quic_tx-t.h index efbdfe6870..359869a314 100644 --- a/include/haproxy/quic_tx-t.h +++ b/include/haproxy/quic_tx-t.h @@ -64,4 +64,9 @@ enum qc_build_pkt_err { QC_BUILD_PKT_ERR_BUFROOM, /* no more room in input buf or congestion window */ }; +enum quic_tx_err { + QUIC_TX_ERR_NONE, + QUIC_TX_ERR_FATAL, +}; + #endif /* _HAPROXY_TX_T_H */ diff --git a/include/haproxy/quic_tx.h b/include/haproxy/quic_tx.h index b77d6a20a5..21f7eecf3a 100644 --- a/include/haproxy/quic_tx.h +++ b/include/haproxy/quic_tx.h @@ -33,7 +33,7 @@ void qc_txb_release(struct quic_conn *qc); int qc_purge_txbuf(struct quic_conn *qc, struct buffer *buf); struct buffer *qc_get_txb(struct quic_conn *qc); -int qc_send_mux(struct quic_conn *qc, struct list *frms); +enum quic_tx_err qc_send_mux(struct quic_conn *qc, struct list *frms); void qel_register_send(struct list *send_list, struct quic_enc_level *qel, struct list *frms); diff --git a/src/mux_quic.c b/src/mux_quic.c index 80f4eff2d0..ffd53b9c54 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -2074,6 +2074,8 @@ static int qcc_subscribe_send(struct qcc *qcc) */ static int qcc_send_frames(struct qcc *qcc, struct list *frms) { + enum quic_tx_err ret; + TRACE_ENTER(QMUX_EV_QCC_SEND, qcc->conn); if (LIST_ISEMPTY(frms)) { @@ -2081,7 +2083,8 @@ static int qcc_send_frames(struct qcc *qcc, struct list *frms) return 1; } - if (!qc_send_mux(qcc->conn->handle.qc, frms)) { + ret = qc_send_mux(qcc->conn->handle.qc, frms); + if (ret == QUIC_TX_ERR_FATAL) { TRACE_DEVEL("error on sending", QMUX_EV_QCC_SEND, qcc->conn); qcc_subscribe_send(qcc); goto err; diff --git a/src/quic_tx.c b/src/quic_tx.c index 6431b3dfa8..a99b2c4b49 100644 --- a/src/quic_tx.c +++ b/src/quic_tx.c @@ -469,10 +469,11 @@ int qc_purge_txbuf(struct quic_conn *qc, struct buffer *buf) * * Returns the result from qc_send() function. */ -int qc_send_mux(struct quic_conn *qc, struct list *frms) +enum quic_tx_err qc_send_mux(struct quic_conn *qc, struct list *frms) { struct list send_list = LIST_HEAD_INIT(send_list); - int ret; + enum quic_tx_err ret = QUIC_TX_ERR_NONE; + int sent; TRACE_ENTER(QUIC_EV_CONN_TXPKT, qc); BUG_ON(qc->mux_state != QC_MUX_READY); /* Only MUX can uses this function so it must be ready. */ @@ -480,7 +481,7 @@ int qc_send_mux(struct quic_conn *qc, struct list *frms) if (qc->conn->flags & CO_FL_SOCK_WR_SH) { qc->conn->flags |= CO_FL_ERROR | CO_FL_SOCK_RD_SH; TRACE_DEVEL("connection on error", QUIC_EV_CONN_TXPKT, qc); - return 0; + return QUIC_TX_ERR_FATAL; } /* Try to send post handshake frames first unless on 0-RTT. */ @@ -493,7 +494,9 @@ int qc_send_mux(struct quic_conn *qc, struct list *frms) TRACE_STATE("preparing data (from MUX)", QUIC_EV_CONN_TXPKT, qc); qel_register_send(&send_list, qc->ael, frms); - ret = qc_send(qc, 0, &send_list, 0); + sent = qc_send(qc, 0, &send_list, 0); + if (sent <= 0) + ret = QUIC_TX_ERR_FATAL; TRACE_LEAVE(QUIC_EV_CONN_TXPKT, qc); return ret;