From: Frederic Lecaille Date: Wed, 4 Nov 2026 16:42:51 +0000 (+0100) Subject: CLEANUP: quic: use QUIC_PACKET_PN_MAXLEN instead of the magic 4 X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=5ae48ca2e18468be731a516f4e97c76dcf1e10e6;p=haproxy.git CLEANUP: quic: use QUIC_PACKET_PN_MAXLEN instead of the magic 4 Both fast retransmission functions account for the packet number increase when comparing the size of the packets to be retransmitted with the anti-amplification limit. They use a plain 4 for this, while quic_conn-t.h defines QUIC_PACKET_PN_MAXLEN for this exact purpose, as already used in quic_tx.c for the header protection sample. Replace the magic value in qc_prep_fast_retrans() and qc_prep_hdshk_fast_retrans(). No functional change, no need to backport. --- diff --git a/src/quic_retransmit.c b/src/quic_retransmit.c index b95095279..7082984dd 100644 --- a/src/quic_retransmit.c +++ b/src/quic_retransmit.c @@ -180,7 +180,7 @@ void qc_prep_fast_retrans(struct quic_conn *qc, * packet size is the packet number. And the maximum increase is 4 bytes. */ if (!quic_peer_validated_addr(qc) && !qc_is_back(qc) && - pkt->len + 4 > quic_may_send_bytes(qc)) { + pkt->len + QUIC_PACKET_PN_MAXLEN > quic_may_send_bytes(qc)) { qc->flags |= QUIC_FL_CONN_ANTI_AMPLIFICATION_REACHED; TRACE_PROTO("anti-amplification limit would be reached", QUIC_EV_CONN_SPPKTS, qc, pkt); goto leave; @@ -244,11 +244,11 @@ void qc_prep_hdshk_fast_retrans(struct quic_conn *qc, * packet size is the packet number. And the maximum increase is 4 bytes. */ if (!quic_peer_validated_addr(qc) && !qc_is_back(qc)) { - size_t dglen = pkt->len + 4; + size_t dglen = pkt->len + QUIC_PACKET_PN_MAXLEN; size_t may_send; may_send = quic_may_send_bytes(qc); - dglen += pkt->next ? pkt->next->len + 4 : 0; + dglen += pkt->next ? pkt->next->len + QUIC_PACKET_PN_MAXLEN : 0; if (dglen > may_send) { qc->flags |= QUIC_FL_CONN_ANTI_AMPLIFICATION_REACHED; TRACE_PROTO("anti-amplification limit would be reached", QUIC_EV_CONN_SPPKTS, qc, pkt);