]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: quic: Missing STREAM frame data pointer updates
authorFrédéric Lécaille <flecaille@haproxy.com>
Fri, 17 Mar 2023 07:56:50 +0000 (08:56 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 17 Mar 2023 08:21:18 +0000 (09:21 +0100)
This patch follows this one which was not sufficient:
    "BUG/MINOR: quic: Missing STREAM frame length updates"
Indeed, it is not sufficient to update the ->len and ->offset member
of a STREAM frame to move it forward. The data pointer must also be updated.
This is not done by the STREAM frame builder.

Must be backported to 2.6 and 2.7.

include/haproxy/quic_frame.h
src/quic_conn.c

index ea33425ac816ccaabcf91e34811145b9a3c4a14e..f75d7e65fcb8c3dfc8fbafc38422f49824a887d7 100644 (file)
@@ -254,5 +254,18 @@ static inline void qc_frm_free(struct quic_frame **frm)
        *frm = NULL;
 }
 
+/* Move forward <strm> STREAM frame by <data> bytes. */
+static inline void qc_stream_frm_mv_fwd(struct quic_stream *strm, uint64_t data)
+{
+       struct buffer cf_buf;
+
+       strm->offset.key += data;
+       strm->len -= data;
+       cf_buf = b_make(b_orig(strm->buf),
+                       b_size(strm->buf),
+                       (char *)strm->data - b_orig(strm->buf), 0);
+       strm->data = (unsigned char *)b_peek(&cf_buf, data);
+}
+
 #endif /* USE_QUIC */
 #endif /* _HAPROXY_QUIC_FRAME_H */
index 6fd8412f2f0a7c65b5cd3f00852bb79bd24031f2..5fa2ce942db85f2259f8582ed217fce20a8c6acc 100644 (file)
@@ -1897,8 +1897,9 @@ static inline int qc_requeue_nacked_pkt_tx_frms(struct quic_conn *qc,
                                continue;
                        }
                        else if (strm_frm->offset.key < stream_desc->ack_offset) {
-                               strm_frm->offset.key = stream_desc->ack_offset;
-                               strm_frm->len -= stream_desc->ack_offset - strm_frm->offset.key;
+                               uint64_t diff = stream_desc->ack_offset - strm_frm->offset.key;
+
+                               qc_stream_frm_mv_fwd(strm_frm, diff);
                                TRACE_DEVEL("updated partially acked frame",
                                            QUIC_EV_CONN_PRSAFRM, qc, frm);
                        }
@@ -2553,8 +2554,9 @@ static void qc_dup_pkt_frms(struct quic_conn *qc,
                                continue;
                        }
                        else if (strm_frm->offset.key < stream_desc->ack_offset) {
-                               strm_frm->offset.key = stream_desc->ack_offset;
-                               strm_frm->len -= stream_desc->ack_offset - strm_frm->offset.key;
+                               uint64_t diff = stream_desc->ack_offset - strm_frm->offset.key;
+
+                               qc_stream_frm_mv_fwd(strm_frm, diff);
                                TRACE_DEVEL("updated partially acked frame",
                                            QUIC_EV_CONN_PRSAFRM, qc, frm);
                        }
@@ -7289,8 +7291,9 @@ static inline int qc_build_frms(struct list *outlist, struct list *inlist,
                                        continue;
                                }
                                else if (strm->offset.key < stream_desc->ack_offset) {
-                                       strm->offset.key = stream_desc->ack_offset;
-                                       strm->len -= stream_desc->ack_offset - strm->offset.key;
+                                       uint64_t diff = stream_desc->ack_offset - strm->offset.key;
+
+                                       qc_stream_frm_mv_fwd(strm, diff);
                                        TRACE_DEVEL("updated partially acked frame",
                                                    QUIC_EV_CONN_PRSAFRM, qc, cf);
                                }