Skip to content

Commit 7228583

Browse files
committed
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.
1 parent 763d598 commit 7228583

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

include/haproxy/quic_frame-t.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ struct qf_stop_sending {
142142
};
143143

144144
struct qf_crypto {
145-
uint64_t offset;
146145
struct eb64_node offset_node;
147146
uint64_t len;
148147
const struct quic_enc_level *qel;

include/haproxy/quic_frame.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static inline size_t qc_frm_len(struct quic_frame *frm)
8383
}
8484
case QUIC_FT_CRYPTO: {
8585
struct qf_crypto *f = &frm->crypto;
86-
len += 1 + quic_int_getsize(f->offset) + quic_int_getsize(f->len) + f->len;
86+
len += 1 + quic_int_getsize(f->offset_node.key) + quic_int_getsize(f->len) + f->len;
8787
break;
8888
}
8989
case QUIC_FT_NEW_TOKEN: {

src/quic_conn.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ static int quic_crypto_data_cpy(struct quic_conn *qc, struct quic_enc_level *qel
13111311
goto leave;
13121312
}
13131313

1314-
frm->crypto.offset = cf_offset;
1314+
frm->crypto.offset_node.key = cf_offset;
13151315
frm->crypto.len = cf_len;
13161316
frm->crypto.qel = qel;
13171317
LIST_APPEND(&qel->pktns->tx.frms, &frm->list);
@@ -3023,7 +3023,7 @@ static enum quic_rx_ret_frm qc_handle_crypto_frm(struct quic_conn *qc,
30233023
enum quic_rx_ret_frm ret = QUIC_RX_RET_FRM_DONE;
30243024
/* XXX TO DO: <cfdebug> is used only for the traces. */
30253025
struct quic_rx_crypto_frm cfdebug = {
3026-
.offset_node.key = crypto_frm->offset,
3026+
.offset_node.key = crypto_frm->offset_node.key,
30273027
.len = crypto_frm->len,
30283028
};
30293029
struct quic_cstream *cstream = qel->cstream;
@@ -3037,10 +3037,10 @@ static enum quic_rx_ret_frm qc_handle_crypto_frm(struct quic_conn *qc,
30373037
goto done;
30383038
}
30393039

3040-
if (unlikely(crypto_frm->offset < cstream->rx.offset)) {
3040+
if (unlikely(crypto_frm->offset_node.key < cstream->rx.offset)) {
30413041
size_t diff;
30423042

3043-
if (crypto_frm->offset + crypto_frm->len <= cstream->rx.offset) {
3043+
if (crypto_frm->offset_node.key + crypto_frm->len <= cstream->rx.offset) {
30443044
/* Nothing to do */
30453045
TRACE_PROTO("Already received CRYPTO data",
30463046
QUIC_EV_CONN_RXPKT, qc, pkt, &cfdebug);
@@ -3051,13 +3051,13 @@ static enum quic_rx_ret_frm qc_handle_crypto_frm(struct quic_conn *qc,
30513051
TRACE_PROTO("Partially already received CRYPTO data",
30523052
QUIC_EV_CONN_RXPKT, qc, pkt, &cfdebug);
30533053

3054-
diff = cstream->rx.offset - crypto_frm->offset;
3054+
diff = cstream->rx.offset - crypto_frm->offset_node.key;
30553055
crypto_frm->len -= diff;
30563056
crypto_frm->data += diff;
3057-
crypto_frm->offset = cstream->rx.offset;
3057+
crypto_frm->offset_node.key = cstream->rx.offset;
30583058
}
30593059

3060-
if (crypto_frm->offset == cstream->rx.offset && ncb_is_empty(ncbuf)) {
3060+
if (crypto_frm->offset_node.key == cstream->rx.offset && ncb_is_empty(ncbuf)) {
30613061
if (!qc_provide_cdata(qel, qc->xprt_ctx, crypto_frm->data, crypto_frm->len,
30623062
pkt, &cfdebug)) {
30633063
// trace already emitted by function above
@@ -3076,7 +3076,7 @@ static enum quic_rx_ret_frm qc_handle_crypto_frm(struct quic_conn *qc,
30763076
}
30773077

30783078
/* crypto_frm->offset > cstream-trx.offset */
3079-
off_rel = crypto_frm->offset - cstream->rx.offset;
3079+
off_rel = crypto_frm->offset_node.key - cstream->rx.offset;
30803080

30813081
/* RFC 9000 7.5. Cryptographic Message Buffering
30823082
*
@@ -3326,7 +3326,7 @@ static int qc_parse_pkt_frms(struct quic_conn *qc, struct quic_rx_packet *pkt,
33263326
break;
33273327
}
33283328
case QUIC_FT_CRYPTO:
3329-
frm->crypto.offset_node.key = frm->crypto.offset;
3329+
frm->crypto.offset_node.key = frm->crypto.offset_node.key;
33303330
eb64_insert(&cf_frms_tree, &frm->crypto.offset_node);
33313331
frm = NULL;
33323332
break;
@@ -7908,7 +7908,7 @@ static inline int qc_build_frms(struct list *outlist, struct list *inlist,
79087908
TRACE_DEVEL(" New CRYPTO frame build (room, len)",
79097909
QUIC_EV_CONN_BCFRMS, qc, &room, len);
79107910
/* Compute the length of this CRYPTO frame header */
7911-
hlen = 1 + quic_int_getsize(cf->crypto.offset);
7911+
hlen = 1 + quic_int_getsize(cf->crypto.offset_node.key);
79127912
/* Compute the data length of this CRYPTO frame. */
79137913
dlen = max_stream_data_size(room, hlen, cf->crypto.len);
79147914
TRACE_DEVEL(" CRYPTO data length (hlen, crypto.len, dlen)",
@@ -7940,7 +7940,7 @@ static inline int qc_build_frms(struct list *outlist, struct list *inlist,
79407940
}
79417941

79427942
new_cf->crypto.len = dlen;
7943-
new_cf->crypto.offset = cf->crypto.offset;
7943+
new_cf->crypto.offset_node.key = cf->crypto.offset_node.key;
79447944
new_cf->crypto.qel = qel;
79457945
TRACE_DEVEL("split frame", QUIC_EV_CONN_PRSAFRM, qc, new_cf);
79467946
if (cf->origin) {
@@ -7955,7 +7955,7 @@ static inline int qc_build_frms(struct list *outlist, struct list *inlist,
79557955
LIST_APPEND(outlist, &new_cf->list);
79567956
/* Consume <dlen> bytes of the current frame. */
79577957
cf->crypto.len -= dlen;
7958-
cf->crypto.offset += dlen;
7958+
cf->crypto.offset_node.key += dlen;
79597959
}
79607960
break;
79617961

src/quic_frame.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void chunk_frm_appendf(struct buffer *buf, const struct quic_frame *frm)
111111
{
112112
const struct qf_crypto *crypto_frm = &frm->crypto;
113113
chunk_appendf(buf, " cfoff=%llu cflen=%llu",
114-
(ull)crypto_frm->offset, (ull)crypto_frm->len);
114+
(ull)crypto_frm->offset_node.key, (ull)crypto_frm->len);
115115
break;
116116
}
117117
case QUIC_FT_RESET_STREAM:
@@ -426,12 +426,12 @@ static int quic_build_crypto_frame(unsigned char **pos, const unsigned char *end
426426
const struct quic_enc_level *qel = crypto_frm->qel;
427427
size_t offset, len;
428428

429-
if (!quic_enc_int(pos, end, crypto_frm->offset) ||
429+
if (!quic_enc_int(pos, end, crypto_frm->offset_node.key) ||
430430
!quic_enc_int(pos, end, crypto_frm->len) || end - *pos < crypto_frm->len)
431431
return 0;
432432

433433
len = crypto_frm->len;
434-
offset = crypto_frm->offset;
434+
offset = crypto_frm->offset_node.key;
435435
while (len) {
436436
int idx;
437437
size_t to_copy;
@@ -459,7 +459,7 @@ static int quic_parse_crypto_frame(struct quic_frame *frm, struct quic_conn *qc,
459459
{
460460
struct qf_crypto *crypto_frm = &frm->crypto;
461461

462-
if (!quic_dec_int(&crypto_frm->offset, pos, end) ||
462+
if (!quic_dec_int((uint64_t *)&crypto_frm->offset_node.key, pos, end) ||
463463
!quic_dec_int(&crypto_frm->len, pos, end) || end - *pos < crypto_frm->len)
464464
return 0;
465465

0 commit comments

Comments
 (0)