mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 22:15:20 +00:00
Merge branch 'ondrej/squash-dns_name_fullhash-and-dns_name_hash' into 'main'
Squash dns_name_fullhash() and dns_name_hash() See merge request isc-projects/bind9!7759
This commit is contained in:
@@ -229,7 +229,7 @@ dns_badcache_add(dns_badcache_t *bc, const dns_name_t *name,
|
||||
isc_time_settoepoch(&now);
|
||||
}
|
||||
|
||||
hashval = dns_name_hash(name, false);
|
||||
hashval = dns_name_hash(name);
|
||||
hash = hashval % bc->size;
|
||||
LOCK(&bc->tlocks[hash]);
|
||||
prev = NULL;
|
||||
@@ -318,7 +318,7 @@ dns_badcache_find(dns_badcache_t *bc, const dns_name_t *name,
|
||||
goto skip;
|
||||
}
|
||||
|
||||
hash = dns_name_hash(name, false) % bc->size;
|
||||
hash = dns_name_hash(name) % bc->size;
|
||||
prev = NULL;
|
||||
LOCK(&bc->tlocks[hash]);
|
||||
for (bad = bc->table[hash]; bad != NULL; bad = next) {
|
||||
@@ -402,7 +402,7 @@ dns_badcache_flushname(dns_badcache_t *bc, const dns_name_t *name) {
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_time_settoepoch(&now);
|
||||
}
|
||||
hash = dns_name_hash(name, false) % bc->size;
|
||||
hash = dns_name_hash(name) % bc->size;
|
||||
LOCK(&bc->tlocks[hash]);
|
||||
prev = NULL;
|
||||
for (bad = bc->table[hash]; bad != NULL; bad = next) {
|
||||
|
@@ -341,29 +341,14 @@ dns_name_iswildcard(const dns_name_t *name);
|
||||
* \li FALSE The least significant label of 'name' is not '*'.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
dns_name_hash(const dns_name_t *name, bool case_sensitive);
|
||||
uint32_t
|
||||
dns_name_hash(const dns_name_t *name);
|
||||
/*%<
|
||||
* Provide a hash value for 'name'.
|
||||
*
|
||||
* Note: if 'case_sensitive' is false, then names which differ only in
|
||||
* case will have the same hash value.
|
||||
*
|
||||
* Requires:
|
||||
* \li 'name' is a valid name
|
||||
*
|
||||
* Returns:
|
||||
* \li A hash value
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
dns_name_fullhash(const dns_name_t *name, bool case_sensitive);
|
||||
/*%<
|
||||
* Provide a hash value for 'name'. Unlike dns_name_hash(), this function
|
||||
* always takes into account of the entire name to calculate the hash value.
|
||||
*
|
||||
* Note: if 'case_sensitive' is false, then names which differ only in
|
||||
* case will have the same hash value.
|
||||
* Note: This function always takes into account of the entire name to calculate
|
||||
* the hash value. The names which differ only in case will have the same hash
|
||||
* value.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'name' is a valid name
|
||||
|
@@ -397,39 +397,11 @@ dns_name_internalwildcard(const dns_name_t *name) {
|
||||
return (false);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
dns_name_hash(const dns_name_t *name, bool case_sensitive) {
|
||||
unsigned int length;
|
||||
|
||||
/*
|
||||
* Provide a hash value for 'name'.
|
||||
*/
|
||||
uint32_t
|
||||
dns_name_hash(const dns_name_t *name) {
|
||||
REQUIRE(VALID_NAME(name));
|
||||
|
||||
if (name->labels == 0) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
length = name->length;
|
||||
if (length > 16) {
|
||||
length = 16;
|
||||
}
|
||||
|
||||
return (isc_hash32(name->ndata, length, case_sensitive));
|
||||
}
|
||||
|
||||
unsigned int
|
||||
dns_name_fullhash(const dns_name_t *name, bool case_sensitive) {
|
||||
/*
|
||||
* Provide a hash value for 'name'.
|
||||
*/
|
||||
REQUIRE(VALID_NAME(name));
|
||||
|
||||
if (name->labels == 0) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (isc_hash32(name->ndata, name->length, case_sensitive));
|
||||
return (isc_hash32(name->ndata, name->length, false));
|
||||
}
|
||||
|
||||
dns_namereln_t
|
||||
|
@@ -872,7 +872,7 @@ dns__rbt_findnode(dns_rbt_t *rbt, const dns_name_t *name, dns_name_t *foundname,
|
||||
dns_name_getlabelsequence(name, nlabels - tlabels,
|
||||
hlabels + tlabels,
|
||||
&hash_name);
|
||||
hashval = dns_name_fullhash(&hash_name, false);
|
||||
hashval = dns_name_hash(&hash_name);
|
||||
|
||||
dns_name_getlabelsequence(search_name,
|
||||
nlabels - tlabels, tlabels,
|
||||
@@ -1569,7 +1569,7 @@ hash_add_node(dns_rbt_t *rbt, dns_rbtnode_t *node, const dns_name_t *name) {
|
||||
|
||||
REQUIRE(name != NULL);
|
||||
|
||||
node->hashval = dns_name_fullhash(name, false);
|
||||
node->hashval = dns_name_hash(name);
|
||||
|
||||
hash = isc_hash_bits32(node->hashval, rbt->hashbits[rbt->hindex]);
|
||||
node->hashnext = rbt->hashtable[rbt->hindex][hash];
|
||||
|
@@ -459,9 +459,9 @@ make_key(const dns_rrl_t *rrl, dns_rrl_key_t *key,
|
||||
*/
|
||||
wild = origin;
|
||||
}
|
||||
key->s.qname_hash = dns_name_fullhash(wild, false);
|
||||
key->s.qname_hash = dns_name_hash(wild);
|
||||
} else {
|
||||
key->s.qname_hash = dns_name_fullhash(qname, false);
|
||||
key->s.qname_hash = dns_name_hash(qname);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -629,8 +629,8 @@ ISC_RUN_TEST_IMPL(hash) {
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
/* Check case-insensitive hashing first */
|
||||
h1 = dns_name_hash(n1, false);
|
||||
h2 = dns_name_hash(n2, false);
|
||||
h1 = dns_name_hash(n1);
|
||||
h2 = dns_name_hash(n2);
|
||||
|
||||
if (verbose) {
|
||||
print_message("# %s hashes to %u, "
|
||||
@@ -642,8 +642,8 @@ ISC_RUN_TEST_IMPL(hash) {
|
||||
assert_int_equal((h1 == h2), testcases[i].expect);
|
||||
|
||||
/* Now case-sensitive */
|
||||
h1 = dns_name_hash(n1, false);
|
||||
h2 = dns_name_hash(n2, false);
|
||||
h1 = dns_name_hash(n1);
|
||||
h2 = dns_name_hash(n2);
|
||||
|
||||
if (verbose) {
|
||||
print_message("# %s hashes to %u, "
|
||||
|
Reference in New Issue
Block a user