From: Hugo Landau Date: Tue, 1 Nov 2022 16:39:09 +0000 (+0000) Subject: QUIC ACKM: Add function to get PTO X-Git-Tag: openssl-3.2.0-alpha1~1506 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ed9e0a1e36eaa8f07a4a5371f9d13912a3f9da8;p=thirdparty%2Fopenssl.git QUIC ACKM: Add function to get PTO Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/19703) --- diff --git a/include/internal/quic_ackm.h b/include/internal/quic_ackm.h index 866213cb730..ee5f06cf342 100644 --- a/include/internal/quic_ackm.h +++ b/include/internal/quic_ackm.h @@ -225,4 +225,10 @@ int ossl_ackm_get_largest_unacked(OSSL_ACKM *ackm, int pkt_space, QUIC_PN *pn); int ossl_ackm_mark_packet_pseudo_lost(OSSL_ACKM *ackm, int pkt_space, QUIC_PN pn); +/* + * Returns the PTO duration as currently calculated. This is a quantity of time. + * This duration is used in various parts of QUIC besides the ACKM. + */ +OSSL_TIME ossl_ackm_get_pto_duration(OSSL_ACKM *ackm); + #endif diff --git a/ssl/quic/quic_ackm.c b/ssl/quic/quic_ackm.c index 54298b54c41..53eb51cfc8b 100644 --- a/ssl/quic/quic_ackm.c +++ b/ssl/quic/quic_ackm.c @@ -1663,3 +1663,19 @@ int ossl_ackm_mark_packet_pseudo_lost(OSSL_ACKM *ackm, ackm_on_pkts_lost(ackm, pkt_space, pkt, /*pseudo=*/1); return 1; } + +OSSL_TIME ossl_ackm_get_pto_duration(OSSL_ACKM *ackm) +{ + OSSL_TIME duration; + OSSL_RTT_INFO rtt; + + ossl_statm_get_rtt_info(ackm->statm, &rtt); + + duration = ossl_time_add(rtt.smoothed_rtt, + ossl_time_max(ossl_time_multiply(rtt.rtt_variance, 4), + ossl_ticks2time(K_GRANULARITY))); + if (!ossl_time_is_infinite(rtt.max_ack_delay)) + duration = ossl_time_add(duration, rtt.max_ack_delay); + + return duration; +}