]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Initial packet number spaced not discarded
authorFrédéric Lécaille <flecaille@haproxy.com>
Mon, 20 Sep 2021 09:00:46 +0000 (11:00 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 23 Sep 2021 13:27:25 +0000 (15:27 +0200)
There were cases where the Initial packet number space was not discarded.
This leaded the packet loss detection to continue to take it into
considuration during the connection lifetime. Some Application level
packets could not be retransmitted.

src/xprt_quic.c

index 40346f9bfa34607cad4a6834ec71b7956ef0fee9..75ba788daef36abaec416ef1b2714b869cfb9f7a 100644 (file)
@@ -2003,12 +2003,17 @@ static int qc_parse_pkt_frms(struct quic_rx_packet *pkt, struct ssl_sock_ctx *ct
         * has successfully parse a Handshake packet. The Initial encryption must also
         * be discarded.
         */
-       if (HA_ATOMIC_LOAD(&conn->state) == QUIC_HS_ST_SERVER_INITIAL &&
-           pkt->type == QUIC_PACKET_TYPE_HANDSHAKE) {
-               quic_tls_discard_keys(&conn->els[QUIC_TLS_ENC_LEVEL_INITIAL]);
-               quic_pktns_discard(conn->els[QUIC_TLS_ENC_LEVEL_INITIAL].pktns, conn);
-               qc_set_timer(ctx);
-               HA_ATOMIC_STORE(&conn->state, QUIC_HS_ST_SERVER_HANDSHAKE);
+       if (pkt->type == QUIC_PACKET_TYPE_HANDSHAKE && objt_listener(ctx->conn->target)) {
+           int state = HA_ATOMIC_LOAD(&conn->state);
+
+           if (state >= QUIC_HS_ST_SERVER_INITIAL) {
+                   quic_tls_discard_keys(&conn->els[QUIC_TLS_ENC_LEVEL_INITIAL]);
+                   TRACE_PROTO("discarding Initial pktns", QUIC_EV_CONN_PRSHPKT, ctx->conn);
+                   quic_pktns_discard(conn->els[QUIC_TLS_ENC_LEVEL_INITIAL].pktns, conn);
+                   qc_set_timer(ctx);
+                   if (state < QUIC_HS_ST_SERVER_HANDSHAKE)
+                           HA_ATOMIC_STORE(&conn->state, QUIC_HS_ST_SERVER_HANDSHAKE);
+           }
        }
 
        TRACE_LEAVE(QUIC_EV_CONN_PRSHPKT, ctx->conn);