diff options
author | Florian Westphal <fw@strlen.de> | 2016-08-09 06:16:09 -0400 |
---|---|---|
committer | Steffen Klassert <steffen.klassert@secunet.com> | 2016-08-10 05:23:24 -0400 |
commit | d737a5805581c6f99dad4caa9fdf80965d617d1a (patch) | |
tree | 4a41adb2c5c3ac0ea2816fa8789b828499d8fee4 /net/xfrm | |
parent | c8406998b80183ef87895ab1de4dbed8bb2d53a0 (diff) |
xfrm: state: don't use lock anymore unless acquire operation is needed
push the lock down, after earlier patches we can rely on rcu to
make sure state struct won't go away.
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Diffstat (limited to 'net/xfrm')
-rw-r--r-- | net/xfrm/xfrm_state.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 53e7867f9254..1a15b658a79e 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c | |||
@@ -799,7 +799,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr, | |||
799 | 799 | ||
800 | sequence = read_seqcount_begin(&xfrm_state_hash_generation); | 800 | sequence = read_seqcount_begin(&xfrm_state_hash_generation); |
801 | 801 | ||
802 | spin_lock_bh(&net->xfrm.xfrm_state_lock); | 802 | rcu_read_lock(); |
803 | h = xfrm_dst_hash(net, daddr, saddr, tmpl->reqid, encap_family); | 803 | h = xfrm_dst_hash(net, daddr, saddr, tmpl->reqid, encap_family); |
804 | hlist_for_each_entry_rcu(x, net->xfrm.state_bydst + h, bydst) { | 804 | hlist_for_each_entry_rcu(x, net->xfrm.state_bydst + h, bydst) { |
805 | if (x->props.family == encap_family && | 805 | if (x->props.family == encap_family && |
@@ -870,6 +870,7 @@ found: | |||
870 | } | 870 | } |
871 | 871 | ||
872 | if (km_query(x, tmpl, pol) == 0) { | 872 | if (km_query(x, tmpl, pol) == 0) { |
873 | spin_lock_bh(&net->xfrm.xfrm_state_lock); | ||
873 | x->km.state = XFRM_STATE_ACQ; | 874 | x->km.state = XFRM_STATE_ACQ; |
874 | list_add(&x->km.all, &net->xfrm.state_all); | 875 | list_add(&x->km.all, &net->xfrm.state_all); |
875 | hlist_add_head_rcu(&x->bydst, net->xfrm.state_bydst + h); | 876 | hlist_add_head_rcu(&x->bydst, net->xfrm.state_bydst + h); |
@@ -883,6 +884,7 @@ found: | |||
883 | tasklet_hrtimer_start(&x->mtimer, ktime_set(net->xfrm.sysctl_acq_expires, 0), HRTIMER_MODE_REL); | 884 | tasklet_hrtimer_start(&x->mtimer, ktime_set(net->xfrm.sysctl_acq_expires, 0), HRTIMER_MODE_REL); |
884 | net->xfrm.state_num++; | 885 | net->xfrm.state_num++; |
885 | xfrm_hash_grow_check(net, x->bydst.next != NULL); | 886 | xfrm_hash_grow_check(net, x->bydst.next != NULL); |
887 | spin_unlock_bh(&net->xfrm.xfrm_state_lock); | ||
886 | } else { | 888 | } else { |
887 | x->km.state = XFRM_STATE_DEAD; | 889 | x->km.state = XFRM_STATE_DEAD; |
888 | to_put = x; | 890 | to_put = x; |
@@ -899,7 +901,7 @@ out: | |||
899 | } else { | 901 | } else { |
900 | *err = acquire_in_progress ? -EAGAIN : error; | 902 | *err = acquire_in_progress ? -EAGAIN : error; |
901 | } | 903 | } |
902 | spin_unlock_bh(&net->xfrm.xfrm_state_lock); | 904 | rcu_read_unlock(); |
903 | if (to_put) | 905 | if (to_put) |
904 | xfrm_state_put(to_put); | 906 | xfrm_state_put(to_put); |
905 | 907 | ||