mirror of
http://git.haproxy.org/git/haproxy.git
synced 2026-02-14 13:29:07 +02:00
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.
This commit is contained in:
@@ -282,9 +282,8 @@ extern const struct quic_version *preferred_version;
|
||||
* <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 @@ struct quic_conn {
|
||||
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 */
|
||||
|
||||
@@ -120,42 +120,6 @@ static inline size_t quic_saddr_cpy(unsigned char *buf,
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user