From ebc3fc15090bc0a1931a9897231b06ac4a996721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20L=C3=A9caille?= Date: Wed, 22 Sep 2021 08:34:21 +0200 Subject: [PATCH] CLEANUP: quic: Remove useless inline functions We want to track the packet reference counting more easily, so without inline functions. --- include/haproxy/xprt_quic.h | 36 ------------------------------------ src/xprt_quic.c | 14 +++++++++----- 2 files changed, 9 insertions(+), 41 deletions(-) diff --git a/include/haproxy/xprt_quic.h b/include/haproxy/xprt_quic.h index bcb1d9553..aa0331f7b 100644 --- a/include/haproxy/xprt_quic.h +++ b/include/haproxy/xprt_quic.h @@ -1038,42 +1038,6 @@ static inline void quic_rx_packet_refdec(struct quic_rx_packet *pkt) pool_free(pool_head_quic_rx_packet, pkt); } -/* Add RX packet to , incrementing its reference counter. */ -static inline void quic_rx_packet_list_addq(struct mt_list *list, - struct quic_rx_packet *pkt) -{ - MT_LIST_APPEND(list, &pkt->list); - quic_rx_packet_refinc(pkt); -} - -/* Remove RX packet from , decrementing its reference counter. */ -static inline void quic_rx_packet_list_del(struct quic_rx_packet *pkt) -{ - MT_LIST_DELETE(&pkt->list); - quic_rx_packet_refdec(pkt); -} - -/* Add RX packet to tree, incrementing its reference counter. */ -static inline void quic_rx_packet_eb64_insert(struct eb_root *root, - struct eb64_node *node) -{ - eb64_insert(root, node); - quic_rx_packet_refinc(eb64_entry(node, struct quic_rx_packet, pn_node)); -} - -/* Delete RX packet from tree, decrementing its reference counter. */ -static inline void quic_rx_packet_eb64_delete(struct eb64_node *node) -{ - eb64_delete(node); - quic_rx_packet_refdec(eb64_entry(node, struct quic_rx_packet, pn_node)); -} - -/* Release the memory allocated for RX packet. */ -static inline void free_quic_rx_packet(struct quic_rx_packet *pkt) -{ - quic_rx_packet_refdec(pkt); -} - /* Increment the reference counter of */ static inline void quic_tx_packet_refinc(struct quic_tx_packet *pkt) { diff --git a/src/xprt_quic.c b/src/xprt_quic.c index d073fb1f3..80591e116 100644 --- a/src/xprt_quic.c +++ b/src/xprt_quic.c @@ -2594,7 +2594,8 @@ static inline void qc_rm_hp_pkts(struct quic_enc_level *el, struct ssl_sock_ctx /* Store the packet into the tree of packets to decrypt. */ pqpkt->pn_node.key = pqpkt->pn; HA_RWLOCK_WRLOCK(QUIC_LOCK, &el->rx.pkts_rwlock); - quic_rx_packet_eb64_insert(&el->rx.pkts, &pqpkt->pn_node); + eb64_insert(&el->rx.pkts, &pqpkt->pn_node); + quic_rx_packet_refinc(pqpkt); HA_RWLOCK_WRUNLOCK(QUIC_LOCK, &el->rx.pkts_rwlock); TRACE_PROTO("hp removed", QUIC_EV_CONN_ELRMHP, ctx->conn, pqpkt); } @@ -2693,7 +2694,8 @@ int qc_treat_rx_pkts(struct quic_enc_level *cur_el, struct quic_enc_level *next_ } } node = eb64_next(node); - quic_rx_packet_eb64_delete(&pkt->pn_node); + eb64_delete(&pkt->pn_node); + quic_rx_packet_refdec(pkt); } HA_RWLOCK_WRUNLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock); @@ -3166,13 +3168,15 @@ static inline int qc_try_rm_hp(struct quic_rx_packet *pkt, /* Store the packet */ pkt->pn_node.key = pkt->pn; HA_RWLOCK_WRLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock); - quic_rx_packet_eb64_insert(&qel->rx.pkts, &pkt->pn_node); + eb64_insert(&qel->rx.pkts, &pkt->pn_node); + quic_rx_packet_refinc(pkt); HA_RWLOCK_WRUNLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock); } else if (qel) { TRACE_PROTO("hp not removed", QUIC_EV_CONN_TRMHP, ctx ? ctx->conn : NULL, pkt); pkt->pn_offset = pn - beg; - quic_rx_packet_list_addq(&qel->rx.pqpkts, pkt); + MT_LIST_APPEND(&qel->rx.pqpkts, &pkt->list); + quic_rx_packet_refinc(pkt); } memcpy(pkt->data, beg, pkt->len); @@ -4601,7 +4605,7 @@ static ssize_t quic_dgram_read(char *buf, size_t len, void *owner, size_t pkt_len; pkt_len = pkt->len; - free_quic_rx_packet(pkt); + quic_rx_packet_refdec(pkt); /* If the packet length could not be found, we cannot continue. */ if (!pkt_len) break;