Commit e5549aec authored by Fushuai Wang's avatar Fushuai Wang Committed by Jakub Kicinski
Browse files

wireguard: allowedips: Use kfree_rcu() instead of call_rcu()



Replace call_rcu() + kmem_cache_free() with kfree_rcu() to simplify
the code and reduce function size.

Signed-off-by: default avatarFushuai Wang <wangfushuai@baidu.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
Link: https://patch.msgid.link/20260414153944.2742252-2-Jason@zx2c4.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent bc28831d
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -48,11 +48,6 @@ static void push_rcu(struct allowedips_node **stack,
	}
}

static void node_free_rcu(struct rcu_head *rcu)
{
	kmem_cache_free(node_cache, container_of(rcu, struct allowedips_node, rcu));
}

static void root_free_rcu(struct rcu_head *rcu)
{
	struct allowedips_node *node, *stack[MAX_ALLOWEDIPS_DEPTH] = {
@@ -271,13 +266,13 @@ static void remove_node(struct allowedips_node *node, struct mutex *lock)
	if (free_parent)
		child = rcu_dereference_protected(parent->bit[!(node->parent_bit_packed & 1)],
						  lockdep_is_held(lock));
	call_rcu(&node->rcu, node_free_rcu);
	kfree_rcu(node, rcu);
	if (!free_parent)
		return;
	if (child)
		child->parent_bit_packed = parent->parent_bit_packed;
	*(struct allowedips_node **)(parent->parent_bit_packed & ~3UL) = child;
	call_rcu(&parent->rcu, node_free_rcu);
	kfree_rcu(parent, rcu);
}

static int remove(struct allowedips_node __rcu **trie, u8 bits, const u8 *key,