]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Prepare quic_frame struct duplication
authorFrédéric Lécaille <flecaille@haproxy.com>
Thu, 21 Apr 2022 15:32:10 +0000 (17:32 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 28 Apr 2022 14:22:40 +0000 (16:22 +0200)
We want to track the frames which have been duplicated during retransmissions so
that to avoid uselessly retransmitting frames which would already have been
acknowledged. ->origin new member is there to store the frame from which a copy
was done, ->reflist is a list to store the frames which are copies.
Also ensure all the frames are zeroed and that their ->reflist list member is
initialized.
Add QUIC_FL_TX_FRAME_ACKED flag definition to mark a TX frame as acknowledged.

include/haproxy/quic_frame-t.h
src/mux_quic.c
src/xprt_quic.c

index 12e3cd04c37924aa40b2a085113281908068afb9..ebd416bfc79915eee43d7316a8c3e4eb5681d3cb 100644 (file)
@@ -93,6 +93,10 @@ enum quic_frame_type {
 
 #define QUIC_FT_PKT_TYPE____1_BITMASK QUIC_FT_PKT_TYPE_1_BITMASK
 
+
+/* Flag a TX frame as acknowledged */
+#define QUIC_FL_TX_FRAME_ACKED             0x01
+
 #define QUIC_STREAM_FRAME_TYPE_FIN_BIT     0x01
 #define QUIC_STREAM_FRAME_TYPE_LEN_BIT     0x02
 #define QUIC_STREAM_FRAME_TYPE_OFF_BIT     0x04
@@ -258,6 +262,10 @@ struct quic_frame {
                struct quic_connection_close connection_close;
                struct quic_connection_close_app connection_close_app;
        };
+       struct quic_frame *origin;
+       struct list reflist;
+       struct list ref;
+       unsigned int flags;
 };
 
 #endif /* USE_QUIC */
index 5c5ba2cb9f8621f4afa1becdf2133858324523a2..edf2be845bb8d38c4fd2971cee4d9a56180a9342 100644 (file)
@@ -677,6 +677,7 @@ static int qcs_build_stream_frm(struct qcs *qcs, struct buffer *out, char fin,
        if (!frm)
                goto err;
 
+       LIST_INIT(&frm->reflist);
        frm->type = QUIC_FT_STREAM_8;
        frm->stream.stream = qcs->stream;
        frm->stream.id = qcs->id;
@@ -845,6 +846,7 @@ static int qc_send_max_streams(struct qcc *qcc)
        frm = pool_zalloc(pool_head_quic_frame);
        BUG_ON(!frm); /* TODO handle this properly */
 
+       LIST_INIT(&frm->reflist);
        frm->type = QUIC_FT_MAX_STREAMS_BIDI;
        frm->max_streams_bidi.max_streams = qcc->lfctl.ms_bidi +
                                            qcc->lfctl.cl_bidi_r;
index 05ca936df2c840862302176db6a016ce704b785f..1ccabd941be961063a1248a5d7cce4c93207a735 100644 (file)
@@ -1079,10 +1079,11 @@ static int quic_crypto_data_cpy(struct quic_enc_level *qel,
                        found->crypto.len += cf_len;
                }
                else {
-                       frm = pool_alloc(pool_head_quic_frame);
+                       frm = pool_zalloc(pool_head_quic_frame);
                        if (!frm)
                                return 0;
 
+                       LIST_INIT(&frm->reflist);
                        frm->type = QUIC_FT_CRYPTO;
                        frm->crypto.offset = cf_offset;
                        frm->crypto.len = cf_len;
@@ -3141,6 +3142,7 @@ static int quic_build_post_handshake_frames(struct quic_conn *qc)
                if (!frm)
                        return 0;
 
+               LIST_INIT(&frm->reflist);
                frm->type = QUIC_FT_HANDSHAKE_DONE;
                LIST_APPEND(&frm_list, &frm->list);
        }
@@ -3154,6 +3156,7 @@ static int quic_build_post_handshake_frames(struct quic_conn *qc)
                if (!frm)
                        goto err;
 
+               LIST_INIT(&frm->reflist);
                cid = new_quic_cid(&qc->cids, qc, i);
                if (!cid)
                        goto err;
@@ -5220,12 +5223,13 @@ static inline int qc_build_frms(struct list *outlist, struct list *inlist,
                        else {
                                struct quic_frame *new_cf;
 
-                               new_cf = pool_alloc(pool_head_quic_frame);
+                               new_cf = pool_zalloc(pool_head_quic_frame);
                                if (!new_cf) {
                                        TRACE_PROTO("No memory for new crypto frame", QUIC_EV_CONN_BCFRMS, qc);
                                        return 0;
                                }
 
+                               LIST_INIT(&new_cf->reflist);
                                new_cf->type = QUIC_FT_CRYPTO;
                                new_cf->crypto.len = dlen;
                                new_cf->crypto.offset = cf->crypto.offset;
@@ -5301,6 +5305,7 @@ static inline int qc_build_frms(struct list *outlist, struct list *inlist,
                                        return 0;
                                }
 
+                               LIST_INIT(&new_cf->reflist);
                                new_cf->type = cf->type;
                                new_cf->stream.stream = cf->stream.stream;
                                new_cf->stream.buf = cf->stream.buf;