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.
This commit is contained in:
Frédéric Lécaille 2022-04-21 17:32:10 +02:00 committed by Amaury Denoyelle
parent fc88844d2c
commit b917191817
3 changed files with 17 additions and 2 deletions

View File

@ -93,6 +93,10 @@ enum quic_frame_type {
#define QUIC_FT_PKT_TYPE____1_BITMASK QUIC_FT_PKT_TYPE_1_BITMASK #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_FIN_BIT 0x01
#define QUIC_STREAM_FRAME_TYPE_LEN_BIT 0x02 #define QUIC_STREAM_FRAME_TYPE_LEN_BIT 0x02
#define QUIC_STREAM_FRAME_TYPE_OFF_BIT 0x04 #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 connection_close;
struct quic_connection_close_app connection_close_app; struct quic_connection_close_app connection_close_app;
}; };
struct quic_frame *origin;
struct list reflist;
struct list ref;
unsigned int flags;
}; };
#endif /* USE_QUIC */ #endif /* USE_QUIC */

View File

@ -677,6 +677,7 @@ static int qcs_build_stream_frm(struct qcs *qcs, struct buffer *out, char fin,
if (!frm) if (!frm)
goto err; goto err;
LIST_INIT(&frm->reflist);
frm->type = QUIC_FT_STREAM_8; frm->type = QUIC_FT_STREAM_8;
frm->stream.stream = qcs->stream; frm->stream.stream = qcs->stream;
frm->stream.id = qcs->id; 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); frm = pool_zalloc(pool_head_quic_frame);
BUG_ON(!frm); /* TODO handle this properly */ BUG_ON(!frm); /* TODO handle this properly */
LIST_INIT(&frm->reflist);
frm->type = QUIC_FT_MAX_STREAMS_BIDI; frm->type = QUIC_FT_MAX_STREAMS_BIDI;
frm->max_streams_bidi.max_streams = qcc->lfctl.ms_bidi + frm->max_streams_bidi.max_streams = qcc->lfctl.ms_bidi +
qcc->lfctl.cl_bidi_r; qcc->lfctl.cl_bidi_r;

View File

@ -1079,10 +1079,11 @@ static int quic_crypto_data_cpy(struct quic_enc_level *qel,
found->crypto.len += cf_len; found->crypto.len += cf_len;
} }
else { else {
frm = pool_alloc(pool_head_quic_frame); frm = pool_zalloc(pool_head_quic_frame);
if (!frm) if (!frm)
return 0; return 0;
LIST_INIT(&frm->reflist);
frm->type = QUIC_FT_CRYPTO; frm->type = QUIC_FT_CRYPTO;
frm->crypto.offset = cf_offset; frm->crypto.offset = cf_offset;
frm->crypto.len = cf_len; frm->crypto.len = cf_len;
@ -3141,6 +3142,7 @@ static int quic_build_post_handshake_frames(struct quic_conn *qc)
if (!frm) if (!frm)
return 0; return 0;
LIST_INIT(&frm->reflist);
frm->type = QUIC_FT_HANDSHAKE_DONE; frm->type = QUIC_FT_HANDSHAKE_DONE;
LIST_APPEND(&frm_list, &frm->list); LIST_APPEND(&frm_list, &frm->list);
} }
@ -3154,6 +3156,7 @@ static int quic_build_post_handshake_frames(struct quic_conn *qc)
if (!frm) if (!frm)
goto err; goto err;
LIST_INIT(&frm->reflist);
cid = new_quic_cid(&qc->cids, qc, i); cid = new_quic_cid(&qc->cids, qc, i);
if (!cid) if (!cid)
goto err; goto err;
@ -5220,12 +5223,13 @@ static inline int qc_build_frms(struct list *outlist, struct list *inlist,
else { else {
struct quic_frame *new_cf; struct quic_frame *new_cf;
new_cf = pool_alloc(pool_head_quic_frame); new_cf = pool_zalloc(pool_head_quic_frame);
if (!new_cf) { if (!new_cf) {
TRACE_PROTO("No memory for new crypto frame", QUIC_EV_CONN_BCFRMS, qc); TRACE_PROTO("No memory for new crypto frame", QUIC_EV_CONN_BCFRMS, qc);
return 0; return 0;
} }
LIST_INIT(&new_cf->reflist);
new_cf->type = QUIC_FT_CRYPTO; new_cf->type = QUIC_FT_CRYPTO;
new_cf->crypto.len = dlen; new_cf->crypto.len = dlen;
new_cf->crypto.offset = cf->crypto.offset; 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; return 0;
} }
LIST_INIT(&new_cf->reflist);
new_cf->type = cf->type; new_cf->type = cf->type;
new_cf->stream.stream = cf->stream.stream; new_cf->stream.stream = cf->stream.stream;
new_cf->stream.buf = cf->stream.buf; new_cf->stream.buf = cf->stream.buf;