]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Drop asap Retry or Version Negotiation packets
authorFrédéric Lécaille <flecaille@haproxy.com>
Wed, 22 Dec 2021 19:39:12 +0000 (20:39 +0100)
committerFrédéric Lécaille <flecaille@haproxy.com>
Wed, 22 Dec 2021 19:43:22 +0000 (20:43 +0100)
These packet are only sent by servers. We drop them as soon as possible
when we are an haproxy listener.

src/xprt_quic.c

index be71f2664422562b2741109122e6e001d092bbb7..8c4b38c9c07ff5e1717c6263312b80b59f0c63b1 100644 (file)
@@ -3973,21 +3973,21 @@ static ssize_t qc_lstnr_pkt_rcv(unsigned char *buf, const unsigned char *end,
        /* Header form */
        qc_parse_hd_form(pkt, *buf++, &long_header);
        if (long_header) {
+               uint64_t len;
+
                if (!quic_packet_read_long_header(&buf, end, pkt)) {
                        TRACE_PROTO("Packet dropped", QUIC_EV_CONN_LPKT);
                        goto err;
                }
 
+               /* Retry of Version Negotiation packets are only sent by servers */
+               if (pkt->type == QUIC_PACKET_TYPE_RETRY || !pkt->version) {
+                       TRACE_PROTO("Packet dropped", QUIC_EV_CONN_LPKT);
+                       goto err;
+               }
+
                /* RFC9000 6. Version Negotiation */
                if (!qc_pkt_is_supported_version(pkt)) {
-                       /* do not send Version Negotiation in response to a
-                        * Version Negotiation packet.
-                        */
-                       if (!pkt->version) {
-                               TRACE_PROTO("Null QUIC version, packet dropped", QUIC_EV_CONN_LPKT);
-                               goto err;
-                       }
-
                         /* unsupported version, send Negotiation packet */
                        if (qc_send_version_negotiation(l->rx.fd, saddr, pkt)) {
                                TRACE_PROTO("Error on Version Negotiation sending", QUIC_EV_CONN_LPKT);
@@ -4026,22 +4026,15 @@ static ssize_t qc_lstnr_pkt_rcv(unsigned char *buf, const unsigned char *end,
                        }
                }
 
-               /* Only packets packets with long headers and not RETRY or VERSION as type
-                * have a length field.
-                */
-               if (pkt->type != QUIC_PACKET_TYPE_RETRY && pkt->version) {
-                       uint64_t len;
-
-                       if (!quic_dec_int(&len, (const unsigned char **)&buf, end) ||
-                               end - buf < len) {
-                               TRACE_PROTO("Packet dropped", QUIC_EV_CONN_LPKT);
-                               goto err;
-                       }
-
-                       payload = buf;
-                       pkt->len = len + payload - beg;
+               if (!quic_dec_int(&len, (const unsigned char **)&buf, end) ||
+                       end - buf < len) {
+                       TRACE_PROTO("Packet dropped", QUIC_EV_CONN_LPKT);
+                       goto err;
                }
 
+               payload = buf;
+               pkt->len = len + payload - beg;
+
                qc = qc_retrieve_conn_from_cid(pkt, l, saddr);
                if (!qc) {
                        int ipv4;