From: Michał Kępień Date: Thu, 17 Jun 2021 15:09:37 +0000 (+0200) Subject: Allow hash tables for cache RBTs to be grown X-Git-Tag: v9.17.16~31^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c096f9145122e3cf1fc6068b6c76c24abd3d3cbc;p=thirdparty%2Fbind9.git Allow hash tables for cache RBTs to be grown Upon creation, each dns_rbt_t structure has its "maxhashbits" field initialized to the value of the RBT_HASH_MAX_BITS preprocessor macro, i.e. 32. When the dns_rbt_adjusthashsize() function is called for the first time for a given RBT (for cache RBTs, this happens when they are first created, i.e. upon named startup), it lowers the value of the "maxhashbits" field to the number of bits required to index the requested number of hash table slots. When a larger hash table size is subsequently requested, the value of the "maxhashbits" field should be increased accordingly, up to RBT_HASH_MAX_BITS. However, the loop in the rehash_bits() function currently ensures that the number of bits necessary to index the resized hash table will not be larger than rbt->maxhashbits instead of RBT_HASH_MAX_BITS, preventing the hash table from being grown once the "maxhashbits" field of a given dns_rbt_t structure is set to any value lower than RBT_HASH_MAX_BITS. Fix by tweaking the loop guard condition in the rehash_bits() function so that it compares the new number of bits used for indexing the hash table against RBT_HASH_MAX_BITS rather than rbt->maxhashbits. --- diff --git a/lib/dns/rbt.c b/lib/dns/rbt.c index 03ec0993cec..a42b7d08fff 100644 --- a/lib/dns/rbt.c +++ b/lib/dns/rbt.c @@ -2337,7 +2337,7 @@ static uint32_t rehash_bits(dns_rbt_t *rbt, size_t newcount) { uint32_t newbits = rbt->hashbits; - while (newcount >= HASHSIZE(newbits) && newbits < rbt->maxhashbits) { + while (newcount >= HASHSIZE(newbits) && newbits < RBT_HASH_MAX_BITS) { newbits += 1; }