]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Add a BUG_ON_HOT() call for too small datagrams
authorFrédéric Lécaille <flecaille@haproxy.com>
Mon, 20 Feb 2023 13:43:55 +0000 (14:43 +0100)
committerFrédéric Lécaille <flecaille@haproxy.com>
Fri, 3 Mar 2023 18:12:26 +0000 (19:12 +0100)
This should be helpful to detect too small datagrams: datagrams
smaller than 1200 bytes, with Initial packets inside.

Must be backported to 2.7.

src/quic_conn.c

index dbcd4db7634baeca1bd77c07e23cfccacd87ae80..d8bcb76f91d58db969e58d4977b9ac5ec3174f68 100644 (file)
@@ -3523,6 +3523,15 @@ int qc_send_ppkts(struct buffer *buf, struct ssl_sock_ctx *ctx)
                time_sent = now_ms;
 
                for (pkt = first_pkt; pkt; pkt = next_pkt) {
+                       /* RFC 9000 14.1 Initial datagram size
+                        * a server MUST expand the payload of all UDP datagrams carrying ack-eliciting
+                        * Initial packets to at least the smallest allowed maximum datagram size of
+                        * 1200 bytes.
+                        */
+                       BUG_ON_HOT(pkt->type == QUIC_PACKET_TYPE_INITIAL &&
+                                  (pkt->flags & QUIC_FL_TX_PACKET_ACK_ELICITING) &&
+                                  dglen < QUIC_INITIAL_PACKET_MINLEN);
+
                        pkt->time_sent = time_sent;
                        if (pkt->flags & QUIC_FL_TX_PACKET_ACK_ELICITING) {
                                pkt->pktns->tx.time_of_last_eliciting = time_sent;