Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 61a7b3de authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso Committed by Greg Kroah-Hartman
Browse files

netfilter: nft_set_rbtree: use read spinlock to avoid datapath contention



commit 96b33300fba880ec0eafcf3d82486f3463b4b6da upstream.

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: default avatarPablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 03caf75d
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -626,8 +626,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. */
@@ -676,8 +675,7 @@ static void nft_rbtree_gc(struct work_struct *work)
	}

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);