Skip to content

Commit 8728d68

Browse files
a-denoyellecapflam
authored andcommitted
BUG/MINOR: quic: fix computed length of emitted STREAM frames
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. (cherry picked from commit 50470a5) Signed-off-by: Christopher Faulet <[email protected]>
1 parent be979dd commit 8728d68

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/quic_tx.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,7 @@ static int qc_build_frms(struct list *outlist, struct list *inlist,
14251425
ret = 0;
14261426
if (*len > room)
14271427
goto leave;
1428+
room -= *len;
14281429

14291430
/* If we are not probing we must take into an account the congestion
14301431
* control window.
@@ -1458,8 +1459,8 @@ static int qc_build_frms(struct list *outlist, struct list *inlist,
14581459
QUIC_EV_CONN_BCFRMS, qc, &room, len);
14591460
/* Compute the length of this CRYPTO frame header */
14601461
hlen = 1 + quic_int_getsize(cf->crypto.offset);
1461-
/* Compute the data length of this CRyPTO frame. */
1462-
dlen = max_stream_data_size(room, *len + hlen, cf->crypto.len);
1462+
/* Compute the data length of this CRYPTO frame. */
1463+
dlen = max_stream_data_size(room, hlen, cf->crypto.len);
14631464
TRACE_DEVEL(" CRYPTO data length (hlen, crypto.len, dlen)",
14641465
QUIC_EV_CONN_BCFRMS, qc, &hlen, &cf->crypto.len, &dlen);
14651466
if (!dlen)
@@ -1550,7 +1551,7 @@ static int qc_build_frms(struct list *outlist, struct list *inlist,
15501551
hlen = 1 + quic_int_getsize(cf->stream.id) +
15511552
((cf->type & QUIC_STREAM_FRAME_TYPE_OFF_BIT) ? quic_int_getsize(cf->stream.offset.key) : 0);
15521553
/* Compute the data length of this STREAM frame. */
1553-
avail_room = room - hlen - *len;
1554+
avail_room = room - hlen;
15541555
if ((ssize_t)avail_room <= 0)
15551556
continue;
15561557

0 commit comments

Comments
 (0)