From dcc74ff792b1ce0b764722894b83da9392324ff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20L=C3=A9caille?= Date: Fri, 18 Mar 2022 17:49:29 +0100 Subject: [PATCH] BUG/MINOR: quic: Unsent frame because of qc_build_frms() There are non already identified rare cases where qc_build_frms() does not manage to size frames to be encoded in a packet leading qc_build_frm() to fail to add such frame to the packet to be built. In such cases we must move back such frames to their origin frame list passed as parameter to qc_build_frms(): . because they were added to the packet frame list (but not built). If this this packet is not retransmitted, the frame is lost for ever! Furthermore we must not modify the buffer. --- src/xprt_quic.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/xprt_quic.c b/src/xprt_quic.c index 114fc569b..b50af85b3 100644 --- a/src/xprt_quic.c +++ b/src/xprt_quic.c @@ -5231,12 +5231,23 @@ static int qc_do_build_pkt(unsigned char *pos, const unsigned char *end, /* Ack-eliciting frames */ if (!LIST_ISEMPTY(&frm_list)) { list_for_each_entry(cf, &frm_list, list) { - if (!qc_build_frm(&pos, end, cf, pkt, qc)) { + unsigned char *spos = pos; + + if (!qc_build_frm(&spos, end, cf, pkt, qc)) { ssize_t room = end - pos; TRACE_PROTO("Not enough room", QUIC_EV_CONN_HPKT, qc, NULL, NULL, &room); + /* TODO: this should not have happened if qc_build_frms() + * had correctly computed and sized the frames to be + * added to this packet. Note that was added + * from to list by qc_build_frms(). + */ + LIST_DELETE(&cf->list); + LIST_INSERT(frms, &cf->list); break; } + + pos = spos; quic_tx_packet_refinc(pkt); cf->pkt = pkt; }