Hash tables for cache RBTs cannot 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 maxhashsize
field of a given
dns_rbt_t
structure is set to any value lower than
RBT_HASH_MAX_BITS
.
To reproduce, start named
with max-cache-size 1G;
in named.conf
,
take note of its memory use, then change max-cache-size
to 10G
and
run rndc reconfig
; memory use will not increase significantly, proving
that the hash table was not resized according to the new value of
max-cache-size
.
Found while working on #2279 (closed).