diff --git a/include/haproxy/quic_conn.h b/include/haproxy/quic_conn.h index a2292d008..6b2b70b22 100644 --- a/include/haproxy/quic_conn.h +++ b/include/haproxy/quic_conn.h @@ -487,6 +487,19 @@ static inline int64_t quic_pktns_get_largest_acked_pn(struct quic_pktns *pktns) return eb64_entry(ar, struct quic_arng_node, first)->last; } +/* The TX packets sent in the same datagram are linked to each others in + * the order they are built. This function detach a packet from its successor + * and predecessor in the same datagram. + */ +static inline void quic_tx_packet_dgram_detach(struct quic_tx_packet *pkt) +{ + if (pkt->prev) + pkt->prev->next = pkt->next; + if (pkt->next) + pkt->next->prev = pkt->prev; +} + + /* Increment the reference counter of */ static inline void quic_tx_packet_refinc(struct quic_tx_packet *pkt) { @@ -498,6 +511,10 @@ static inline void quic_tx_packet_refdec(struct quic_tx_packet *pkt) { if (!HA_ATOMIC_SUB_FETCH(&pkt->refcnt, 1)) { BUG_ON(!LIST_ISEMPTY(&pkt->frms)); + /* If there are others packet in the same datagram is attached to, + * detach the previous one and the next one from . + */ + quic_tx_packet_dgram_detach(pkt); pool_free(pool_head_quic_tx_packet, pkt); } } diff --git a/src/quic_conn.c b/src/quic_conn.c index 1d67248c6..dd748945f 100644 --- a/src/quic_conn.c +++ b/src/quic_conn.c @@ -1759,10 +1759,7 @@ static inline struct eb64_node *qc_ackrng_pkts(struct quic_conn *qc, /* If there are others packet in the same datagram is attached to, * detach the previous one and the next one from . */ - if (pkt->prev) - pkt->prev->next = pkt->next; - if (pkt->next) - pkt->next->prev = pkt->prev; + quic_tx_packet_dgram_detach(pkt); node = eb64_prev(node); eb64_delete(&pkt->pn_node); } @@ -3237,7 +3234,7 @@ static int qc_prep_pkts(struct quic_conn *qc, struct buffer *buf, /* keep trace of the first packet in the datagram */ if (!first_pkt) first_pkt = cur_pkt; - /* Attach the current one to the previous one */ + /* Attach the current one to the previous one and vice versa */ if (prv_pkt) { prv_pkt->next = cur_pkt; cur_pkt->prev = prv_pkt;