diff options
author | Florian Westphal <fw@strlen.de> | 2016-08-09 06:16:08 -0400 |
---|---|---|
committer | Steffen Klassert <steffen.klassert@secunet.com> | 2016-08-10 05:23:24 -0400 |
commit | c8406998b80183ef87895ab1de4dbed8bb2d53a0 (patch) | |
tree | 4b6c613e08a0ff3d6a93393724d6d45c40c7c958 /net/xfrm | |
parent | b65e3d7be06fd8ff5236439254f338fe1a8d4bbd (diff) |
xfrm: state: use rcu_deref and assign_pointer helpers
Before xfrm_state_find() can use rcu_read_lock instead of xfrm_state_lock
we need to switch users of the hash table to assign/obtain the pointers
with the appropriate rcu helpers.
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 | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index ac4037cf6a29..53e7867f9254 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c | |||
@@ -28,6 +28,9 @@ | |||
28 | 28 | ||
29 | #include "xfrm_hash.h" | 29 | #include "xfrm_hash.h" |
30 | 30 | ||
31 | #define xfrm_state_deref_prot(table, net) \ | ||
32 | rcu_dereference_protected((table), lockdep_is_held(&(net)->xfrm.xfrm_state_lock)) | ||
33 | |||
31 | /* Each xfrm_state may be linked to two tables: | 34 | /* Each xfrm_state may be linked to two tables: |
32 | 35 | ||
33 | 1. Hash table by (spi,daddr,ah/esp) to find SA by SPI. (input,ctl) | 36 | 1. Hash table by (spi,daddr,ah/esp) to find SA by SPI. (input,ctl) |
@@ -131,18 +134,17 @@ static void xfrm_hash_resize(struct work_struct *work) | |||
131 | write_seqcount_begin(&xfrm_state_hash_generation); | 134 | write_seqcount_begin(&xfrm_state_hash_generation); |
132 | 135 | ||
133 | nhashmask = (nsize / sizeof(struct hlist_head)) - 1U; | 136 | nhashmask = (nsize / sizeof(struct hlist_head)) - 1U; |
137 | odst = xfrm_state_deref_prot(net->xfrm.state_bydst, net); | ||
134 | for (i = net->xfrm.state_hmask; i >= 0; i--) | 138 | for (i = net->xfrm.state_hmask; i >= 0; i--) |
135 | xfrm_hash_transfer(net->xfrm.state_bydst+i, ndst, nsrc, nspi, | 139 | xfrm_hash_transfer(odst + i, ndst, nsrc, nspi, nhashmask); |
136 | nhashmask); | ||
137 | 140 | ||
138 | odst = net->xfrm.state_bydst; | 141 | osrc = xfrm_state_deref_prot(net->xfrm.state_bysrc, net); |
139 | osrc = net->xfrm.state_bysrc; | 142 | ospi = xfrm_state_deref_prot(net->xfrm.state_byspi, net); |
140 | ospi = net->xfrm.state_byspi; | ||
141 | ohashmask = net->xfrm.state_hmask; | 143 | ohashmask = net->xfrm.state_hmask; |
142 | 144 | ||
143 | net->xfrm.state_bydst = ndst; | 145 | rcu_assign_pointer(net->xfrm.state_bydst, ndst); |
144 | net->xfrm.state_bysrc = nsrc; | 146 | rcu_assign_pointer(net->xfrm.state_bysrc, nsrc); |
145 | net->xfrm.state_byspi = nspi; | 147 | rcu_assign_pointer(net->xfrm.state_byspi, nspi); |
146 | net->xfrm.state_hmask = nhashmask; | 148 | net->xfrm.state_hmask = nhashmask; |
147 | 149 | ||
148 | write_seqcount_end(&xfrm_state_hash_generation); | 150 | write_seqcount_end(&xfrm_state_hash_generation); |