@@ -23,6 +23,9 @@
/* We target a hash table size of 4, element hint is 75% of final size */
#define NFT_HASH_ELEMENT_HINT 3
+/* Default max number of elements if user doesn't specify a size */
+#define NFT_HASH_MAX_ELEMENTS 10
+
struct nft_hash_elem {
struct rhash_head node;
struct nft_data key;
@@ -194,6 +197,8 @@ static int nft_hash_init(const struct nft_set *set,
.hashfn = jhash,
.grow_decision = rht_grow_above_75,
.shrink_decision = rht_shrink_below_30,
+ .max_shift = desc->size ?
+ roundup_pow_of_two(desc->size) : NFT_HASH_MAX_ELEMENTS,
};
return rhashtable_init(priv, ¶ms);
Starting with commit "rhashtable: require max_shift definition" all users of rhashtable must define a max_shift value to set an upper bound the table can grow to. nft sets presently use nft_set_desc.size to enforce a limit on the size a set can grow. Use this value to also set the ceiling for rhashtables. If a user doesn't define a size it will fall back to a newly defined default of 10 (1024 elements.) Signed-off-by: Josh Hunt <johunt@akamai.com> --- net/netfilter/nft_hash.c | 5 +++++ 1 file changed, 5 insertions(+)