]> git.kaiwu.me - haproxy.git/commitdiff
CLEANUP: quic: compute the STREAM frame end offset once in qc_stream_frm_is_acked()
authorFrederic Lecaille <flecaille@haproxy.com>
Wed, 4 Nov 2026 16:05:24 +0000 (17:05 +0100)
committerFrederic Lecaille <flecaille@haproxy.com>
Thu, 5 Nov 2026 08:58:36 +0000 (09:58 +0100)
The end offset of a STREAM frame, frm->offset + frm->len, was recomputed
four times in qc_stream_frm_is_acked(): once in the BUG_ON() and three
times in the offset comparisons. Store it in a local frm_end variable, as
already done for the FIN bit flag.

No functional change, no need to backport.

src/quic_retransmit.c

index f4d12e180af05debe740ff5e291d7caed3401543..891532240bd46df8d4d0c3ae87535b4ec3085573 100644 (file)
@@ -21,6 +21,7 @@ int qc_stream_frm_is_acked(struct quic_conn *qc, struct quic_frame *f)
 {
        const struct qf_stream *frm = &f->stream;
        const struct qc_stream_desc *s = frm->stream;
+       const uint64_t frm_end = frm->offset + frm->len;
        const int frm_fin = f->type & QUIC_STREAM_FRAME_TYPE_FIN_BIT;
 
        if (!eb64_lookup(&qc->streams_by_id, frm->id)) {
@@ -29,17 +30,17 @@ int qc_stream_frm_is_acked(struct quic_conn *qc, struct quic_frame *f)
        }
 
        /* Frame cannot advertise FIN for a smaller data range. */
-       BUG_ON(frm_fin && frm->offset + frm->len < s->ack_offset);
+       BUG_ON(frm_fin && frm_end < s->ack_offset);
 
-       if (frm->offset + frm->len < s->ack_offset ||
-           (frm->offset + frm->len == s->ack_offset &&
+       if (frm_end < s->ack_offset ||
+           (frm_end == s->ack_offset &&
             (!frm_fin || !(s->flags & QC_SD_FL_WAIT_FOR_FIN)))) {
                TRACE_DEVEL("STREAM frame already acked : fully acked range", QUIC_EV_CONN_PRSAFRM, qc, f);
                return 1;
        }
 
        if (frm->offset < s->ack_offset &&
-           frm->offset + frm->len > s->ack_offset) {
+           frm_end > s->ack_offset) {
                /* Data range partially acked, remove it from STREAM frame. */
                const uint64_t diff = s->ack_offset - frm->offset;
                TRACE_DEVEL("updated partially acked frame", QUIC_EV_CONN_PRSAFRM, qc, f);