diff --git a/src/quic_conn.c b/src/quic_conn.c index 9c6a09046..3019c848d 100644 --- a/src/quic_conn.c +++ b/src/quic_conn.c @@ -804,6 +804,33 @@ struct task *quic_conn_io_cb(struct task *t, void *context, unsigned int state) qc_el_rx_pkts_del(qc->hel); qc_release_pktns_frms(qc, qc->hel->pktns); } + + /* Release 0RTT packets still waiting for HP removal. These + * packets are considered unneeded after handshake completion. + * They will be freed later from Rx buf via quic_rx_pkts_del(). + */ + if (qc->eel && !LIST_ISEMPTY(&qc->eel->rx.pqpkts)) { + struct quic_rx_packet *pqpkt, *pkttmp; + list_for_each_entry_safe(pqpkt, pkttmp, &qc->eel->rx.pqpkts, list) { + LIST_DEL_INIT(&pqpkt->list); + quic_rx_packet_refdec(pqpkt); + } + + /* RFC 9001 4.9.3. Discarding 0-RTT Keys + * Additionally, a server MAY discard 0-RTT keys as soon as it receives + * a 1-RTT packet. However, due to packet reordering, a 0-RTT packet + * could arrive after a 1-RTT packet. Servers MAY temporarily retain 0- + * RTT keys to allow decrypting reordered packets without requiring + * their contents to be retransmitted with 1-RTT keys. After receiving a + * 1-RTT packet, servers MUST discard 0-RTT keys within a short time; + * the RECOMMENDED time period is three times the Probe Timeout (PTO, + * see [QUIC-RECOVERY]). A server MAY discard 0-RTT keys earlier if it + * determines that it has received all 0-RTT packets, which can be done + * by keeping track of missing packet numbers. + * + * TODO implement discarding of 0-RTT keys + */ + } } /* Insert each QEL into sending list if needed. */ diff --git a/src/quic_rx.c b/src/quic_rx.c index a2254e5e5..fd01c8f8b 100644 --- a/src/quic_rx.c +++ b/src/quic_rx.c @@ -1145,7 +1145,7 @@ static void qc_rm_hp_pkts(struct quic_conn *qc, struct quic_enc_level *el) quic_rx_packet_refinc(pqpkt); TRACE_PROTO("RX hp removed", QUIC_EV_CONN_ELRMHP, qc, pqpkt); } - LIST_DELETE(&pqpkt->list); + LIST_DEL_INIT(&pqpkt->list); quic_rx_packet_refdec(pqpkt); }