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.
diff --git a/include/haproxy/connection-t.h b/include/haproxy/connection-t.h
index 4e4b65e..0372ebf 100644
--- a/include/haproxy/connection-t.h
+++ b/include/haproxy/connection-t.h
@@ -37,7 +37,6 @@
#include <haproxy/port_range-t.h>
#include <haproxy/protocol-t.h>
#include <haproxy/thread-t.h>
-#include <haproxy/xxhash.h>
/* referenced below */
struct connection;
@@ -519,11 +518,11 @@
* connection hash.
*/
struct conn_hash_params {
+ uint64_t sni_prehash;
+ uint64_t proxy_prehash;
void *target;
- XXH64_hash_t sni_prehash;
struct sockaddr_storage *src_addr;
struct sockaddr_storage *dst_addr;
- XXH64_hash_t proxy_prehash;
};
/* This structure describes a connection with its methods and data.
diff --git a/include/haproxy/connection.h b/include/haproxy/connection.h
index bd809e1..a50b0bb 100644
--- a/include/haproxy/connection.h
+++ b/include/haproxy/connection.h
@@ -37,6 +37,7 @@
#include <haproxy/session.h>
#include <haproxy/task-t.h>
#include <haproxy/tcpcheck-t.h>
+#include <haproxy/xxhash.h>
extern struct pool_head *pool_head_connection;
@@ -1197,9 +1198,9 @@
/* Generate the hash of a connection with params as input
* 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);
}
@@ -1218,11 +1219,11 @@
*flags |= type;
}
-static inline XXH64_hash_t conn_hash_digest(char *buf, size_t bufsize,
- enum conn_hash_params_t flags)
+static inline uint64_t conn_hash_digest(char *buf, size_t bufsize,
+ enum conn_hash_params_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);
}
diff --git a/src/connection.c b/src/connection.c
index eaee319..2e734f7 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -1627,11 +1627,11 @@
}
}
-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;
size_t idx = 0;
- XXH64_hash_t hash = 0;
+ uint64_t hash = 0;
enum conn_hash_params_t hash_flags = 0;
buf = trash.area;