aboutsummaryrefslogtreecommitdiffstats
path: root/net/xfrm
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2018-12-18 11:15:18 -0500
committerDavid S. Miller <davem@davemloft.net>2018-12-19 14:21:37 -0500
commit0ca64da128b816b2826e9b469f47239c47f1df31 (patch)
tree1772b09b0ce8f686851f3a854777e2b2001ea1f1 /net/xfrm
parentde8bda1d22d38b7d5cd08b33f86efd94d4c86630 (diff)
xfrm: change secpath_set to return secpath struct, not error value
It can only return 0 (success) or -ENOMEM. Change return value to a pointer to secpath struct. This avoids direct access to skb->sp: err = secpath_set(skb); if (!err) .. skb->sp-> ... Becomes: sp = secpath_set(skb) if (!sp) .. sp-> .. This reduces noise in followup patch which is going to remove skb->sp. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/xfrm')
-rw-r--r--net/xfrm/xfrm_input.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
index 684c0bc01e2c..bda929b9ff35 100644
--- a/net/xfrm/xfrm_input.c
+++ b/net/xfrm/xfrm_input.c
@@ -145,21 +145,22 @@ struct sec_path *secpath_dup(struct sec_path *src)
145} 145}
146EXPORT_SYMBOL(secpath_dup); 146EXPORT_SYMBOL(secpath_dup);
147 147
148int secpath_set(struct sk_buff *skb) 148struct sec_path *secpath_set(struct sk_buff *skb)
149{ 149{
150 struct sec_path *sp; 150 struct sec_path *sp = skb->sp;
151 151
152 /* Allocate new secpath or COW existing one. */ 152 /* Allocate new secpath or COW existing one. */
153 if (!skb->sp || refcount_read(&skb->sp->refcnt) != 1) { 153 if (!sp || refcount_read(&sp->refcnt) != 1) {
154 sp = secpath_dup(skb->sp); 154 sp = secpath_dup(skb->sp);
155 if (!sp) 155 if (!sp)
156 return -ENOMEM; 156 return NULL;
157 157
158 if (skb->sp) 158 if (skb->sp)
159 secpath_put(skb->sp); 159 secpath_put(skb->sp);
160 skb->sp = sp; 160 skb->sp = sp;
161 } 161 }
162 return 0; 162
163 return sp;
163} 164}
164EXPORT_SYMBOL(secpath_set); 165EXPORT_SYMBOL(secpath_set);
165 166
@@ -236,6 +237,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
236 bool xfrm_gro = false; 237 bool xfrm_gro = false;
237 bool crypto_done = false; 238 bool crypto_done = false;
238 struct xfrm_offload *xo = xfrm_offload(skb); 239 struct xfrm_offload *xo = xfrm_offload(skb);
240 struct sec_path *sp;
239 241
240 if (encap_type < 0) { 242 if (encap_type < 0) {
241 x = xfrm_input_state(skb); 243 x = xfrm_input_state(skb);
@@ -312,8 +314,8 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
312 break; 314 break;
313 } 315 }
314 316
315 err = secpath_set(skb); 317 sp = secpath_set(skb);
316 if (err) { 318 if (!sp) {
317 XFRM_INC_STATS(net, LINUX_MIB_XFRMINERROR); 319 XFRM_INC_STATS(net, LINUX_MIB_XFRMINERROR);
318 goto drop; 320 goto drop;
319 } 321 }