]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
xfrm: state lookup can be lockless
authorFlorian Westphal <fw@strlen.de>
Tue, 20 Sep 2016 13:45:26 +0000 (15:45 +0200)
committerSteffen Klassert <steffen.klassert@secunet.com>
Wed, 21 Sep 2016 10:37:29 +0000 (12:37 +0200)
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>
net/xfrm/xfrm_state.c

index ba8bf518ba14c911697813377987e0f998c84aa8..a38fdead38ea7ba29f70fcda219b375625773204 100644 (file)
@@ -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);