netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH ipsec-next] xfrm: state: make xfrm_state_lookup_byaddr lockless
@ 2025-03-07 11:47 Florian Westphal
  2025-03-15  3:45 ` Steffen Klassert
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Westphal @ 2025-03-07 11:47 UTC (permalink / raw)
  To: netdev; +Cc: steffen.klassert, herbert, davem, Florian Westphal

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>
---
 net/xfrm/xfrm_state.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 7b1028671144..07545944a536 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -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);
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH ipsec-next] xfrm: state: make xfrm_state_lookup_byaddr lockless
  2025-03-07 11:47 [PATCH ipsec-next] xfrm: state: make xfrm_state_lookup_byaddr lockless Florian Westphal
@ 2025-03-15  3:45 ` Steffen Klassert
  0 siblings, 0 replies; 2+ messages in thread
From: Steffen Klassert @ 2025-03-15  3:45 UTC (permalink / raw)
  To: Florian Westphal; +Cc: netdev, herbert, davem

On Fri, Mar 07, 2025 at 12:47:54PM +0100, Florian Westphal wrote:
> 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>

Applied, thanks Florian!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-03-15  3:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-07 11:47 [PATCH ipsec-next] xfrm: state: make xfrm_state_lookup_byaddr lockless Florian Westphal
2025-03-15  3:45 ` Steffen Klassert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).