QUIC CHANNEL: Initialise max_ack_delay values properly
authorHugo Landau <hlandau@openssl.org>
Mon, 3 Jul 2023 14:45:25 +0000 (15:45 +0100)
committerPauli <pauli@openssl.org>
Wed, 19 Jul 2023 03:03:11 +0000 (13:03 +1000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21349)

ssl/quic/quic_channel.c
ssl/quic/quic_channel_local.h

index b872829a91faa8c8bb986b587aa1544266ac2099..b8d6e126656120809895a355b9a64e69619c12c0 100644 (file)
  */
 #define MAX_NAT_INTERVAL (ossl_ms2time(25000))
 
+/*
+ * Our maximum ACK delay on the TX side. This is up to us to choose. Note that
+ * this could differ from QUIC_DEFAULT_MAX_DELAY in future as that is a protocol
+ * value which determines the value of the maximum ACK delay if the
+ * max_ack_delay transport parameter is not set.
+ */
+#define DEFAULT_MAX_ACK_DELAY   QUIC_DEFAULT_MAX_ACK_DELAY
+
 static void ch_rx_pre(QUIC_CHANNEL *ch);
 static int ch_rx(QUIC_CHANNEL *ch);
 static int ch_tx(QUIC_CHANNEL *ch);
@@ -292,6 +300,7 @@ static int ch_init(QUIC_CHANNEL *ch)
     if ((ch->qtls = ossl_quic_tls_new(&tls_args)) == NULL)
         goto err;
 
+    ch->tx_max_ack_delay        = DEFAULT_MAX_ACK_DELAY;
     ch->rx_max_ack_delay        = QUIC_DEFAULT_MAX_ACK_DELAY;
     ch->rx_ack_delay_exp        = QUIC_DEFAULT_ACK_DELAY_EXP;
     ch->rx_active_conn_id_limit = QUIC_MIN_ACTIVE_CONN_ID_LIMIT;
@@ -300,6 +309,9 @@ static int ch_init(QUIC_CHANNEL *ch)
     ch->rx_enc_level            = QUIC_ENC_LEVEL_INITIAL;
     ch->txku_threshold_override = UINT64_MAX;
 
+    ossl_ackm_set_tx_max_ack_delay(ch->ackm, ossl_ms2time(ch->tx_max_ack_delay));
+    ossl_ackm_set_rx_max_ack_delay(ch->ackm, ossl_ms2time(ch->rx_max_ack_delay));
+
     /*
      * Determine the QUIC Transport Parameters and serialize the transport
      * parameters block. (For servers, we do this later as we must defer
@@ -1232,6 +1244,9 @@ static int ch_on_transport_params(const unsigned char *params,
             }
 
             ch->rx_max_ack_delay = v;
+            ossl_ackm_set_rx_max_ack_delay(ch->ackm,
+                                           ossl_ms2time(ch->rx_max_ack_delay));
+
             got_max_ack_delay = 1;
             break;
 
@@ -1511,6 +1526,11 @@ static int ch_generate_transport_params(QUIC_CHANNEL *ch)
                                                    QUIC_MIN_ACTIVE_CONN_ID_LIMIT))
         goto err;
 
+    if (ch->tx_max_ack_delay != QUIC_DEFAULT_MAX_ACK_DELAY
+        && !ossl_quic_wire_encode_transport_param_int(&wpkt, QUIC_TPARAM_MAX_ACK_DELAY,
+                                                      ch->tx_max_ack_delay))
+        goto err;
+
     if (!ossl_quic_wire_encode_transport_param_int(&wpkt, QUIC_TPARAM_INITIAL_MAX_DATA,
                                                    ossl_quic_rxfc_get_cwm(&ch->conn_rxfc)))
         goto err;
index 44ebc23f22a1d051491fa9c1fa437ce9973ca768..8cc903506d9e1dd3a71fe07bf34b48cd0e0a5bfd 100644 (file)
@@ -138,6 +138,7 @@ struct quic_channel_st {
     uint64_t                        tx_init_max_stream_data_bidi_local;
     uint64_t                        tx_init_max_stream_data_bidi_remote;
     uint64_t                        tx_init_max_stream_data_uni;
+    uint64_t                        tx_max_ack_delay; /* ms */
 
     /* Transport parameter values received from server. */
     uint64_t                        rx_init_max_stream_data_bidi_local;