Skip to content

Commit

Permalink
xfrm: state lookup can be lockless
Browse files Browse the repository at this point in the history
This is called from the packet input path, we get lock contention
if many cpus handle ipsec in parallel.

After recent rcu conversion it is safe to call __xfrm_state_lookup
without the spinlock.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
  • Loading branch information
Florian Westphal authored and Steffen Klassert committed Sep 21, 2016
1 parent 34a3d4b commit c2f672f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/xfrm/xfrm_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -1431,9 +1431,9 @@ xfrm_state_lookup(struct net *net, u32 mark, const xfrm_address_t *daddr, __be32
{
struct xfrm_state *x;

spin_lock_bh(&net->xfrm.xfrm_state_lock);
rcu_read_lock();
x = __xfrm_state_lookup(net, mark, daddr, spi, proto, family);
spin_unlock_bh(&net->xfrm.xfrm_state_lock);
rcu_read_unlock();
return x;
}
EXPORT_SYMBOL(xfrm_state_lookup);
Expand Down

0 comments on commit c2f672f

Please sign in to comment.