diff options
author | Florian Westphal <fw@strlen.de> | 2018-12-18 11:15:26 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-12-19 14:21:38 -0500 |
commit | a84e3f533324e40e4a99f50dee2188bf140d8098 (patch) | |
tree | 87609cfff448eacf1b18ae19f9f841d416abee2c /net/xfrm/xfrm_output.c | |
parent | a053c866496d0c3647727f6a282a1db3afea3ed7 (diff) |
xfrm: prefer secpath_set over secpath_dup
secpath_set is a wrapper for secpath_dup that will not perform
an allocation if the secpath attached to the skb has a reference count
of one, i.e., it doesn't need to be COW'ed.
Also, secpath_dup doesn't attach the secpath to the skb, it leaves
this to the caller.
Use secpath_set in places that immediately assign the return value to
skb.
This allows to remove skb->sp without touching these spots again.
secpath_dup can eventually be removed in followup patch.
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/xfrm/xfrm_output.c')
-rw-r--r-- | net/xfrm/xfrm_output.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c index 4ae87c5ce2e3..757c4d11983b 100644 --- a/net/xfrm/xfrm_output.c +++ b/net/xfrm/xfrm_output.c | |||
@@ -218,19 +218,16 @@ int xfrm_output(struct sock *sk, struct sk_buff *skb) | |||
218 | if (xfrm_dev_offload_ok(skb, x)) { | 218 | if (xfrm_dev_offload_ok(skb, x)) { |
219 | struct sec_path *sp; | 219 | struct sec_path *sp; |
220 | 220 | ||
221 | sp = secpath_dup(skb->sp); | 221 | sp = secpath_set(skb); |
222 | if (!sp) { | 222 | if (!sp) { |
223 | XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR); | 223 | XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR); |
224 | kfree_skb(skb); | 224 | kfree_skb(skb); |
225 | return -ENOMEM; | 225 | return -ENOMEM; |
226 | } | 226 | } |
227 | if (skb->sp) | ||
228 | secpath_put(skb->sp); | ||
229 | skb->sp = sp; | ||
230 | skb->encapsulation = 1; | 227 | skb->encapsulation = 1; |
231 | 228 | ||
232 | sp->olen++; | 229 | sp->olen++; |
233 | sp->xvec[skb->sp->len++] = x; | 230 | sp->xvec[sp->len++] = x; |
234 | xfrm_state_hold(x); | 231 | xfrm_state_hold(x); |
235 | 232 | ||
236 | if (skb_is_gso(skb)) { | 233 | if (skb_is_gso(skb)) { |