aboutsummaryrefslogtreecommitdiffstats
path: root/net/netfilter
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2015-01-02 17:00:16 -0500
committerDavid S. Miller <davem@davemloft.net>2015-01-03 14:32:56 -0500
commit88d6ed15acff1cb44b1d1f3c0a393b7f7744957a (patch)
treeee25a48f8ab11d06c062480c89ba1e96c8113e57 /net/netfilter
parenta4b18cda4c2676a4b4b59622b2e0394dc153e00b (diff)
rhashtable: Convert bucket iterators to take table and index
This patch is in preparation to introduce per bucket spinlocks. It extends all iterator macros to take the bucket table and bucket index. It also introduces a new rht_dereference_bucket() to handle protected accesses to buckets. It introduces a barrier() to the RCU iterators to the prevent the compiler from caching the first element. The lockdep verifier is introduced as stub which always succeeds and properly implement in the next patch when the locks are introduced. Signed-off-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netfilter')
-rw-r--r--net/netfilter/nft_hash.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/net/netfilter/nft_hash.c b/net/netfilter/nft_hash.c
index 614ee099ba36..d93f1f4c22a9 100644
--- a/net/netfilter/nft_hash.c
+++ b/net/netfilter/nft_hash.c
@@ -142,7 +142,9 @@ static void nft_hash_walk(const struct nft_ctx *ctx, const struct nft_set *set,
142 142
143 tbl = rht_dereference_rcu(priv->tbl, priv); 143 tbl = rht_dereference_rcu(priv->tbl, priv);
144 for (i = 0; i < tbl->size; i++) { 144 for (i = 0; i < tbl->size; i++) {
145 rht_for_each_entry_rcu(he, tbl->buckets[i], node) { 145 struct rhash_head *pos;
146
147 rht_for_each_entry_rcu(he, pos, tbl, i, node) {
146 if (iter->count < iter->skip) 148 if (iter->count < iter->skip)
147 goto cont; 149 goto cont;
148 150
@@ -197,15 +199,13 @@ static void nft_hash_destroy(const struct nft_set *set)
197{ 199{
198 const struct rhashtable *priv = nft_set_priv(set); 200 const struct rhashtable *priv = nft_set_priv(set);
199 const struct bucket_table *tbl = priv->tbl; 201 const struct bucket_table *tbl = priv->tbl;
200 struct nft_hash_elem *he, *next; 202 struct nft_hash_elem *he;
203 struct rhash_head *pos, *next;
201 unsigned int i; 204 unsigned int i;
202 205
203 for (i = 0; i < tbl->size; i++) { 206 for (i = 0; i < tbl->size; i++) {
204 for (he = rht_entry(tbl->buckets[i], struct nft_hash_elem, node); 207 rht_for_each_entry_safe(he, pos, next, tbl, i, node)
205 he != NULL; he = next) {
206 next = rht_entry(he->node.next, struct nft_hash_elem, node);
207 nft_hash_elem_destroy(set, he); 208 nft_hash_elem_destroy(set, he);
208 }
209 } 209 }
210 rhashtable_destroy(priv); 210 rhashtable_destroy(priv);
211} 211}