From: Frédéric Lécaille Date: Mon, 6 Dec 2021 11:09:08 +0000 (+0100) Subject: MINOR: quic: Delete remaining RX handshake packets X-Git-Tag: v2.6-dev1~309 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fee7ba673f3f77a37aed0a14a976adbbeeafd591;p=thirdparty%2Fhaproxy.git MINOR: quic: Delete remaining RX handshake packets After the handshake has succeeded, we must delete any remaining Initial or Handshake packets from the RX buffer. This cannot be done depending on the state the connection (->st quic_conn struct member value) as the packet are not received/treated in order. --- diff --git a/include/haproxy/xprt_quic.h b/include/haproxy/xprt_quic.h index 4b619a6584..24e6ad319f 100644 --- a/include/haproxy/xprt_quic.h +++ b/include/haproxy/xprt_quic.h @@ -1108,6 +1108,24 @@ static inline void quic_tx_packet_refdec(struct quic_tx_packet *pkt) pool_free(pool_head_quic_tx_packet, pkt); } +/* Delete all RX packets for QUIC encryption level */ +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 = + eb64_entry(&node->node, struct quic_rx_packet, pn_node); + + node = eb64_next(node); + eb64_delete(&pkt->pn_node); + quic_rx_packet_refdec(pkt); + } + HA_RWLOCK_WRUNLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock); +} + void quic_set_tls_alert(struct quic_conn *qc, int alert); ssize_t quic_lstnr_dgram_read(struct buffer *buf, size_t len, void *owner, struct sockaddr_storage *saddr); diff --git a/src/xprt_quic.c b/src/xprt_quic.c index d50df308bb..347e519463 100644 --- a/src/xprt_quic.c +++ b/src/xprt_quic.c @@ -3114,6 +3114,9 @@ struct task *quic_conn_io_cb(struct task *t, void *context, unsigned int state) qc_set_timer(ctx); if (!quic_build_post_handshake_frames(qc)) goto err; + + qc_el_rx_pkts_del(&qc->els[QUIC_TLS_ENC_LEVEL_INITIAL]); + qc_el_rx_pkts_del(&qc->els[QUIC_TLS_ENC_LEVEL_HANDSHAKE]); goto start; }