]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Only take note of the ack deadline if we can actually issue an ack
authorMatt Caswell <matt@openssl.org>
Mon, 12 Jun 2023 15:21:16 +0000 (16:21 +0100)
committerMatt Caswell <matt@openssl.org>
Wed, 14 Jun 2023 09:23:58 +0000 (10:23 +0100)
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 https://github.com/openssl/openssl/pull/21181)

ssl/quic/quic_channel.c

index d4437c4d90f93e640a29c75d3cd56f1f37272da6..aa4233c51d136a43b9754c987ab100909c0988fd 100644 (file)
@@ -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();
@@ -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,