Skip to content

Commit d4b7f29

Browse files
author
Florian Westphal
committed
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: Florian Westphal <[email protected]>
1 parent a4878ee commit d4b7f29

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6541,10 +6541,13 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,
65416541
goto err_element_clash;
65426542
}
65436543

6544-
if (!(flags & NFT_SET_ELEM_CATCHALL) && set->size &&
6545-
!atomic_add_unless(&set->nelems, 1, set->size + set->ndeact)) {
6546-
err = -ENFILE;
6547-
goto err_set_full;
6544+
if (!(flags & NFT_SET_ELEM_CATCHALL)) {
6545+
unsigned int max = set->size ? set->size + set->ndeact : UINT_MAX;
6546+
6547+
if (!atomic_add_unless(&set->nelems, 1, max)) {
6548+
err = -ENFILE;
6549+
goto err_set_full;
6550+
}
65486551
}
65496552

65506553
nft_trans_elem(trans) = elem;

0 commit comments

Comments
 (0)