MINOR: quic: remove ->offset qf_crypto struct field

This patch follows this previous bug fix:

    BUG/MINOR: quic: reorder fragmented RX CRYPTO frames by their offsets

where a ebtree node has been added to qf_crypto struct. It has the same
meaning and type as ->offset_node.key field with ->offset_node an eb64tree node.
This patch simply removes ->offset which is no more useful.

This patch should be easily backported as far as 2.6 as the one mentioned above
to ease any further backport to come.
This commit is contained in:
Frederic Lecaille 2025-08-27 16:28:04 +02:00
parent 2ed515c632
commit 31c17ad837
5 changed files with 16 additions and 17 deletions

View File

@ -153,7 +153,6 @@ struct qf_stop_sending {
struct qf_crypto {
struct list list;
uint64_t offset;
struct eb64_node offset_node;
uint64_t len;
const struct quic_enc_level *qel;

View File

@ -86,7 +86,7 @@ static inline size_t qc_frm_len(struct quic_frame *frm)
}
case QUIC_FT_CRYPTO: {
struct qf_crypto *f = &frm->crypto;
len += 1 + quic_int_getsize(f->offset) + quic_int_getsize(f->len) + f->len;
len += 1 + quic_int_getsize(f->offset_node.key) + quic_int_getsize(f->len) + f->len;
break;
}
case QUIC_FT_NEW_TOKEN: {

View File

@ -115,7 +115,7 @@ void chunk_frm_appendf(struct buffer *buf, const struct quic_frame *frm)
{
const struct qf_crypto *crypto_frm = &frm->crypto;
chunk_appendf(buf, " cfoff=%llu cflen=%llu",
(ull)crypto_frm->offset, (ull)crypto_frm->len);
(ull)crypto_frm->offset_node.key, (ull)crypto_frm->len);
break;
}
case QUIC_FT_RESET_STREAM:
@ -430,12 +430,12 @@ static int quic_build_crypto_frame(unsigned char **pos, const unsigned char *end
const struct quic_enc_level *qel = crypto_frm->qel;
size_t offset, len;
if (!quic_enc_int(pos, end, crypto_frm->offset) ||
if (!quic_enc_int(pos, end, crypto_frm->offset_node.key) ||
!quic_enc_int(pos, end, crypto_frm->len) || end - *pos < crypto_frm->len)
return 0;
len = crypto_frm->len;
offset = crypto_frm->offset;
offset = crypto_frm->offset_node.key;
while (len) {
int idx;
size_t to_copy;
@ -463,7 +463,7 @@ static int quic_parse_crypto_frame(struct quic_frame *frm, struct quic_conn *qc,
{
struct qf_crypto *crypto_frm = &frm->crypto;
if (!quic_dec_int(&crypto_frm->offset, pos, end) ||
if (!quic_dec_int((uint64_t *)&crypto_frm->offset_node.key, pos, end) ||
!quic_dec_int(&crypto_frm->len, pos, end) || end - *pos < crypto_frm->len)
return 0;
@ -1363,7 +1363,7 @@ size_t quic_strm_frm_fillbuf(size_t room, struct quic_frame *frm, size_t *split)
}
else if (frm->type == QUIC_FT_CRYPTO) {
total = 1;
total += quic_int_getsize(frm->crypto.offset);
total += quic_int_getsize(frm->crypto.offset_node.key);
payload = frm->crypto.len;
}
else {
@ -1438,12 +1438,12 @@ struct quic_frame *quic_strm_frm_split(struct quic_frame *frm, uint64_t split)
}
else if (frm->type == QUIC_FT_CRYPTO) {
new->crypto.qel = frm->crypto.qel;
new->crypto.offset = frm->crypto.offset;
new->crypto.offset_node.key = frm->crypto.offset_node.key;
new->crypto.len = split;
/* Advance original frame to point to the remaining data. */
frm->crypto.len -= split;
frm->crypto.offset += split;
frm->crypto.offset_node.key += split;
}
else {
/* Function must only be used with STREAM or CRYPTO frames. */

View File

@ -662,7 +662,7 @@ static enum quic_rx_ret_frm qc_handle_crypto_frm(struct quic_conn *qc,
enum quic_rx_ret_frm ret = QUIC_RX_RET_FRM_DONE;
/* XXX TO DO: <cfdebug> is used only for the traces. */
struct quic_rx_crypto_frm cfdebug = {
.offset_node.key = crypto_frm->offset,
.offset_node.key = crypto_frm->offset_node.key,
.len = crypto_frm->len,
};
struct quic_cstream *cstream = qel->cstream;
@ -671,10 +671,10 @@ static enum quic_rx_ret_frm qc_handle_crypto_frm(struct quic_conn *qc,
TRACE_ENTER(QUIC_EV_CONN_PRSHPKT, qc);
if (unlikely(crypto_frm->offset < cstream->rx.offset)) {
if (unlikely(crypto_frm->offset_node.key < cstream->rx.offset)) {
size_t diff;
if (crypto_frm->offset + crypto_frm->len <= cstream->rx.offset) {
if (crypto_frm->offset_node.key + crypto_frm->len <= cstream->rx.offset) {
/* Nothing to do */
TRACE_PROTO("Already received CRYPTO data",
QUIC_EV_CONN_RXPKT, qc, pkt, &cfdebug);
@ -685,10 +685,10 @@ static enum quic_rx_ret_frm qc_handle_crypto_frm(struct quic_conn *qc,
TRACE_PROTO("Partially already received CRYPTO data",
QUIC_EV_CONN_RXPKT, qc, pkt, &cfdebug);
diff = cstream->rx.offset - crypto_frm->offset;
diff = cstream->rx.offset - crypto_frm->offset_node.key;
crypto_frm->len -= diff;
crypto_frm->data += diff;
crypto_frm->offset = cstream->rx.offset;
crypto_frm->offset_node.key = cstream->rx.offset;
}
if (!quic_get_ncbuf(ncbuf) || ncb_is_null(ncbuf)) {
@ -697,7 +697,7 @@ static enum quic_rx_ret_frm qc_handle_crypto_frm(struct quic_conn *qc,
}
/* crypto_frm->offset > cstream-trx.offset */
off_rel = crypto_frm->offset - cstream->rx.offset;
off_rel = crypto_frm->offset_node.key - cstream->rx.offset;
/* RFC 9000 7.5. Cryptographic Message Buffering
*
@ -903,7 +903,7 @@ static int qc_parse_pkt_frms(struct quic_conn *qc, struct quic_rx_packet *pkt,
break;
}
case QUIC_FT_CRYPTO:
frm->crypto.offset_node.key = frm->crypto.offset;
frm->crypto.offset_node.key = frm->crypto.offset_node.key;
eb64_insert(&cf_frms_tree, &frm->crypto.offset_node);
frm = NULL;
break;

View File

@ -149,7 +149,7 @@ static int qc_ssl_crypto_data_cpy(struct quic_conn *qc, struct quic_enc_level *q
goto leave;
}
frm->crypto.offset = cf_offset;
frm->crypto.offset_node.key = cf_offset;
frm->crypto.len = cf_len;
frm->crypto.qel = qel;
LIST_APPEND(&qel->pktns->tx.frms, &frm->list);