diff options
author | Pablo Neira Ayuso | 2016-12-05 23:35:49 +0100 |
---|---|---|
committer | Pablo Neira Ayuso | 2016-12-07 13:31:02 +0100 |
commit | 37df5301a3ae903c5b1aa90cae37c6c669dfc386 (patch) | |
tree | dfaf6fdbc51c03f4f788a825d643fa85d7b9a3d2 /net/netfilter/nft_set_hash.c | |
parent | netfilter: nf_tables: constify struct nft_ctx * parameter in nft_trans_alloc() (diff) | |
download | kernel-qcow2-linux-37df5301a3ae903c5b1aa90cae37c6c669dfc386.tar.gz kernel-qcow2-linux-37df5301a3ae903c5b1aa90cae37c6c669dfc386.tar.xz kernel-qcow2-linux-37df5301a3ae903c5b1aa90cae37c6c669dfc386.zip |
netfilter: nft_set: introduce nft_{hash, rbtree}_deactivate_one()
This new function allows us to deactivate one single element, this is
required by the set flush command that comes in a follow up patch.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/netfilter/nft_set_hash.c')
-rw-r--r-- | net/netfilter/nft_set_hash.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/net/netfilter/nft_set_hash.c b/net/netfilter/nft_set_hash.c index a3dface3e6e6..73f7687c5656 100644 --- a/net/netfilter/nft_set_hash.c +++ b/net/netfilter/nft_set_hash.c @@ -167,6 +167,19 @@ static void nft_hash_activate(const struct net *net, const struct nft_set *set, nft_set_elem_clear_busy(&he->ext); } +static bool nft_hash_deactivate_one(const struct net *net, + const struct nft_set *set, void *priv) +{ + struct nft_hash_elem *he = priv; + + if (!nft_set_elem_mark_busy(&he->ext) || + !nft_is_active(net, &he->ext)) { + nft_set_elem_change_active(net, set, &he->ext); + return true; + } + return false; +} + static void *nft_hash_deactivate(const struct net *net, const struct nft_set *set, const struct nft_set_elem *elem) @@ -181,13 +194,10 @@ static void *nft_hash_deactivate(const struct net *net, rcu_read_lock(); he = rhashtable_lookup_fast(&priv->ht, &arg, nft_hash_params); - if (he != NULL) { - if (!nft_set_elem_mark_busy(&he->ext) || - !nft_is_active(net, &he->ext)) - nft_set_elem_change_active(net, set, &he->ext); - else - he = NULL; - } + if (he != NULL && + !nft_hash_deactivate_one(net, set, he)) + he = NULL; + rcu_read_unlock(); return he; |