summaryrefslogtreecommitdiffstats
path: root/ssl
diff options
context:
space:
mode:
authorHugo Landau <hlandau@openssl.org>2022-08-15 17:45:17 +0200
committerHugo Landau <hlandau@openssl.org>2022-08-24 15:05:46 +0200
commit4d32f5332fa69ac949feec54c273fe63639ad891 (patch)
tree4a6185777f214a43bf2dae98f2c8c23f9075a1fc /ssl
parentQUIC ACK Manager, Statistics Manager and Congestion Control API (diff)
downloadopenssl-4d32f5332fa69ac949feec54c273fe63639ad891.tar.xz
openssl-4d32f5332fa69ac949feec54c273fe63639ad891.zip
Updates for OSSL_TIME changes
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18676)
Diffstat (limited to 'ssl')
-rw-r--r--ssl/quic/quic_ackm.c49
-rw-r--r--ssl/quic/quic_statm.c12
2 files changed, 31 insertions, 30 deletions
diff --git a/ssl/quic/quic_ackm.c b/ssl/quic/quic_ackm.c
index 670b2d316e..dde882c649 100644
--- a/ssl/quic/quic_ackm.c
+++ b/ssl/quic/quic_ackm.c
@@ -1124,15 +1124,15 @@ static OSSL_ACKM_TX_PKT *ackm_detect_and_remove_lost_pkts(OSSL_ACKM *ackm,
ossl_statm_get_rtt_info(ackm->statm, &rtt);
- ackm->loss_time[pkt_space] = 0;
+ ackm->loss_time[pkt_space] = ossl_time_zero();
- loss_delay = ossl_time_multiply(K_TIME_THRESHOLD_NUM,
- ossl_time_max(rtt.latest_rtt,
- rtt.smoothed_rtt));
+ loss_delay = ossl_time_multiply(ossl_time_max(rtt.latest_rtt,
+ rtt.smoothed_rtt),
+ K_TIME_THRESHOLD_NUM);
loss_delay = ossl_time_divide(loss_delay, K_TIME_THRESHOLD_DEN);
/* Minimum time of K_GRANULARITY before packets are deemed lost. */
- loss_delay = ossl_time_max(loss_delay, K_GRANULARITY);
+ loss_delay = ossl_time_max(loss_delay, ossl_ticks2time(K_GRANULARITY));
/* Packets sent before this time are deemed lost. */
now = ackm->now(ackm->now_arg);
@@ -1198,15 +1198,15 @@ static OSSL_TIME ackm_get_pto_time_and_space(OSSL_ACKM *ackm, int *space)
{
OSSL_RTT_INFO rtt;
OSSL_TIME duration;
- OSSL_TIME pto_timeout = OSSL_TIME_INFINITY, t;
+ OSSL_TIME pto_timeout = ossl_time_infinite(), t;
int pto_space = QUIC_PN_SPACE_INITIAL, i;
ossl_statm_get_rtt_info(ackm->statm, &rtt);
duration
= ossl_time_add(rtt.smoothed_rtt,
- ossl_time_max(ossl_time_multiply(4, rtt.rtt_variance),
- K_GRANULARITY));
+ ossl_time_max(ossl_time_multiply(rtt.rtt_variance, 4),
+ ossl_ticks2time(K_GRANULARITY)));
duration
= ossl_time_multiply(duration, 1U << min_u32(ackm->pto_count,
@@ -1232,7 +1232,7 @@ static OSSL_TIME ackm_get_pto_time_and_space(OSSL_ACKM *ackm, int *space)
break;
/* Include max_ack_delay and backoff for app data. */
- if (!ossl_time_is_infinity(rtt.max_ack_delay))
+ if (!ossl_time_is_infinite(rtt.max_ack_delay))
duration
= ossl_time_add(duration,
ossl_time_multiply(rtt.max_ack_delay,
@@ -1241,7 +1241,7 @@ static OSSL_TIME ackm_get_pto_time_and_space(OSSL_ACKM *ackm, int *space)
}
t = ossl_time_add(ackm->time_of_last_ack_eliciting_pkt[i], duration);
- if (t < pto_timeout) {
+ if (ossl_time_compare(t, pto_timeout) < 0) {
pto_timeout = t;
pto_space = i;
}
@@ -1280,7 +1280,7 @@ static int ackm_set_loss_detection_timer(OSSL_ACKM *ackm)
* needs to arm the timer if the server might be blocked by the
* anti-amplification limit.
*/
- ackm_set_loss_detection_timer_actual(ackm, OSSL_TIME_ZERO);
+ ackm_set_loss_detection_timer_actual(ackm, ossl_time_zero());
return 1;
}
@@ -1328,7 +1328,7 @@ static void ackm_on_pkts_lost(OSSL_ACKM *ackm, int pkt_space,
*/
ossl_statm_get_rtt_info(ackm->statm, &rtt);
- if (ackm->first_rtt_sample == 0)
+ if (ossl_time_is_zero(ackm->first_rtt_sample))
return;
ackm->cc_method->on_data_lost(ackm->cc_data,
@@ -1391,7 +1391,7 @@ OSSL_ACKM *ossl_ackm_new(OSSL_TIME (*now)(void *arg),
for (i = 0; i < (int)OSSL_NELEM(ackm->tx_history); ++i) {
ackm->largest_acked_pkt[i] = QUIC_PN_INVALID;
- ackm->rx_ack_flush_deadline[i] = OSSL_TIME_INFINITY;
+ ackm->rx_ack_flush_deadline[i] = ossl_time_infinite();
if (tx_pkt_history_init(&ackm->tx_history[i]) < 1)
goto err;
}
@@ -1607,8 +1607,8 @@ int ossl_ackm_on_pkt_space_discarded(OSSL_ACKM *ackm, int pkt_space)
ackm->cc_method->on_data_invalidated(ackm->cc_data,
num_bytes_invalidated);
- ackm->time_of_last_ack_eliciting_pkt[pkt_space] = OSSL_TIME_ZERO;
- ackm->loss_time[pkt_space] = OSSL_TIME_ZERO;
+ ackm->time_of_last_ack_eliciting_pkt[pkt_space] = ossl_time_zero();
+ ackm->loss_time[pkt_space] = ossl_time_zero();
ackm->pto_count = 0;
ackm->discarded[pkt_space] = 1;
ackm->ack_eliciting_bytes_in_flight[pkt_space] = 0;
@@ -1713,7 +1713,7 @@ int ossl_ackm_get_largest_unacked(OSSL_ACKM *ackm, int pkt_space, QUIC_PN *pn)
/* Number of ACK-eliciting packets RX'd before we always emit an ACK. */
#define PKTS_BEFORE_ACK 2
/* Maximum amount of time to leave an ACK-eliciting packet un-ACK'd. */
-#define MAX_ACK_DELAY (ossl_time_multiply(OSSL_TIME_MS, 25))
+#define MAX_ACK_DELAY (OSSL_TIME_MS * 25)
/*
* Return 1 if emission of an ACK frame is currently desired.
@@ -1733,7 +1733,7 @@ int ossl_ackm_get_largest_unacked(OSSL_ACKM *ackm, int pkt_space, QUIC_PN *pn)
int ossl_ackm_is_ack_desired(OSSL_ACKM *ackm, int pkt_space)
{
return ackm->rx_ack_desired[pkt_space]
- || (!ossl_time_is_infinity(ackm->rx_ack_flush_deadline[pkt_space])
+ || (!ossl_time_is_infinite(ackm->rx_ack_flush_deadline[pkt_space])
&& ossl_time_compare(ackm->now(ackm->now_arg),
ackm->rx_ack_flush_deadline[pkt_space]) >= 0);
}
@@ -1814,7 +1814,7 @@ static void ackm_queue_ack(OSSL_ACKM *ackm, int pkt_space)
ackm->rx_ack_desired[pkt_space] = 1;
/* Cancel deadline. */
- ackm_set_flush_deadline(ackm, pkt_space, OSSL_TIME_INFINITY);
+ ackm_set_flush_deadline(ackm, pkt_space, ossl_time_infinite());
}
static void ackm_on_rx_ack_eliciting(OSSL_ACKM *ackm,
@@ -1863,14 +1863,15 @@ static void ackm_on_rx_ack_eliciting(OSSL_ACKM *ackm,
*
* Update the ACK flush deadline.
*/
- if (ossl_time_is_infinity(ackm->rx_ack_flush_deadline[pkt_space]))
+ if (ossl_time_is_infinite(ackm->rx_ack_flush_deadline[pkt_space]))
ackm_set_flush_deadline(ackm, pkt_space,
- ossl_time_add(rx_time, MAX_ACK_DELAY));
+ ossl_time_add(rx_time,
+ ossl_ticks2time(MAX_ACK_DELAY)));
else
ackm_set_flush_deadline(ackm, pkt_space,
ossl_time_min(ackm->rx_ack_flush_deadline[pkt_space],
ossl_time_add(rx_time,
- MAX_ACK_DELAY)));
+ ossl_ticks2time(MAX_ACK_DELAY))));
}
int ossl_ackm_on_rx_packet(OSSL_ACKM *ackm, const OSSL_ACKM_RX_PKT *pkt)
@@ -1966,7 +1967,7 @@ const OSSL_QUIC_FRAME_ACK *ossl_ackm_get_ack_frame(OSSL_ACKM *ackm,
ack->delay_time =
ossl_time_subtract(now, ackm->rx_largest_time[pkt_space]);
else
- ack->delay_time = OSSL_TIME_ZERO;
+ ack->delay_time = ossl_time_zero();
ack->ect0 = ackm->rx_ect0[pkt_space];
ack->ect1 = ackm->rx_ect1[pkt_space];
@@ -1977,7 +1978,7 @@ const OSSL_QUIC_FRAME_ACK *ossl_ackm_get_ack_frame(OSSL_ACKM *ackm,
ackm->rx_ack_generated[pkt_space] = 1;
ackm->rx_ack_desired[pkt_space] = 0;
- ackm_set_flush_deadline(ackm, pkt_space, OSSL_TIME_INFINITY);
+ ackm_set_flush_deadline(ackm, pkt_space, ossl_time_infinite());
return ack;
}
@@ -1986,7 +1987,7 @@ OSSL_TIME ossl_ackm_get_ack_deadline(OSSL_ACKM *ackm, int pkt_space)
{
if (ackm->rx_ack_desired[pkt_space])
/* Already desired, deadline is now. */
- return OSSL_TIME_ZERO;
+ return ossl_time_zero();
return ackm->rx_ack_flush_deadline[pkt_space];
}
diff --git a/ssl/quic/quic_statm.c b/ssl/quic/quic_statm.c
index 35f5722735..cf402036c5 100644
--- a/ssl/quic/quic_statm.c
+++ b/ssl/quic/quic_statm.c
@@ -42,24 +42,24 @@ void ossl_statm_update_rtt(OSSL_STATM *statm,
if (ossl_time_compare(latest_rtt, ossl_time_add(statm->min_rtt, ack_delay)) >= 0)
adjusted_rtt = ossl_time_subtract(latest_rtt, ack_delay);
- statm->rtt_variance = ossl_time_divide(ossl_time_add(ossl_time_multiply(3, statm->rtt_variance),
+ statm->rtt_variance = ossl_time_divide(ossl_time_add(ossl_time_multiply(statm->rtt_variance, 3),
ossl_time_abs_difference(statm->smoothed_rtt,
adjusted_rtt)), 4);
- statm->smoothed_rtt = ossl_time_divide(ossl_time_add(ossl_time_multiply(7, statm->smoothed_rtt),
+ statm->smoothed_rtt = ossl_time_divide(ossl_time_add(ossl_time_multiply(statm->smoothed_rtt, 7),
adjusted_rtt), 8);
}
/* RFC 9002 kInitialRtt value. RFC recommended value. */
-#define K_INITIAL_RTT (ossl_time_multiply(OSSL_TIME_MS, 333))
+#define K_INITIAL_RTT (ossl_ticks2time(333 * OSSL_TIME_MS))
int ossl_statm_init(OSSL_STATM *statm)
{
statm->smoothed_rtt = K_INITIAL_RTT;
- statm->latest_rtt = OSSL_TIME_ZERO;
- statm->min_rtt = OSSL_TIME_INFINITY;
+ statm->latest_rtt = ossl_time_zero();
+ statm->min_rtt = ossl_time_infinite();
statm->rtt_variance = ossl_time_divide(K_INITIAL_RTT, 2);
statm->have_first_sample = 0;
- statm->max_ack_delay = OSSL_TIME_INFINITY;
+ statm->max_ack_delay = ossl_time_infinite();
return 1;
}