diff options
author | Hugo Landau <hlandau@openssl.org> | 2022-11-01 16:39:09 +0000 |
---|---|---|
committer | Hugo Landau <hlandau@openssl.org> | 2023-01-13 13:20:14 +0000 |
commit | 4ed9e0a1e36eaa8f07a4a5371f9d13912a3f9da8 (patch) | |
tree | f2ce2f3558acd9c4c7842b89d8688a4266cca06d | |
parent | 27003aa6ebcb9f3a03c253dbd26fc152e1481fab (diff) |
QUIC ACKM: Add function to get PTO
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19703)
-rw-r--r-- | include/internal/quic_ackm.h | 6 | ||||
-rw-r--r-- | ssl/quic/quic_ackm.c | 16 |
2 files changed, 22 insertions, 0 deletions
diff --git a/include/internal/quic_ackm.h b/include/internal/quic_ackm.h index 866213cb73..ee5f06cf34 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 54298b54c4..53eb51cfc8 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; +} |