diff options
author | Hugo Landau <hlandau@openssl.org> | 2024-04-12 07:58:24 +0100 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2024-04-18 17:42:57 +0200 |
commit | 4414c1d3aa056429a50c462e0515938176e4cd93 (patch) | |
tree | fb6827981c63a5eb379c853c6b3295e8cbe8cf29 | |
parent | a4e28758d19247a578befc4658d54a3b2f7bcdff (diff) |
QUIC TXP: Fix reserve calculations for PING frames
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24122)
(cherry picked from commit c3542b22fa3f14d7b6c970d4b2c38a737d6ed8a4)
-rw-r--r-- | ssl/quic/quic_txp.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/ssl/quic/quic_txp.c b/ssl/quic/quic_txp.c index f26f1e81a1..3996d25a02 100644 --- a/ssl/quic/quic_txp.c +++ b/ssl/quic/quic_txp.c @@ -1590,10 +1590,21 @@ static void on_regen_notify(uint64_t frame_type, uint64_t stream_id, } } +static int txp_need_ping(OSSL_QUIC_TX_PACKETISER *txp, + uint32_t pn_space, + const struct archetype_data *adata) +{ + return adata->allow_ping + && (adata->require_ack_eliciting + || (txp->force_ack_eliciting & (1UL << pn_space)) != 0); +} + static int txp_pkt_init(struct txp_pkt *pkt, OSSL_QUIC_TX_PACKETISER *txp, uint32_t enc_level, uint32_t archetype, size_t running_total) { + uint32_t pn_space = ossl_quic_enc_level_to_pn_space(enc_level); + if (!txp_determine_geometry(txp, archetype, enc_level, running_total, &pkt->phdr, &pkt->geom)) return 0; @@ -1604,7 +1615,7 @@ static int txp_pkt_init(struct txp_pkt *pkt, OSSL_QUIC_TX_PACKETISER *txp, */ if (!tx_helper_init(&pkt->h, txp, enc_level, pkt->geom.cmppl, - pkt->geom.adata.require_ack_eliciting ? 1 : 0)) + txp_need_ping(txp, pn_space, &pkt->geom.adata) ? 1 : 0)) return 0; pkt->h_valid = 1; @@ -2772,11 +2783,10 @@ static int txp_generate_for_el(OSSL_QUIC_TX_PACKETISER *txp, /* PING */ tx_helper_unrestrict(h); - if ((a.require_ack_eliciting - || (txp->force_ack_eliciting & (1UL << pn_space)) != 0) - && !have_ack_eliciting && a.allow_ping) { + if (!have_ack_eliciting && txp_need_ping(txp, pn_space, &a)) { WPACKET *wpkt; + assert(h->reserve > 0); wpkt = tx_helper_begin(h); if (wpkt == NULL) goto fatal_err; |