MINOR: quic: remove address concatenation to ODCID
Previously, ODCID were concatenated with the client address. This was
done to prevent a collision between two endpoints which used the same
ODCID.
Thanks to the two previous patches, first connection generated CID is
now directly derived from the client ODCID using a hash function which
uses the client source address from the same purpose. Thus, it is now
unneeded to concatenate client address to <odcid> quic-conn member.
This change allows to simplify the quic_cid structure management and
reduce its size which is important as it is embedded several times in
various structures such as quic_conn and quic_rx_packet.
This should be backported up to 2.7.
diff --git a/include/haproxy/quic_conn-t.h b/include/haproxy/quic_conn-t.h
index f6a9629..fdeb9da 100644
--- a/include/haproxy/quic_conn-t.h
+++ b/include/haproxy/quic_conn-t.h
@@ -282,9 +282,8 @@
* <data> member must be the first one.
*/
struct quic_cid {
- unsigned char data[QUIC_CID_MAXLEN + sizeof(in_port_t) + sizeof(struct in6_addr)];
- unsigned char len; /* size of QUIC CID, excluding possible concatenated address */
- unsigned char addrlen; /* size of port + IP if present in data*/
+ unsigned char data[QUIC_CID_MAXLEN];
+ unsigned char len; /* size of QUIC CID */
};
/* QUIC connection id attached to a QUIC connection.
@@ -651,12 +650,7 @@
unsigned char enc_params[QUIC_TP_MAX_ENCLEN]; /* encoded QUIC transport parameters */
size_t enc_params_len;
- /*
- * Original DCID used by clients on first Initial packets.
- * <odcid> is concatenated with the socket src address.
- */
- struct quic_cid odcid;
-
+ struct quic_cid odcid; /* First DCID used by client on its Initial packet. */
struct quic_cid dcid; /* DCID of our endpoint - not updated when a new DCID is used */
struct ebmb_node scid_node; /* used only for client side (backend) */
struct quic_cid scid; /* first SCID of our endpoint - not updated when a new SCID is used */
diff --git a/include/haproxy/quic_conn.h b/include/haproxy/quic_conn.h
index 8342c9b..5689110 100644
--- a/include/haproxy/quic_conn.h
+++ b/include/haproxy/quic_conn.h
@@ -120,42 +120,6 @@
return p - buf;
}
-/* Concatenate the port and address of <saddr> to <cid> QUIC connection ID. The
- * <addrlen> field of <cid> will be updated with the size of the concatenated
- * address.
- *
- * Returns the number of bytes concatenated to <cid>.
- */
-static inline size_t quic_cid_saddr_cat(struct quic_cid *cid,
- struct sockaddr_storage *saddr)
-{
- void *port, *addr;
- size_t port_len, addr_len;
-
- cid->addrlen = 0;
-
- if (saddr->ss_family == AF_INET6) {
- port = &((struct sockaddr_in6 *)saddr)->sin6_port;
- addr = &((struct sockaddr_in6 *)saddr)->sin6_addr;
- port_len = sizeof ((struct sockaddr_in6 *)saddr)->sin6_port;
- addr_len = sizeof ((struct sockaddr_in6 *)saddr)->sin6_addr;
- }
- else {
- port = &((struct sockaddr_in *)saddr)->sin_port;
- addr = &((struct sockaddr_in *)saddr)->sin_addr;
- port_len = sizeof ((struct sockaddr_in *)saddr)->sin_port;
- addr_len = sizeof ((struct sockaddr_in *)saddr)->sin_addr;
- }
-
- memcpy(cid->data + cid->len, port, port_len);
- cid->addrlen += port_len;
- memcpy(cid->data + cid->len + port_len, addr, addr_len);
- cid->addrlen += addr_len;
-
- return port_len + addr_len;
-}
-
-
/* Dump the QUIC connection ID value if present (non null length). Used only for
* debugging purposes.
* Always succeeds.
diff --git a/src/quic_conn.c b/src/quic_conn.c
index 268368f..06cbcdb 100644
--- a/src/quic_conn.c
+++ b/src/quic_conn.c
@@ -5421,10 +5421,9 @@
&quic_stats_module);
qc->flags |= QUIC_FL_CONN_LISTENER;
qc->state = QUIC_HS_ST_SERVER_INITIAL;
- /* Copy the initial DCID with the address. */
+ /* Copy the client original DCID. */
qc->odcid.len = dcid->len;
- qc->odcid.addrlen = dcid->addrlen;
- memcpy(qc->odcid.data, dcid->data, dcid->len + dcid->addrlen);
+ memcpy(qc->odcid.data, dcid->data, dcid->len);
/* copy the packet SCID to reuse it as DCID for sending */
if (scid->len)
@@ -8165,9 +8164,6 @@
struct ebmb_node *node;
struct quic_connection_id *id;
- /* For ODCID, address is concatenated to it after qc.odcid.len so this
- * comparison is safe.
- */
if ((qc->scid.len == dcid_len &&
memcmp(qc->scid.data, dcid, dcid_len) == 0) ||
(qc->odcid.len == dcid_len &&