]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic-be: Correct Version Information transp. param encoding
authorFrederic Lecaille <flecaille@haproxy.com>
Wed, 17 Jan 2024 16:17:26 +0000 (17:17 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 11 Jun 2025 16:37:34 +0000 (18:37 +0200)
According to the RFC, a QUIC client must encode the QUIC version it supports
into the "Available Versions" of "Version Information" transport parameter
order by descending preference.

This is done defining <quic_version_2> and <quic_version_draft_29> new variables
pointers to the corresponding version of <quic_versions> array elements.
A client announces its available versions as follows: v1, v2, draft29.

include/haproxy/quic_conn-t.h
src/quic_conn.c
src/quic_tp.c

index 7aecde5d3b482918128494b3997e1378cf842b18..dfd24c4c29cb040db24179939222847c238bf43b 100644 (file)
@@ -228,6 +228,9 @@ struct quic_version {
 extern const struct quic_version quic_versions[];
 extern const size_t quic_versions_nb;
 extern const struct quic_version *preferred_version;
+extern const struct quic_version *quic_version_draft_29;
+extern const struct quic_version *quic_version_1;
+extern const struct quic_version *quic_version_2;
 
 /* unused: 0x01 */
 /* Flag the packet number space as requiring an ACK frame to be sent. */
index 6f7be84d7fc10fad6ababcecbef5204dacadc6d6..82c630add99c79337917ba20d8201a32721313d1 100644 (file)
@@ -119,6 +119,10 @@ const struct quic_version quic_versions[] = {
        },
 };
 
+const struct quic_version *quic_version_draft_29 = &quic_versions[0];
+const struct quic_version *quic_version_1 = &quic_versions[1];
+const struct quic_version *quic_version_2 = &quic_versions[2];
+
 /* Function pointers, can be used to compute a hash from first generated CID and to derive new CIDs */
 uint64_t (*quic_hash64_from_cid)(const unsigned char *cid, int size, const unsigned char *secret, size_t secretlen) = NULL;
 void (*quic_newcid_from_hash64)(unsigned char *cid, int size, uint64_t hash, const unsigned char *secret, size_t secretlen) = NULL;
index 6d6557e74ab695b8ba294eb57b012a4299a28d3a..2e5e47d61c209f0524c57ec3602e7437dd0f8217 100644 (file)
@@ -513,8 +513,21 @@ static int quic_transport_param_enc_version_info(unsigned char **buf,
        memcpy(*buf, &ver, sizeof ver);
        *buf += sizeof ver;
        /* For servers: all supported version, chosen included */
-       for (i = 0; i < quic_versions_nb; i++) {
-               ver = htonl(quic_versions[i].num);
+       if (server) {
+               for (i = 0; i < quic_versions_nb; i++) {
+                       ver = htonl(quic_versions[i].num);
+                       memcpy(*buf, &ver, sizeof ver);
+                       *buf += sizeof ver;
+               }
+       }
+       else {
+               ver = htonl(quic_version_1->num);
+               memcpy(*buf, &ver, sizeof ver);
+               *buf += sizeof ver;
+               ver = htonl(quic_version_2->num);
+               memcpy(*buf, &ver, sizeof ver);
+               *buf += sizeof ver;
+               ver = htonl(quic_version_draft_29->num);
                memcpy(*buf, &ver, sizeof ver);
                *buf += sizeof ver;
        }