From: Hugo Landau Date: Mon, 3 Jul 2023 14:45:25 +0000 (+0100) Subject: QUIC CHANNEL: Initialise max_ack_delay values properly X-Git-Tag: openssl-3.2.0-alpha1~395 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f13868def28ee532631a1dec0322a3ff51b3d7c8;p=thirdparty%2Fopenssl.git QUIC CHANNEL: Initialise max_ack_delay values properly Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/21349) --- diff --git a/ssl/quic/quic_channel.c b/ssl/quic/quic_channel.c index b872829a91f..b8d6e126656 100644 --- a/ssl/quic/quic_channel.c +++ b/ssl/quic/quic_channel.c @@ -36,6 +36,14 @@ */ #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; diff --git a/ssl/quic/quic_channel_local.h b/ssl/quic/quic_channel_local.h index 44ebc23f22a..8cc903506d9 100644 --- a/ssl/quic/quic_channel_local.h +++ b/ssl/quic/quic_channel_local.h @@ -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;