diff --git a/lib/dns/badcache.c b/lib/dns/badcache.c index 274ef9b55b..873e328360 100644 --- a/lib/dns/badcache.c +++ b/lib/dns/badcache.c @@ -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) { diff --git a/lib/dns/include/dns/name.h b/lib/dns/include/dns/name.h index 9e3a5191b5..e079a59a1e 100644 --- a/lib/dns/include/dns/name.h +++ b/lib/dns/include/dns/name.h @@ -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 diff --git a/lib/dns/name.c b/lib/dns/name.c index 039b9b17f5..3a44c1dc90 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -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 diff --git a/lib/dns/rbt.c b/lib/dns/rbt.c index a8f40dadb3..9109a9ce05 100644 --- a/lib/dns/rbt.c +++ b/lib/dns/rbt.c @@ -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]; diff --git a/lib/dns/rrl.c b/lib/dns/rrl.c index f48258ef93..3a4921b803 100644 --- a/lib/dns/rrl.c +++ b/lib/dns/rrl.c @@ -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); } } diff --git a/tests/dns/name_test.c b/tests/dns/name_test.c index a20eb79536..fa923fb6ec 100644 --- a/tests/dns/name_test.c +++ b/tests/dns/name_test.c @@ -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, "