]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: rename constant for haproxy CIDs length
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 14 Dec 2021 16:17:28 +0000 (17:17 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 17 Dec 2021 09:59:36 +0000 (10:59 +0100)
On haproxy implementation, generated DCID are on 8 bytes, the minimal
value allowed by the specification. Rename the constant representing
this size to inform that this is haproxy specific.

include/haproxy/xprt_quic-t.h
include/haproxy/xprt_quic.h
src/xprt_quic.c

index 6c236fce88bd4b6e218301011dd6581ab3581f0e..826362f698cf895fa0c5cc5be0f5dcb2df277d5a 100644 (file)
@@ -56,11 +56,8 @@ typedef unsigned long long ull;
 /* The minimum length of Initial packets. */
 #define QUIC_INITIAL_PACKET_MINLEN 1200
 
-/*
- * QUIC CID lengths. This the length of the connection IDs for this QUIC
- * implementation.
- */
-#define QUIC_CID_LEN               8
+/* Lengths of the QUIC CIDs generated by the haproxy implementation. */
+#define QUIC_HAP_CID_LEN               8
 
 /* Common definitions for short and long QUIC packet headers. */
 /* QUIC connection ID maximum length for version 1. */
index 826ee77009621d074678f1b74781e7d8727f280d..6600cc6fdd7acb5194c2acea3220814294d6bd33 100644 (file)
@@ -180,7 +180,7 @@ static inline struct quic_connection_id *new_quic_cid(struct eb_root *root,
        if (!cid)
                return NULL;
 
-       cid->cid.len = QUIC_CID_LEN;
+       cid->cid.len = QUIC_HAP_CID_LEN;
        if (RAND_bytes(cid->cid.data, cid->cid.len) != 1 ||
            RAND_bytes(cid->stateless_reset_token,
                       sizeof cid->stateless_reset_token) != 1) {
index accadb75b364800f15d5d6edac1d0d0b1b205525..77ef29703a5ca6a555590b99466f7ddc2c6f01a5 100644 (file)
@@ -3477,7 +3477,7 @@ static inline int quic_packet_read_long_header(unsigned char **buf, const unsign
                 */
                if (pkt->type != QUIC_PACKET_TYPE_INITIAL &&
                    pkt->type != QUIC_PACKET_TYPE_0RTT &&
-                   dcid_len != QUIC_CID_LEN)
+                   dcid_len != QUIC_HAP_CID_LEN)
                        return 0;
 
                memcpy(pkt->dcid.data, *buf, dcid_len);
@@ -3712,7 +3712,7 @@ static ssize_t qc_srv_pkt_rcv(unsigned char **buf, const unsigned char *end,
                }
                else {
                        cids = &((struct server *)__objt_server(srv_conn->target))->cids;
-                       cid_lookup_len = QUIC_CID_LEN;
+                       cid_lookup_len = QUIC_HAP_CID_LEN;
                }
 
                node = ebmb_lookup(cids, pkt->dcid.data, cid_lookup_len);
@@ -3745,16 +3745,16 @@ static ssize_t qc_srv_pkt_rcv(unsigned char **buf, const unsigned char *end,
        }
        else {
                /* XXX TO DO: Short header XXX */
-               if (end - *buf < QUIC_CID_LEN)
+               if (end - *buf < QUIC_HAP_CID_LEN)
                        goto err;
 
                cids = &((struct server *)__objt_server(srv_conn->target))->cids;
-               node = ebmb_lookup(cids, *buf, QUIC_CID_LEN);
+               node = ebmb_lookup(cids, *buf, QUIC_HAP_CID_LEN);
                if (!node)
                        goto err;
 
                qc = ebmb_entry(node, struct quic_conn, scid_node);
-               *buf += QUIC_CID_LEN;
+               *buf += QUIC_HAP_CID_LEN;
        }
        /* Store the DCID used for this packet to check the packet which
         * come in this UDP datagram match with it.
@@ -3971,7 +3971,7 @@ static ssize_t qc_lstnr_pkt_rcv(unsigned char **buf, const unsigned char *end,
                        }
                }
                else {
-                       if (pkt->dcid.len != QUIC_CID_LEN) {
+                       if (pkt->dcid.len != QUIC_HAP_CID_LEN) {
                                TRACE_PROTO("Packet dropped", QUIC_EV_CONN_LPKT);
                                goto err;
                        }
@@ -3997,8 +3997,8 @@ static ssize_t qc_lstnr_pkt_rcv(unsigned char **buf, const unsigned char *end,
 
                HA_RWLOCK_RDLOCK(OTHER_LOCK, &l->rx.cids_lock);
                node = ebmb_lookup(cids, pkt->dcid.data, pkt->dcid.len);
-               if (!node && pkt->type == QUIC_PACKET_TYPE_INITIAL && dcid_len == QUIC_CID_LEN &&
-                   cids == &l->rx.odcids) {
+               if (!node && pkt->type == QUIC_PACKET_TYPE_INITIAL &&
+                   dcid_len == QUIC_HAP_CID_LEN && cids == &l->rx.odcids) {
                        /* Switch to the definitive tree ->cids containing the final CIDs. */
                        node = ebmb_lookup(&l->rx.cids, pkt->dcid.data, dcid_len);
                        if (node) {
@@ -4109,7 +4109,7 @@ static ssize_t qc_lstnr_pkt_rcv(unsigned char **buf, const unsigned char *end,
        else {
                struct quic_connection_id *cid;
 
-               if (end - *buf < QUIC_CID_LEN) {
+               if (end - *buf < QUIC_HAP_CID_LEN) {
                        TRACE_PROTO("Packet dropped", QUIC_EV_CONN_LPKT);
                        goto err;
                }
@@ -4117,7 +4117,7 @@ static ssize_t qc_lstnr_pkt_rcv(unsigned char **buf, const unsigned char *end,
                cids = &l->rx.cids;
 
                HA_RWLOCK_RDLOCK(QUIC_LOCK, &l->rx.cids_lock);
-               node = ebmb_lookup(cids, *buf, QUIC_CID_LEN);
+               node = ebmb_lookup(cids, *buf, QUIC_HAP_CID_LEN);
                if (!node) {
                        HA_RWLOCK_RDUNLOCK(QUIC_LOCK, &l->rx.cids_lock);
                        TRACE_PROTO("Packet dropped", QUIC_EV_CONN_LPKT);
@@ -4130,7 +4130,7 @@ static ssize_t qc_lstnr_pkt_rcv(unsigned char **buf, const unsigned char *end,
 
                if (HA_ATOMIC_LOAD(&qc->conn))
                        conn_ctx = HA_ATOMIC_LOAD(&qc->conn->xprt_ctx);
-               *buf += QUIC_CID_LEN;
+               *buf += QUIC_HAP_CID_LEN;
                pkt->qc = qc;
                /* A short packet is the last one of an UDP datagram. */
                pkt->len = end - *buf;
@@ -5040,7 +5040,7 @@ static int qc_conn_init(struct connection *conn, void **xprt_ctx)
        if (objt_server(conn->target)) {
                /* Server */
                struct server *srv = __objt_server(conn->target);
-               unsigned char dcid[QUIC_CID_LEN];
+               unsigned char dcid[QUIC_HAP_CID_LEN];
                struct quic_conn *qc;
                int ssl_err, ipv4;