MEDIUM: xxhash: use the XXH3 functions to generate 64-bit hashes

Replace the XXH64() function calls with the XXH3 variant function
XXH3_64bits_withSeed() where possible.
This commit is contained in:
Dragan Dosen 2020-12-22 13:22:34 +01:00 committed by Willy Tarreau
parent de37443e64
commit 967e7e79af
4 changed files with 19 additions and 12 deletions

View File

@ -254,6 +254,13 @@ typedef struct { } empty_t;
*/
#define MAX_SEND_FD 253
/* Make the new complex name for the xxhash function easier to remember
* and use.
*/
#ifndef XXH3
#define XXH3(data, len, seed) XXH3_64bits_withSeed(data, len, seed)
#endif
#endif /* _HAPROXY_COMPAT_H */
/*

View File

@ -305,9 +305,9 @@ unsigned long long _51d_req_hash(const struct arg *args, fiftyoneDegreesWorkset*
int i;
for(i = 0; i < ws->importantHeadersCount; i++) {
hash ^= ws->importantHeaders[i].header->headerNameOffset;
hash ^= XXH64(ws->importantHeaders[i].headerValue,
ws->importantHeaders[i].headerValueLength,
seed);
hash ^= XXH3(ws->importantHeaders[i].headerValue,
ws->importantHeaders[i].headerValueLength,
seed);
}
return hash;
}
@ -517,7 +517,7 @@ static int _51d_conv(const struct arg *args, struct sample *smp, void *private)
unsigned long long seed = _51d_lru_seed ^ (long)args;
HA_SPIN_LOCK(OTHER_LOCK, &_51d_lru_lock);
lru = lru64_get(XXH64(smp->data.u.str.area, smp->data.u.str.data, seed),
lru = lru64_get(XXH3(smp->data.u.str.area, smp->data.u.str.data, seed),
_51d_lru_tree, (void*)args, 0);
if (lru && lru->domain) {
_51d_retrieve_cache_entry(smp, lru);

View File

@ -494,7 +494,7 @@ struct pattern *pat_match_str(struct sample *smp, struct pattern_expr *expr, int
if (pat_lru_tree) {
unsigned long long seed = pat_lru_seed ^ (long)expr;
lru = lru64_get(XXH64(smp->data.u.str.area, smp->data.u.str.data, seed),
lru = lru64_get(XXH3(smp->data.u.str.area, smp->data.u.str.data, seed),
pat_lru_tree, expr, expr->ref->revision);
if (lru && lru->domain) {
ret = lru->data;
@ -537,7 +537,7 @@ struct pattern *pat_match_bin(struct sample *smp, struct pattern_expr *expr, int
if (pat_lru_tree) {
unsigned long long seed = pat_lru_seed ^ (long)expr;
lru = lru64_get(XXH64(smp->data.u.str.area, smp->data.u.str.data, seed),
lru = lru64_get(XXH3(smp->data.u.str.area, smp->data.u.str.data, seed),
pat_lru_tree, expr, expr->ref->revision);
if (lru && lru->domain) {
ret = lru->data;
@ -606,7 +606,7 @@ struct pattern *pat_match_reg(struct sample *smp, struct pattern_expr *expr, int
if (pat_lru_tree) {
unsigned long long seed = pat_lru_seed ^ (long)expr;
lru = lru64_get(XXH64(smp->data.u.str.area, smp->data.u.str.data, seed),
lru = lru64_get(XXH3(smp->data.u.str.area, smp->data.u.str.data, seed),
pat_lru_tree, expr, expr->ref->revision);
if (lru && lru->domain) {
ret = lru->data;
@ -689,7 +689,7 @@ struct pattern *pat_match_beg(struct sample *smp, struct pattern_expr *expr, int
if (pat_lru_tree) {
unsigned long long seed = pat_lru_seed ^ (long)expr;
lru = lru64_get(XXH64(smp->data.u.str.area, smp->data.u.str.data, seed),
lru = lru64_get(XXH3(smp->data.u.str.area, smp->data.u.str.data, seed),
pat_lru_tree, expr, expr->ref->revision);
if (lru && lru->domain) {
ret = lru->data;
@ -733,7 +733,7 @@ struct pattern *pat_match_end(struct sample *smp, struct pattern_expr *expr, int
if (pat_lru_tree) {
unsigned long long seed = pat_lru_seed ^ (long)expr;
lru = lru64_get(XXH64(smp->data.u.str.area, smp->data.u.str.data, seed),
lru = lru64_get(XXH3(smp->data.u.str.area, smp->data.u.str.data, seed),
pat_lru_tree, expr, expr->ref->revision);
if (lru && lru->domain) {
ret = lru->data;
@ -781,7 +781,7 @@ struct pattern *pat_match_sub(struct sample *smp, struct pattern_expr *expr, int
if (pat_lru_tree) {
unsigned long long seed = pat_lru_seed ^ (long)expr;
lru = lru64_get(XXH64(smp->data.u.str.area, smp->data.u.str.data, seed),
lru = lru64_get(XXH3(smp->data.u.str.area, smp->data.u.str.data, seed),
pat_lru_tree, expr, expr->ref->revision);
if (lru && lru->domain) {
ret = lru->data;

View File

@ -6242,7 +6242,7 @@ int ssl_load_global_issuer_from_BIO(BIO *in, char *fp, char **err)
memprintf(err, "unable to load issuers-chain %s : SubjectName not found.\n", fp);
goto end;
}
key = XXH64(ASN1_STRING_get0_data(skid), ASN1_STRING_length(skid), 0);
key = XXH3(ASN1_STRING_get0_data(skid), ASN1_STRING_length(skid), 0);
for (node = eb64_lookup(&cert_issuer_tree, key); node; node = eb64_next(node)) {
issuer = container_of(node, typeof(*issuer), node);
if (!X509_NAME_cmp(name, X509_get_subject_name(sk_X509_value(issuer->chain, 0)))) {
@ -6280,7 +6280,7 @@ int ssl_load_global_issuer_from_BIO(BIO *in, char *fp, char **err)
if (akid && akid->keyid) {
struct eb64_node *node;
u64 hk;
hk = XXH64(ASN1_STRING_get0_data(akid->keyid), ASN1_STRING_length(akid->keyid), 0);
hk = XXH3(ASN1_STRING_get0_data(akid->keyid), ASN1_STRING_length(akid->keyid), 0);
for (node = eb64_lookup(&cert_issuer_tree, hk); node; node = eb64_next(node)) {
struct issuer_chain *ti = container_of(node, typeof(*issuer), node);
if (X509_check_issued(sk_X509_value(ti->chain, 0), cert) == X509_V_OK) {