diff options
author | Pauli <pauli@openssl.org> | 2022-10-11 20:20:12 +1100 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2022-11-16 18:02:02 +1100 |
commit | dead13551c6661d34af3e5ddf1bc53c9efdb5647 (patch) | |
tree | 9cbe22d5b77f27b5a58caeeec09b27fe9d280297 /ssl/quic/quic_ackm.c | |
parent | e32fc5ad0ea1a2d69f12d9208f2de489f7ee9737 (diff) |
QUIC ackm: use list.h
Instead of implementing a list internally.
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/19377)
Diffstat (limited to 'ssl/quic/quic_ackm.c')
-rw-r--r-- | ssl/quic/quic_ackm.c | 59 |
1 files changed, 21 insertions, 38 deletions
diff --git a/ssl/quic/quic_ackm.c b/ssl/quic/quic_ackm.c index 0f7166eaf3..4378175f00 100644 --- a/ssl/quic/quic_ackm.c +++ b/ssl/quic/quic_ackm.c @@ -12,6 +12,8 @@ #include "internal/common.h" #include <assert.h> +DEFINE_LIST_OF(tx_history, OSSL_ACKM_TX_PKT); + /* * TX Packet History * ***************** @@ -28,10 +30,7 @@ */ struct tx_pkt_history_st { /* A linked list of all our packets. */ - OSSL_ACKM_TX_PKT *head, *tail; - - /* Number of packets in the list. */ - size_t num_packets; + OSSL_LIST(tx_history) packets; /* * Mapping from packet numbers (uint64_t) to (OSSL_ACKM_TX_PKT *) @@ -78,8 +77,7 @@ static int tx_pkt_info_compare(const OSSL_ACKM_TX_PKT *a, static int tx_pkt_history_init(struct tx_pkt_history_st *h) { - h->head = h->tail = NULL; - h->num_packets = 0; + ossl_list_tx_history_init(&h->packets); h->watermark = 0; h->highest_sent = 0; @@ -95,7 +93,7 @@ tx_pkt_history_destroy(struct tx_pkt_history_st *h) { lh_OSSL_ACKM_TX_PKT_free(h->map); h->map = NULL; - h->head = h->tail = NULL; + ossl_list_tx_history_init(&h->packets); } static int @@ -113,20 +111,13 @@ tx_pkt_history_add_actual(struct tx_pkt_history_st *h, return 0; /* Should not already be in a list. */ - if (!ossl_assert(pkt->next == NULL && pkt->prev == NULL)) + if (!ossl_assert(ossl_list_tx_history_next(pkt) == NULL + && ossl_list_tx_history_prev(pkt) == NULL)) return 0; lh_OSSL_ACKM_TX_PKT_insert(h->map, pkt); - pkt->next = NULL; - pkt->prev = h->tail; - if (h->tail != NULL) - h->tail->next = pkt; - h->tail = pkt; - if (h->head == NULL) - h->head = h->tail; - - ++h->num_packets; + ossl_list_tx_history_insert_tail(&h->packets, pkt); return 1; } @@ -168,19 +159,8 @@ tx_pkt_history_remove(struct tx_pkt_history_st *h, uint64_t pkt_num) if (pkt == NULL) return 0; - if (pkt->prev != NULL) - pkt->prev->next = pkt->next; - if (pkt->next != NULL) - pkt->next->prev = pkt->prev; - if (h->head == pkt) - h->head = pkt->next; - if (h->tail == pkt) - h->tail = pkt->prev; - - pkt->prev = pkt->next = NULL; - + ossl_list_tx_history_remove(&h->packets, pkt); lh_OSSL_ACKM_TX_PKT_delete(h->map, &key); - --h->num_packets; return 1; } @@ -695,14 +675,14 @@ static OSSL_ACKM_TX_PKT *ackm_detect_and_remove_newly_acked_pkts(OSSL_ACKM *ackm pkt = tx_pkt_history_by_pkt_num(h, ack->ack_ranges[0].end); if (pkt == NULL) - pkt = h->tail; + pkt = ossl_list_tx_history_tail(&h->packets); for (; pkt != NULL; pkt = pprev) { /* * Save prev value as it will be zeroed if we remove the packet from the * history list below. */ - pprev = pkt->prev; + pprev = ossl_list_tx_history_prev(pkt); for (;; ++ridx) { if (ridx >= ack->num_ack_ranges) { @@ -774,7 +754,7 @@ static OSSL_ACKM_TX_PKT *ackm_detect_and_remove_lost_pkts(OSSL_ACKM *ackm, lost_send_time = ossl_time_subtract(now, loss_delay); h = get_tx_history(ackm, pkt_space); - pkt = h->head; + pkt = ossl_list_tx_history_head(&h->packets); for (; pkt != NULL; pkt = pnext) { assert(pkt_space == pkt->pkt_space); @@ -783,7 +763,7 @@ static OSSL_ACKM_TX_PKT *ackm_detect_and_remove_lost_pkts(OSSL_ACKM *ackm, * Save prev value as it will be zeroed if we remove the packet from the * history list below. */ - pnext = pkt->next; + pnext = ossl_list_tx_history_next(pkt); if (pkt->pkt_num > ackm->largest_acked_pkt[pkt_space]) continue; @@ -1229,8 +1209,9 @@ int ossl_ackm_on_pkt_space_discarded(OSSL_ACKM *ackm, int pkt_space) if (pkt_space == QUIC_PN_SPACE_HANDSHAKE) ackm->peer_completed_addr_validation = 1; - for (pkt = get_tx_history(ackm, pkt_space)->head; pkt != NULL; pkt = pnext) { - pnext = pkt->next; + for (pkt = ossl_list_tx_history_head(&get_tx_history(ackm, pkt_space)->packets); + pkt != NULL; pkt = pnext) { + pnext = ossl_list_tx_history_next(pkt); if (pkt->is_inflight) { ackm->bytes_in_flight -= pkt->num_bytes; num_bytes_invalidated += pkt->num_bytes; @@ -1339,10 +1320,12 @@ int ossl_ackm_get_probe_request(OSSL_ACKM *ackm, int clear, int ossl_ackm_get_largest_unacked(OSSL_ACKM *ackm, int pkt_space, QUIC_PN *pn) { struct tx_pkt_history_st *h; + OSSL_ACKM_TX_PKT *p; h = get_tx_history(ackm, pkt_space); - if (h->tail != NULL) { - *pn = h->tail->pkt_num; + p = ossl_list_tx_history_tail(&h->packets); + if (p != NULL) { + *pn = p->pkt_num; return 1; } @@ -1416,7 +1399,7 @@ static int ackm_has_newly_missing(OSSL_ACKM *ackm, int pkt_space) h = get_rx_history(ackm, pkt_space); - if (ossl_list_uint_set_num(&h->set) == 0) + if (ossl_list_uint_set_is_empty(&h->set)) return 0; /* |