]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfrm: state: make xfrm_state_lookup_byaddr lockless
authorFlorian Westphal <fw@strlen.de>
Fri, 7 Mar 2025 11:47:54 +0000 (12:47 +0100)
committerSteffen Klassert <steffen.klassert@secunet.com>
Wed, 12 Mar 2025 09:15:38 +0000 (10:15 +0100)
This appears to be an oversight back when the state lookup
was converted to RCU, I see no reason why we need to hold the
state lock here.

__xfrm_state_lookup_byaddr already uses xfrm_state_hold_rcu
helper to obtain a reference, so just replace the state
lock with rcu.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/xfrm/xfrm_state.c

index 7b102867114418b783ed6eae2680acae2c8a82ce..07545944a536935dea30da8009589af9ac17c089 100644 (file)
@@ -2313,12 +2313,12 @@ xfrm_state_lookup_byaddr(struct net *net, u32 mark,
        struct xfrm_hash_state_ptrs state_ptrs;
        struct xfrm_state *x;
 
-       spin_lock_bh(&net->xfrm.xfrm_state_lock);
+       rcu_read_lock();
 
        xfrm_hash_ptrs_get(net, &state_ptrs);
 
        x = __xfrm_state_lookup_byaddr(&state_ptrs, mark, daddr, saddr, proto, family);
-       spin_unlock_bh(&net->xfrm.xfrm_state_lock);
+       rcu_read_unlock();
        return x;
 }
 EXPORT_SYMBOL(xfrm_state_lookup_byaddr);