netfilter: nf_tables: defer gc run if previous batch is still pending
authorFlorian Westphal <fw@strlen.de>
Fri, 22 Sep 2023 16:30:23 +0000 (18:30 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Oct 2023 12:56:34 +0000 (14:56 +0200)
commita42ac74c966604c70f60fc9ee961beae20733f09
tree5848baf10b26bf045602f882551e090c757a0751
parent620e594be334f48c172f0ef01a2cee84536a703a
netfilter: nf_tables: defer gc run if previous batch is still pending

commit 8e51830e29e12670b4c10df070a4ea4c9593e961 upstream.

Don't queue more gc work, else we may queue the same elements multiple
times.

If an element is flagged as dead, this can mean that either the previous
gc request was invalidated/discarded by a transaction or that the previous
request is still pending in the system work queue.

The latter will happen if the gc interval is set to a very low value,
e.g. 1ms, and system work queue is backlogged.

The sets refcount is 1 if no previous gc requeusts are queued, so add
a helper for this and skip gc run if old requests are pending.

Add a helper for this and skip the gc run in this case.

Fixes: f6c383b8c31a ("netfilter: nf_tables: adapt set backend to use GC transaction API")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/net/netfilter/nf_tables.h
net/netfilter/nft_set_hash.c
net/netfilter/nft_set_rbtree.c