[PATCH v3 0/2] nft hash resize fixes

Subsystems: library code, netfilter, networking [general], rhashtable, the rest · Maintainers: Andrew Morton, Pablo Neira Ayuso, Florian Westphal, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Thomas Graf, Herbert Xu, Linus Torvalds

Series: 2 patches touching 2 files, +6/-1

STALE4263d SUPERSEDED

Status: Superseded by v4 (posted 2015-02-24). [go to v4]

Revision v3 (3 revisions archived).

Revisions (3)
  1. v2
  2. v3 current [diff against previous]
  3. v4 [diff against previous]

5 messages, 2 authors, 2015-02-24 · open the first message on its own page

[PATCH v3 0/2] nft hash resize fixes

From: Josh Hunt <hidden>
Date: 2015-02-24 17:25:38

v3:
 * Renames NFT_HASH_MAX_ELEMENTS to NFT_HASH_MAX_BUCKETS
 * Add Acked-by for Thomas

Josh Hunt (2):
  rhashtable: require max_shift if grow_decision defined
  nft_hash: define max_shift rhashtable parameter

 lib/rhashtable.c         |    3 ++-
 net/netfilter/nft_hash.c |    4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

-- 
1.7.9.5

[PATCH v3 1/2] rhashtable: require max_shift if grow_decision defined

From: Josh Hunt <hidden>
Date: 2015-02-24 17:25:35

If an rhashtable user defines a grow_decision fn they must also define a
max_shift parameter.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Josh Hunt <redacted>
---
 lib/rhashtable.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/rhashtable.c b/lib/rhashtable.c
index 9cc4c4a..7d6f539 100644
--- a/lib/rhashtable.c
+++ b/lib/rhashtable.c
@@ -1077,7 +1077,8 @@ int rhashtable_init(struct rhashtable *ht, struct rhashtable_params *params)
 	size = HASH_DEFAULT_SIZE;
 
 	if ((params->key_len && !params->hashfn) ||
-	    (!params->key_len && !params->obj_hashfn))
+	    (!params->key_len && !params->obj_hashfn) ||
+	    (params->grow_decision && !params->max_shift))
 		return -EINVAL;
 
 	if (params->nulls_base && params->nulls_base < (1U << RHT_BASE_SHIFT))
-- 
1.7.9.5

[PATCH v3 2/2] nft_hash: define max_shift rhashtable parameter

From: Josh Hunt <hidden>
Date: 2015-02-24 17:25:36

You must define a max_shift parameter to rhashtable or else the table cannot
grow. This sets max_shift for nft_hash to 24, which will allow the table to
grow to 2^24 or 16 million buckets.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Josh Hunt <redacted>
---
 net/netfilter/nft_hash.c |    4 ++++
 1 file changed, 4 insertions(+)
diff --git a/net/netfilter/nft_hash.c b/net/netfilter/nft_hash.c
index 61e6c40..a32df35 100644
--- a/net/netfilter/nft_hash.c
+++ b/net/netfilter/nft_hash.c
@@ -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
 
+/* Set default of 2^24 buckets or 16 million entries */
+#define NFT_HASH_MAX_BUCKETS 24
+
 struct nft_hash_elem {
 	struct rhash_head		node;
 	struct nft_data			key;
@@ -192,6 +195,7 @@ static int nft_hash_init(const struct nft_set *set,
 		.key_offset = offsetof(struct nft_hash_elem, key),
 		.key_len = set->klen,
 		.hashfn = jhash,
+		.max_shift = NFT_HASH_MAX_BUCKETS,
 		.grow_decision = rht_grow_above_75,
 		.shrink_decision = rht_shrink_below_30,
 	};
-- 
1.7.9.5

Re: [PATCH v3 0/2] nft hash resize fixes

From: Nicolas Dichtel <hidden>
Date: 2015-02-24 17:35:32

Le 24/02/2015 18:25, Josh Hunt a écrit :
v3:
  * Renames NFT_HASH_MAX_ELEMENTS to NFT_HASH_MAX_BUCKETS
  * Add Acked-by for Thomas

Josh Hunt (2):
   rhashtable: require max_shift if grow_decision defined
   nft_hash: define max_shift rhashtable parameter
Patches should be inverted to avoid breaking bisection.

Re: [PATCH v3 0/2] nft hash resize fixes

From: Josh Hunt <hidden>
Date: 2015-02-24 17:42:35

On 02/24/2015 11:35 AM, Nicolas Dichtel wrote:
Le 24/02/2015 18:25, Josh Hunt a écrit :
quoted
v3:
  * Renames NFT_HASH_MAX_ELEMENTS to NFT_HASH_MAX_BUCKETS
  * Add Acked-by for Thomas

Josh Hunt (2):
   rhashtable: require max_shift if grow_decision defined
   nft_hash: define max_shift rhashtable parameter
Patches should be inverted to avoid breaking bisection.
Agreed. Will fix in next rev.

Josh
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help