Report information
The Basics
Id:
45435
Status:
resolved
Priority:
Medium/Medium
Queue:

People
BugTracker
Version Fixed:
9.12.0, 9.11.3, 9.10.7, 9.9.12
Version Found:
(no value)
Versions Affected:
(no value)
Versions Planned:
(no value)
Priority:
P2 Normal
Severity:
S2 Normal
CVSS Score:
(no value)
CVE ID:
(no value)
Component:
BIND Server
Area:
feature

Dates
Created:Wed, 21 Jun 2017 13:41:33 -0400
Updated:Fri, 08 Sep 2017 18:48:53 -0400
Closed:Fri, 08 Sep 2017 18:48:53 -0400



This bug tracker is no longer active.

Please go to our Gitlab to submit issues (both feature requests and bug reports) for active projects maintained by Internet Systems Consortium (ISC).

Due to security and confidentiality requirements, full access is limited to the primary maintainers.

CC: "Tony Finch" <dot@dotat.at>
Date: Wed, 21 Jun 2017 18:41:29 +0100
To: bind9-bugs@isc.org
From: "Tony Finch" <dot@dotat.at>
Subject: [PATCH] Deprecate dns_name_hashbylabel() since it isn't a very good hash.
The rbt stopped using it in 2004 (change 1740) and it was not used after that point until RRL started using it in 2013. I have left the entry points in place for backwards compatibility, though the hash values will be different. --- lib/dns/include/dns/name.h | 16 ---------------- lib/dns/name.c | 34 ++++------------------------------ lib/dns/rrl.c | 4 ++-- 3 files changed, 6 insertions(+), 48 deletions(-) diff --git a/lib/dns/include/dns/name.h b/lib/dns/include/dns/name.h index ab76458..346188e 100644 --- a/lib/dns/include/dns/name.h +++ b/lib/dns/include/dns/name.h @@ -349,22 +349,6 @@ dns_name_fullhash(const dns_name_t *name, isc_boolean_t case_sensitive); *\li A hash value */ -unsigned int -dns_name_hashbylabel(const dns_name_t *name, isc_boolean_t case_sensitive); -/*%< - * Provide a hash value for 'name', where the hash value is the sum - * of the hash values of each label. - * - * Note: if 'case_sensitive' is ISC_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 - */ - /* *** Comparisons ***/ diff --git a/lib/dns/name.c b/lib/dns/name.c index d07b5fc..b41740b 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -498,38 +498,12 @@ dns_fullname_hash(const dns_name_t *name, isc_boolean_t case_sensitive) { unsigned int dns_name_hashbylabel(const dns_name_t *name, isc_boolean_t case_sensitive) { - unsigned char *offsets; - dns_offsets_t odata; - dns_name_t tname; - unsigned int h = 0; - unsigned int i; - /* - * Provide a hash value for 'name'. + * This function was deprecated because of its poor performance. + * We only keep this internally to provide binary backward + * compatibility. */ - REQUIRE(VALID_NAME(name)); - - if (name->labels == 0) - return (0); - else if (name->labels == 1) - return (isc_hash_function_reverse(name->ndata, name->length, - case_sensitive, NULL)); - - SETUP_OFFSETS(name, offsets, odata); - DNS_NAME_INIT(&tname, NULL); - tname.labels = 1; - h = 0; - for (i = 0; i < name->labels; i++) { - tname.ndata = name->ndata + offsets[i]; - if (i == name->labels - 1) - tname.length = name->length - offsets[i]; - else - tname.length = offsets[i + 1] - offsets[i]; - h += isc_hash_function_reverse(tname.ndata, tname.length, - case_sensitive, NULL); - } - - return (h); + return (dns_name_fullhash(name, case_sensitive)); } dns_namereln_t diff --git a/lib/dns/rrl.c b/lib/dns/rrl.c index 252ebd8..53a86d3 100644 --- a/lib/dns/rrl.c +++ b/lib/dns/rrl.c @@ -417,10 +417,10 @@ make_key(const dns_rrl_t *rrl, dns_rrl_key_t *key, { dns_name_init(&base, base_offsets); dns_name_getlabelsequence(qname, 1, labels-1, &base); - key->s.qname_hash = dns_name_hashbylabel(&base, + key->s.qname_hash = dns_name_fullhash(&base, ISC_FALSE); } else { - key->s.qname_hash = dns_name_hashbylabel(qname, + key->s.qname_hash = dns_name_fullhash(qname, ISC_FALSE); } } -- 2.10.1.445.g3cdd5d1
To: "Tony Finch via RT" <bind9-confidential@isc.org>
Date: Mon, 14 Aug 2017 15:08:15 +0530
Subject: Re: [ISC-Bugs #45435] [PATCH] Deprecate dns_name_hashbylabel() since it isn't a very good hash.
From: "Mukund Sivaraman" <muks@isc.org>
Hi Tony On Wed, Jun 21, 2017 at 05:41:34PM +0000, Tony Finch via RT wrote: > The rbt stopped using it in 2004 (change 1740) and it was > not used after that point until RRL started using it in 2013. I'm keeping the dns_name_hashbylabel() function as-is, but have updated lib/dns/rrl.c to use dns_fullname_hash() as hashbylabel()'s use is not necessary there. > I have left the entry points in place for backwards compatibility, > though the hash values will be different. > + return (dns_name_fullhash(name, case_sensitive)); The two aren't equivalent. There's a thought to use something like this in rbt.c again to do incremental hashing during forest traversal. Mukund
From: "Mukund Sivaraman" <muks@isc.org>
Subject: Re: [ISC-Bugs #45435] [PATCH] Deprecate dns_name_hashbylabel() since it isn't a very good hash.
Date: Mon, 14 Aug 2017 15:12:44 +0530
To: "Mukund Sivaraman via RT" <bind9-public@isc.org>
On Mon, Aug 14, 2017 at 09:38:29AM +0000, Mukund Sivaraman via RT wrote: > Hi Tony > > On Wed, Jun 21, 2017 at 05:41:34PM +0000, Tony Finch via RT wrote: > > The rbt stopped using it in 2004 (change 1740) and it was > > not used after that point until RRL started using it in 2013. > > I'm keeping the dns_name_hashbylabel() function as-is, but have updated > lib/dns/rrl.c to use dns_fullname_hash() as hashbylabel()'s use is not s/dns_fullname_hash()/dns_name_fullhash()/ > necessary there. Mukund
Decided to go ahead and merge this: 4709. [cleanup] Use dns_name_fullhash() to hash names for RRL. [RT #45435] 9.12.0, 9.11.3, 9.10.7, 9.9.12