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.
This commit is contained in:
Frédéric Lécaille 2021-12-06 12:09:08 +01:00 committed by Amaury Denoyelle
parent 7d807c93f4
commit fee7ba673f
2 changed files with 21 additions and 0 deletions

View 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);

View 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;
}