From 5ccd22def28963b6626accde588da39c8d05914c Mon Sep 17 00:00:00 2001 From: Frederic Lecaille Date: Wed, 27 Aug 2025 16:28:04 +0200 Subject: [PATCH] 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. (cherry picked from commit 31c17ad837195c70fb6d4e427845ded1c6acffaa) Signed-off-by: Christopher Faulet (cherry picked from commit 4a1a08be4f34feafb637115a1d8536ad70a2df33) [cf: Some changes were made inlined in quic_tx.c because some functions does not exist in 3.2 and lower] Signed-off-by: Christopher Faulet (cherry picked from commit 565d73a3b1d6fa562408392bb55340a5e7b8b967) Signed-off-by: Christopher Faulet --- include/haproxy/quic_frame-t.h | 1 - include/haproxy/quic_frame.h | 2 +- src/quic_frame.c | 9 ++++----- src/quic_rx.c | 14 +++++++------- src/quic_ssl.c | 2 +- src/quic_tx.c | 6 +++--- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/include/haproxy/quic_frame-t.h b/include/haproxy/quic_frame-t.h index 6efea0e..3e062ba 100644 --- a/include/haproxy/quic_frame-t.h +++ b/include/haproxy/quic_frame-t.h @@ -147,7 +147,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; diff --git a/include/haproxy/quic_frame.h b/include/haproxy/quic_frame.h index 90d6b21..88cd0ba 100644 --- a/include/haproxy/quic_frame.h +++ b/include/haproxy/quic_frame.h @@ -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: { diff --git a/src/quic_frame.c b/src/quic_frame.c index 6c45935..f08925f 100644 --- a/src/quic_frame.c +++ b/src/quic_frame.c @@ -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; @@ -1280,4 +1280,3 @@ void qc_release_frm(struct quic_conn *qc, struct quic_frame *frm) TRACE_LEAVE(QUIC_EV_CONN_PRSAFRM, qc); } - diff --git a/src/quic_rx.c b/src/quic_rx.c index ccb970c..d97f1c9 100644 --- a/src/quic_rx.c +++ b/src/quic_rx.c @@ -675,7 +675,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: 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; @@ -684,10 +684,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); @@ -698,10 +698,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)) { @@ -710,7 +710,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 * @@ -916,7 +916,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; diff --git a/src/quic_ssl.c b/src/quic_ssl.c index a6a54a9..f48c85c 100644 --- a/src/quic_ssl.c +++ b/src/quic_ssl.c @@ -141,7 +141,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); diff --git a/src/quic_tx.c b/src/quic_tx.c index 65aff5d..b347b4b 100644 --- a/src/quic_tx.c +++ b/src/quic_tx.c @@ -1444,7 +1444,7 @@ static int qc_build_frms(struct list *outlist, struct list *inlist, TRACE_DEVEL(" New CRYPTO frame build (room, len)", QUIC_EV_CONN_BCFRMS, qc, &room, len); /* Compute the length of this CRYPTO frame header */ - hlen = 1 + quic_int_getsize(cf->crypto.offset); + hlen = 1 + quic_int_getsize(cf->crypto.offset_node.key); /* Compute the data length of this CRYPTO frame. */ dlen = max_stream_data_size(room, hlen, cf->crypto.len); TRACE_DEVEL(" CRYPTO data length (hlen, crypto.len, dlen)", @@ -1476,7 +1476,7 @@ static int qc_build_frms(struct list *outlist, struct list *inlist, } new_cf->crypto.len = dlen; - new_cf->crypto.offset = cf->crypto.offset; + new_cf->crypto.offset_node.key = cf->crypto.offset_node.key; new_cf->crypto.qel = qel; TRACE_DEVEL("split frame", QUIC_EV_CONN_PRSAFRM, qc, new_cf); if (cf->origin) { @@ -1491,7 +1491,7 @@ static int qc_build_frms(struct list *outlist, struct list *inlist, LIST_APPEND(outlist, &new_cf->list); /* Consume bytes of the current frame. */ cf->crypto.len -= dlen; - cf->crypto.offset += dlen; + cf->crypto.offset_node.key += dlen; } break; -- 1.7.10.4