Skip to content

Commit

Permalink
QUIC TXP: Fix reserve calculations for PING frames
Browse files Browse the repository at this point in the history
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #24122)

(cherry picked from commit c3542b2)
  • Loading branch information
hlandau authored and t8m committed Apr 18, 2024
1 parent a4e2875 commit 4414c1d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions ssl/quic/quic_txp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4414c1d

Please sign in to comment.