]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Delete remaining RX handshake packets
authorFrédéric Lécaille <flecaille@haproxy.com>
Mon, 6 Dec 2021 11:09:08 +0000 (12:09 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 7 Dec 2021 14:53:56 +0000 (15:53 +0100)
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.

include/haproxy/xprt_quic.h
src/xprt_quic.c

index 4b619a6584e1eb5f0c3ab9b073ee50c5aebcf864..24e6ad319f95690c633c3a0b2cd593ee5d260a2d 100644 (file)
@@ -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 <qel> 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);
index d50df308bb36ce6b60ef026cc975ef2217c8f579..347e519463f782d66fd445742ede5ec5f294cabb 100644 (file)
@@ -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;
        }