summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2023-09-05 13:52:24 +0300
committerPablo Neira Ayuso <pablo@netfilter.org>2023-09-08 04:26:57 +0300
commit96b33300fba880ec0eafcf3d82486f3463b4b6da (patch)
tree8e20324109e318e2a6cf9d96fc02232367543e73 /net
parentf15f29fd4779be8a418b66e9d52979bb6d6c2325 (diff)
downloadlinux-96b33300fba880ec0eafcf3d82486f3463b4b6da.tar.xz
netfilter: nft_set_rbtree: use read spinlock to avoid datapath contention
rbtree GC does not modify the datastructure, instead it collects expired elements and it enqueues a GC transaction. Use a read spinlock instead to avoid data contention while GC worker is running. Fixes: f6c383b8c31a ("netfilter: nf_tables: adapt set backend to use GC transaction API") Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net')
-rw-r--r--net/netfilter/nft_set_rbtree.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/net/netfilter/nft_set_rbtree.c b/net/netfilter/nft_set_rbtree.c
index f250b5399344..70491ba98dec 100644
--- a/net/netfilter/nft_set_rbtree.c
+++ b/net/netfilter/nft_set_rbtree.c
@@ -622,8 +622,7 @@ static void nft_rbtree_gc(struct work_struct *work)
if (!gc)
goto done;
- write_lock_bh(&priv->lock);
- write_seqcount_begin(&priv->count);
+ read_lock_bh(&priv->lock);
for (node = rb_first(&priv->root); node != NULL; node = rb_next(node)) {
/* Ruleset has been updated, try later. */
@@ -673,8 +672,7 @@ dead_elem:
gc = nft_trans_gc_catchall(gc, gc_seq);
try_later:
- write_seqcount_end(&priv->count);
- write_unlock_bh(&priv->lock);
+ read_unlock_bh(&priv->lock);
if (gc)
nft_trans_gc_queue_async_done(gc);