Commit d4b7f29e authored by Florian Westphal's avatar Florian Westphal

netfilter: nf_tables: always increment set element count

At this time, set->nelems counter only increments when the set has
a maximum size.

All set elements decrement the counter unconditionally, this is
confusing.

Increment the counter unconditionally to make this symmetrical.
This would also allow changing the set maximum size after set creation
in a later patch.
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
parent a4878eea
...@@ -6541,10 +6541,13 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set, ...@@ -6541,10 +6541,13 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,
goto err_element_clash; goto err_element_clash;
} }
if (!(flags & NFT_SET_ELEM_CATCHALL) && set->size && if (!(flags & NFT_SET_ELEM_CATCHALL)) {
!atomic_add_unless(&set->nelems, 1, set->size + set->ndeact)) { unsigned int max = set->size ? set->size + set->ndeact : UINT_MAX;
err = -ENFILE;
goto err_set_full; if (!atomic_add_unless(&set->nelems, 1, max)) {
err = -ENFILE;
goto err_set_full;
}
} }
nft_trans_elem(trans) = elem; nft_trans_elem(trans) = elem;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment