From b917191817616f56509a1dde65cc9df0812698bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20L=C3=A9caille?= Date: Thu, 21 Apr 2022 17:32:10 +0200 Subject: [PATCH] MINOR: quic: Prepare quic_frame struct duplication 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 | 8 ++++++++ src/mux_quic.c | 2 ++ src/xprt_quic.c | 9 +++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/haproxy/quic_frame-t.h b/include/haproxy/quic_frame-t.h index 12e3cd04c..ebd416bfc 100644 --- a/include/haproxy/quic_frame-t.h +++ b/include/haproxy/quic_frame-t.h @@ -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 */ diff --git a/src/mux_quic.c b/src/mux_quic.c index 5c5ba2cb9..edf2be845 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -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; diff --git a/src/xprt_quic.c b/src/xprt_quic.c index 05ca936df..1ccabd941 100644 --- a/src/xprt_quic.c +++ b/src/xprt_quic.c @@ -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;