]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: quic: fix computed length of emitted STREAM frames
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 5 Jun 2024 09:37:44 +0000 (11:37 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 10 Jun 2024 08:24:02 +0000 (10:24 +0200)
qc_build_frms() is responsible to encode multiple frames in a single
QUIC packet. It accounts for room left in the buffer packet for each
newly encded frame.

An incorrect computation was performed when encoding a STREAM frame in a
single packet. Frame length was accounted twice which would reduce in
excess the buffer packet room. This caused the remaining built frames to
be reduced with the resulting packet not able to fill the whole MTU.

The impact of this bug should be minimal. It is only present when
multiple frames are encoded in a single packet after a STREAM. However
in this case datagrams built are smaller than expecting, which is
suboptimal for bandwith.

This should be backported up to 2.6.

src/quic_tx.c

index 6d487ebd07d23daa559ef0973f7799dd36b046dd..3b710ecb32322e1a230b3827b6872abf87a78141 100644 (file)
@@ -1425,6 +1425,7 @@ static int qc_build_frms(struct list *outlist, struct list *inlist,
        ret = 0;
        if (*len > room)
                goto leave;
+       room -= *len;
 
        /* If we are not probing we must take into an account the congestion
         * control window.
@@ -1458,8 +1459,8 @@ static int qc_build_frms(struct list *outlist, struct list *inlist,
                                    QUIC_EV_CONN_BCFRMS, qc, &room, len);
                        /* Compute the length of this CRYPTO frame header */
                        hlen = 1 + quic_int_getsize(cf->crypto.offset);
-                       /* Compute the data length of this CRyPTO frame. */
-                       dlen = max_stream_data_size(room, *len + hlen, cf->crypto.len);
+                       /* Compute the data length of this CRYPTO frame. */
+                       dlen = max_stream_data_size(room, hlen, cf->crypto.len);
                        TRACE_DEVEL(" CRYPTO data length (hlen, crypto.len, dlen)",
                                    QUIC_EV_CONN_BCFRMS, qc, &hlen, &cf->crypto.len, &dlen);
                        if (!dlen)
@@ -1550,7 +1551,7 @@ static int qc_build_frms(struct list *outlist, struct list *inlist,
                        hlen = 1 + quic_int_getsize(cf->stream.id) +
                                ((cf->type & QUIC_STREAM_FRAME_TYPE_OFF_BIT) ? quic_int_getsize(cf->stream.offset.key) : 0);
                        /* Compute the data length of this STREAM frame. */
-                       avail_room = room - hlen - *len;
+                       avail_room = room - hlen;
                        if ((ssize_t)avail_room <= 0)
                                continue;