We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 85dfd81 commit a54754eCopy full SHA for a54754e
net/netfilter/nft_set_hash.c
@@ -412,9 +412,17 @@ static void nft_rhash_destroy(const struct nft_set *set)
412
(void *)set);
413
}
414
415
+/* Number of buckets is stored in u32, so cap our result to 1U<<31 */
416
+#define NFT_MAX_BUCKETS (1U << 31)
417
+
418
static u32 nft_hash_buckets(u32 size)
419
{
- return roundup_pow_of_two(size * 4 / 3);
420
+ u64 val = div_u64((u64)size * 4, 3);
421
422
+ if (val >= NFT_MAX_BUCKETS)
423
+ return NFT_MAX_BUCKETS;
424
425
+ return roundup_pow_of_two(val);
426
427
428
static bool nft_rhash_estimate(const struct nft_set_desc *desc, u32 features,
0 commit comments