Commit a2deb6d2 authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

[IPSEC]: Move x->outer_mode->output out of locked section

RO mode is the only one that requires a locked output function.  So
it's easier to move the lock into that function rather than requiring
everyone else to run under the lock.

In particular, this allows us to move the size check into the output
function without causing a potential dead-lock should the ICMP error
somehow hit the same SA on transmission.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e40b3286
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/spinlock.h>
#include <linux/stringify.h> #include <linux/stringify.h>
#include <linux/time.h> #include <linux/time.h>
#include <net/ipv6.h> #include <net/ipv6.h>
...@@ -53,7 +54,9 @@ static int xfrm6_ro_output(struct xfrm_state *x, struct sk_buff *skb) ...@@ -53,7 +54,9 @@ static int xfrm6_ro_output(struct xfrm_state *x, struct sk_buff *skb)
__skb_pull(skb, hdr_len); __skb_pull(skb, hdr_len);
memmove(ipv6_hdr(skb), iph, hdr_len); memmove(ipv6_hdr(skb), iph, hdr_len);
spin_lock_bh(&x->lock);
x->lastused = get_seconds(); x->lastused = get_seconds();
spin_unlock_bh(&x->lock);
return 0; return 0;
} }
......
...@@ -53,6 +53,10 @@ int xfrm_output(struct sk_buff *skb) ...@@ -53,6 +53,10 @@ int xfrm_output(struct sk_buff *skb)
} }
do { do {
err = x->outer_mode->output(x, skb);
if (err)
goto error;
spin_lock_bh(&x->lock); spin_lock_bh(&x->lock);
err = xfrm_state_check(x, skb); err = xfrm_state_check(x, skb);
if (err) if (err)
...@@ -64,10 +68,6 @@ int xfrm_output(struct sk_buff *skb) ...@@ -64,10 +68,6 @@ int xfrm_output(struct sk_buff *skb)
xfrm_replay_notify(x, XFRM_REPLAY_UPDATE); xfrm_replay_notify(x, XFRM_REPLAY_UPDATE);
} }
err = x->outer_mode->output(x, skb);
if (err)
goto error;
x->curlft.bytes += skb->len; x->curlft.bytes += skb->len;
x->curlft.packets++; x->curlft.packets++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment