Skip to content

Commit

Permalink
Only take note of the ack deadline if we can actually issue an ack
Browse files Browse the repository at this point in the history
When determining the next tick deadline we cannot actually issue an
ack if the CC will not let us, or the enc_level is not yet provisioned.

This avoids a bug where we can end up in a busy loop because the next
event deadline is reported as "now" because we want to send an ack, but
we can't actually send anything yet.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from #21181)
  • Loading branch information
mattcaswell committed Jun 14, 2023
1 parent fbff5b5 commit ca71165
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions ssl/quic/quic_channel.c
Expand Up @@ -1710,7 +1710,7 @@ static int ch_tx(QUIC_CHANNEL *ch)
static OSSL_TIME ch_determine_next_tick_deadline(QUIC_CHANNEL *ch)
{
OSSL_TIME deadline;
uint32_t pn_space;
int i;

if (ossl_quic_channel_is_terminated(ch))
return ossl_time_infinite();
Expand All @@ -1719,9 +1719,19 @@ static OSSL_TIME ch_determine_next_tick_deadline(QUIC_CHANNEL *ch)
if (ossl_time_is_zero(deadline))
deadline = ossl_time_infinite();

for (pn_space = QUIC_PN_SPACE_INITIAL; pn_space < QUIC_PN_SPACE_NUM; ++pn_space)
deadline = ossl_time_min(deadline,
ossl_ackm_get_ack_deadline(ch->ackm, pn_space));
/*
* If the CC will let us send acks, check the ack deadline for all
* enc_levels that are actually provisioned
*/
if (ch->cc_method->get_tx_allowance(ch->cc_data) > 0) {
for (i = 0; i < QUIC_ENC_LEVEL_NUM; i++) {
if (ossl_qtx_is_enc_level_provisioned(ch->qtx, i)) {
deadline = ossl_time_min(deadline,
ossl_ackm_get_ack_deadline(ch->ackm,
ossl_quic_enc_level_to_pn_space(i)));
}
}
}

/* When will CC let us send more? */
if (ossl_quic_tx_packetiser_has_pending(ch->txp, TX_PACKETISER_ARCHETYPE_NORMAL,
Expand Down

0 comments on commit ca71165

Please sign in to comment.