From 6edc24a81f9347d49f674c9fdd6641e922b85132 Mon Sep 17 00:00:00 2001 From: Frederic Lecaille Date: Wed, 25 Jun 2025 10:15:50 +0200 Subject: [PATCH] MINOR: quic: Useless TX buffer size reduction in closing state There is no need to limit the size of the TX buffer to QUIC_MIN_CC_PKTSIZE bytes when the connection is in closing state. There is already a test which limits the number of bytes to be used from this TX buffer after this useless test removed. It limits this number of bytes to the size of the TX buffer itself: if (end > (unsigned char *)b_wrap(buf)) end = (unsigned char *)b_wrap(buf); This is exactly what is needed when the connection is in closing state. Indeed, the size of the TX buffers are limited to reduce the memory usage. The connection only needs to send short datagrams with at most 2 packets with a CONNECTION_CLOSE* frames. They are built only one time and backed up into small TX buffer allocated from a dedicated pool. The size of this TX buffer is QUIC_MAX_CC_BUFSIZE which depends on QUIC_MIN_CC_PKTSIZE: #define QUIC_MIN_CC_PKTSIZE 128 #define QUIC_MAX_CC_BUFSIZE (2 * (QUIC_MIN_CC_PKTSIZE + QUIC_DGRAM_HEADLEN)) This size is smaller than an MTU. This patch should be backported as far as 2.9 to ease further backports to come. (cherry picked from commit c898b29e6486ec17442555b2df4929c77684298f) Signed-off-by: Willy Tarreau (cherry picked from commit 1699cc9df385cbb3abe23547553fee2b47da490f) Signed-off-by: Christopher Faulet (cherry picked from commit 9fe465256cbcaed3fc41c30c6b2b9df93376d639) Signed-off-by: Christopher Faulet --- src/quic_tx.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/quic_tx.c b/src/quic_tx.c index ea96857..0c9106d 100644 --- a/src/quic_tx.c +++ b/src/quic_tx.c @@ -565,10 +565,7 @@ static int qc_prep_pkts(struct quic_conn *qc, struct buffer *buf, if (!prv_pkt) { /* Leave room for the datagram header */ pos += QUIC_DGRAM_HEADLEN; - if (cc) { - end = pos + QUIC_MIN_CC_PKTSIZE; - } - else if (!quic_peer_validated_addr(qc) && qc_is_listener(qc)) { + if (!quic_peer_validated_addr(qc) && qc_is_listener(qc)) { end = pos + QUIC_MIN(qc->path->mtu, quic_may_send_bytes(qc)); } else { -- 1.7.10.4