]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: connection: use uint64_t for the hashes
authorWilly Tarreau <w@1wt.eu>
Wed, 6 Oct 2021 15:09:41 +0000 (17:09 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 6 Oct 2021 23:41:14 +0000 (01:41 +0200)
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.

include/haproxy/connection-t.h
include/haproxy/connection.h
src/connection.c

index 4e4b65ee87784e801cf2fdb6def83e9e10d7683d..0372ebfcdca603284d548f7a8b739d2cc0afc243 100644 (file)
@@ -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 @@ enum conn_hash_params_t {
  * 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.
index bd809e12881ec6dd86ea9fe0fccdb79d8a1c5da2..a50b0bb4f7815eceaacaf598f33cd2fce63832d5 100644 (file)
@@ -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 @@ static inline int conn_upgrade_mux_fe(struct connection *conn, void *ctx, struct
 /* 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 @@ static inline void conn_hash_update(char *buf, size_t *idx,
        *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);
 }
index eaee3191a75813f0802035e50b6e288d95f58466..2e734f7246c5e3882d71f35b49aee9895f461e2f 100644 (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;
        size_t idx = 0;
-       XXH64_hash_t hash = 0;
+       uint64_t hash = 0;
        enum conn_hash_params_t hash_flags = 0;
 
        buf = trash.area;