]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
xfrm: policy: make xfrm_policy_lookup_bytype lockless
authorFlorian Westphal <fw@strlen.de>
Thu, 11 Aug 2016 13:17:56 +0000 (15:17 +0200)
committerSteffen Klassert <steffen.klassert@secunet.com>
Fri, 12 Aug 2016 06:07:12 +0000 (08:07 +0200)
side effect: no longer disables BH (should be fine).

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

index 1ab51d1884087f75e3889954648d8998062df345..3ab828a97e68ef0d0af1d1c3cd2388593fbae439 100644 (file)
@@ -11,7 +11,7 @@
 struct ctl_table_header;
 
 struct xfrm_policy_hash {
-       struct hlist_head       *table;
+       struct hlist_head       __rcu *table;
        unsigned int            hmask;
        u8                      dbits4;
        u8                      sbits4;
index 09f2e2b38246c3cf2aea1ff03dc73e8c8a7aa411..9302647f20a0952b541a2abcbf5c113dabb40657 100644 (file)
@@ -1123,7 +1123,7 @@ static struct xfrm_policy *xfrm_policy_lookup_bytype(struct net *net, u8 type,
        if (unlikely(!daddr || !saddr))
                return NULL;
 
-       read_lock_bh(&net->xfrm.xfrm_policy_lock);
+       rcu_read_lock();
  retry:
        do {
                sequence = read_seqcount_begin(&xfrm_policy_hash_generation);
@@ -1172,7 +1172,7 @@ static struct xfrm_policy *xfrm_policy_lookup_bytype(struct net *net, u8 type,
        if (ret && !xfrm_pol_hold_rcu(ret))
                goto retry;
 fail:
-       read_unlock_bh(&net->xfrm.xfrm_policy_lock);
+       rcu_read_unlock();
 
        return ret;
 }