diff --git a/include/haproxy/quic_conn-t.h b/include/haproxy/quic_conn-t.h index f6a962984..fdeb9dad3 100644 --- a/include/haproxy/quic_conn-t.h +++ b/include/haproxy/quic_conn-t.h @@ -282,9 +282,8 @@ extern const struct quic_version *preferred_version; * 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. - * 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 8342c9baf..568911052 100644 --- a/include/haproxy/quic_conn.h +++ b/include/haproxy/quic_conn.h @@ -120,42 +120,6 @@ static inline size_t quic_saddr_cpy(unsigned char *buf, return p - buf; } -/* Concatenate the port and address of to QUIC connection ID. The - * field of will be updated with the size of the concatenated - * address. - * - * Returns the number of bytes concatenated to . - */ -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 268368f5b..06cbcdba7 100644 --- a/src/quic_conn.c +++ b/src/quic_conn.c @@ -5421,10 +5421,9 @@ static struct quic_conn *qc_new_conn(const struct quic_version *qv, int ipv4, &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 @@ int qc_check_dcid(struct quic_conn *qc, unsigned char *dcid, size_t dcid_len) 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 &&