Skip to content

[v9_16] 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.

(cherry picked from commit c096f914)

Closes #2770 (closed)

Merge request reports