MINOR: connection: use uint64_t for the hashes

The hash type stored everywhere is XXH64_hash_t, which annoyingly forces
everyone to include the huge xxhash file. We know it's an uint64_t because
that's its purpose and the type is only made to abstract it on machines
where uint64_t is not availble. Let's switch the type to uint64_t
everywhere and avoid including xxhash from the type file.
This commit is contained in:
Willy Tarreau 2021-10-06 17:09:41 +02:00
parent 74f9817565
commit fd21c6c6fd
3 changed files with 10 additions and 10 deletions

View File

@ -37,7 +37,6 @@
#include <haproxy/port_range-t.h> #include <haproxy/port_range-t.h>
#include <haproxy/protocol-t.h> #include <haproxy/protocol-t.h>
#include <haproxy/thread-t.h> #include <haproxy/thread-t.h>
#include <haproxy/xxhash.h>
/* referenced below */ /* referenced below */
struct connection; struct connection;
@ -519,11 +518,11 @@ enum conn_hash_params_t {
* connection hash. * connection hash.
*/ */
struct conn_hash_params { struct conn_hash_params {
uint64_t sni_prehash;
uint64_t proxy_prehash;
void *target; void *target;
XXH64_hash_t sni_prehash;
struct sockaddr_storage *src_addr; struct sockaddr_storage *src_addr;
struct sockaddr_storage *dst_addr; struct sockaddr_storage *dst_addr;
XXH64_hash_t proxy_prehash;
}; };
/* This structure describes a connection with its methods and data. /* This structure describes a connection with its methods and data.

View File

@ -37,6 +37,7 @@
#include <haproxy/session.h> #include <haproxy/session.h>
#include <haproxy/task-t.h> #include <haproxy/task-t.h>
#include <haproxy/tcpcheck-t.h> #include <haproxy/tcpcheck-t.h>
#include <haproxy/xxhash.h>
extern struct pool_head *pool_head_connection; extern struct pool_head *pool_head_connection;
@ -1197,9 +1198,9 @@ static inline int conn_upgrade_mux_fe(struct connection *conn, void *ctx, struct
/* Generate the hash of a connection with params as input /* Generate the hash of a connection with params as input
* Each non-null field of params is taken into account for the hash calcul. * Each non-null field of params is taken into account for the hash calcul.
*/ */
XXH64_hash_t conn_calculate_hash(const struct conn_hash_params *params); uint64_t conn_calculate_hash(const struct conn_hash_params *params);
static inline XXH64_hash_t conn_hash_prehash(char *buf, size_t size) static inline uint64_t conn_hash_prehash(char *buf, size_t size)
{ {
return XXH64(buf, size, 0); return XXH64(buf, size, 0);
} }
@ -1218,11 +1219,11 @@ static inline void conn_hash_update(char *buf, size_t *idx,
*flags |= type; *flags |= type;
} }
static inline XXH64_hash_t conn_hash_digest(char *buf, size_t bufsize, static inline uint64_t conn_hash_digest(char *buf, size_t bufsize,
enum conn_hash_params_t flags) enum conn_hash_params_t flags)
{ {
const uint64_t flags_u64 = (uint64_t)flags; const uint64_t flags_u64 = (uint64_t)flags;
const XXH64_hash_t hash = XXH64(buf, bufsize, 0); const uint64_t hash = XXH64(buf, bufsize, 0);
return (flags_u64 << CONN_HASH_PAYLOAD_LEN) | CONN_HASH_GET_PAYLOAD(hash); return (flags_u64 << CONN_HASH_PAYLOAD_LEN) | CONN_HASH_GET_PAYLOAD(hash);
} }

View File

@ -1627,11 +1627,11 @@ static void conn_calculate_hash_sockaddr(const struct sockaddr_storage *ss,
} }
} }
XXH64_hash_t conn_calculate_hash(const struct conn_hash_params *params) uint64_t conn_calculate_hash(const struct conn_hash_params *params)
{ {
char *buf; char *buf;
size_t idx = 0; size_t idx = 0;
XXH64_hash_t hash = 0; uint64_t hash = 0;
enum conn_hash_params_t hash_flags = 0; enum conn_hash_params_t hash_flags = 0;
buf = trash.area; buf = trash.area;