From: Frédéric Lécaille Date: Thu, 11 Aug 2022 09:40:01 +0000 (+0200) Subject: MINOR: quic: Remove useless lock for RX packets X-Git-Tag: v2.7-dev4~59 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a6920a25d98d8b126fe029620e0165d0d2ad15b2;p=thirdparty%2Fhaproxy.git MINOR: quic: Remove useless lock for RX packets This lock was there be able to handle the RX packets for a connetion from several threads. This is no more needed since a QUIC connection is always handled by the same thread. May be backported to 2.6 --- diff --git a/include/haproxy/xprt_quic-t.h b/include/haproxy/xprt_quic-t.h index 2b219eaa1a..f6fcf95e59 100644 --- a/include/haproxy/xprt_quic-t.h +++ b/include/haproxy/xprt_quic-t.h @@ -517,8 +517,6 @@ struct quic_enc_level { /* The packets received by the listener I/O handler with header protection removed. */ struct eb_root pkts; - /* root must be protected from concurrent accesses */ - __decl_thread(HA_RWLOCK_T pkts_rwlock); /* Liste of QUIC packets with protected header. */ struct mt_list pqpkts; /* Crypto frames */ diff --git a/include/haproxy/xprt_quic.h b/include/haproxy/xprt_quic.h index a9e29cbcd0..4f85be876d 100644 --- a/include/haproxy/xprt_quic.h +++ b/include/haproxy/xprt_quic.h @@ -667,9 +667,7 @@ static inline int qc_el_rx_pkts(struct quic_enc_level *qel) { int ret; - HA_RWLOCK_RDLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock); ret = !eb_is_empty(&qel->rx.pkts); - HA_RWLOCK_RDUNLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock); return ret; } @@ -728,7 +726,6 @@ static inline void qc_el_rx_pkts_del(struct quic_enc_level *qel) { struct eb64_node *node; - HA_RWLOCK_WRLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock); node = eb64_first(&qel->rx.pkts); while (node) { struct quic_rx_packet *pkt = @@ -738,14 +735,12 @@ static inline void qc_el_rx_pkts_del(struct quic_enc_level *qel) eb64_delete(&pkt->pn_node); quic_rx_packet_refdec(pkt); } - HA_RWLOCK_WRUNLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock); } static inline void qc_list_qel_rx_pkts(struct quic_enc_level *qel) { struct eb64_node *node; - HA_RWLOCK_RDLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock); node = eb64_first(&qel->rx.pkts); while (node) { struct quic_rx_packet *pkt; @@ -755,7 +750,6 @@ static inline void qc_list_qel_rx_pkts(struct quic_enc_level *qel) pkt, pkt->type, (ull)pkt->pn_node.key); node = eb64_next(node); } - HA_RWLOCK_RDUNLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock); } static inline void qc_list_all_rx_pkts(struct quic_conn *qc) diff --git a/src/xprt_quic.c b/src/xprt_quic.c index 436f701710..05ff1e7efc 100644 --- a/src/xprt_quic.c +++ b/src/xprt_quic.c @@ -3697,10 +3697,8 @@ static inline void qc_rm_hp_pkts(struct quic_conn *qc, struct quic_enc_level *el pqpkt->aad_len = pqpkt->pn_offset + pqpkt->pnl; /* 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); eb64_insert(&el->rx.pkts, &pqpkt->pn_node); quic_rx_packet_refinc(pqpkt); - HA_RWLOCK_WRUNLOCK(QUIC_LOCK, &el->rx.pkts_rwlock); TRACE_DEVEL("hp removed", QUIC_EV_CONN_ELRMHP, qc, pqpkt); } MT_LIST_DELETE_SAFE(pkttmp1); @@ -3769,7 +3767,6 @@ int qc_treat_rx_pkts(struct quic_enc_level *cur_el, struct quic_enc_level *next_ if (!qel) goto out; - HA_RWLOCK_WRLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock); node = eb64_first(&qel->rx.pkts); while (node) { struct quic_rx_packet *pkt; @@ -3811,7 +3808,6 @@ int qc_treat_rx_pkts(struct quic_enc_level *cur_el, struct quic_enc_level *next_ eb64_delete(&pkt->pn_node); quic_rx_packet_refdec(pkt); } - HA_RWLOCK_WRUNLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock); if (largest_pn != -1 && largest_pn > qel->pktns->rx.largest_pn) { /* Update the largest packet number. */ @@ -4325,7 +4321,6 @@ static int quic_conn_enc_level_init(struct quic_conn *qc, qel->tls_ctx.flags = 0; qel->rx.pkts = EB_ROOT; - HA_RWLOCK_INIT(&qel->rx.pkts_rwlock); MT_LIST_INIT(&qel->rx.pqpkts); qel->rx.crypto.offset = 0; qel->rx.crypto.frms = EB_ROOT_UNIQUE; @@ -4931,9 +4926,7 @@ static void qc_pkt_insert(struct quic_conn *qc, pkt->pn_node.key = pkt->pn; quic_rx_packet_refinc(pkt); - HA_RWLOCK_WRLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock); eb64_insert(&qel->rx.pkts, &pkt->pn_node); - HA_RWLOCK_WRUNLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock); TRACE_LEAVE(QUIC_EV_CONN_RXPKT, qc); }