aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/xfrm6_output.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-10-08 20:16:30 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:54:53 -0400
commit406ef77c893ebd882209be4e393d64b01fe72054 (patch)
tree815d753889769b355fba7e648abef7ad1422559e /net/ipv6/xfrm6_output.c
parentbc31d3b2c7d7f2a03721a05cb3c9a3ce8b1e2e5a (diff)
[IPSEC]: Move common output code to xfrm_output
Most of the code in xfrm4_output_one and xfrm6_output_one are identical so this patch moves them into a common xfrm_output function which will live in net/xfrm. In fact this would seem to fix a bug as on IPv4 we never reset the network header after a transform which may upset netfilter later on. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/xfrm6_output.c')
-rw-r--r--net/ipv6/xfrm6_output.c45
1 files changed, 5 insertions, 40 deletions
diff --git a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c
index 56364a5f676a..f21596f89984 100644
--- a/net/ipv6/xfrm6_output.c
+++ b/net/ipv6/xfrm6_output.c
@@ -9,9 +9,9 @@
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10 */ 10 */
11 11
12#include <linux/if_ether.h>
12#include <linux/compiler.h> 13#include <linux/compiler.h>
13#include <linux/skbuff.h> 14#include <linux/skbuff.h>
14#include <linux/spinlock.h>
15#include <linux/icmpv6.h> 15#include <linux/icmpv6.h>
16#include <linux/netfilter_ipv6.h> 16#include <linux/netfilter_ipv6.h>
17#include <net/ipv6.h> 17#include <net/ipv6.h>
@@ -43,62 +43,27 @@ static int xfrm6_tunnel_check_size(struct sk_buff *skb)
43 return ret; 43 return ret;
44} 44}
45 45
46static int xfrm6_output_one(struct sk_buff *skb) 46static inline int xfrm6_output_one(struct sk_buff *skb)
47{ 47{
48 struct dst_entry *dst = skb->dst; 48 struct dst_entry *dst = skb->dst;
49 struct xfrm_state *x = dst->xfrm; 49 struct xfrm_state *x = dst->xfrm;
50 int err; 50 int err;
51 51
52 if (skb->ip_summed == CHECKSUM_PARTIAL) {
53 err = skb_checksum_help(skb);
54 if (err)
55 goto error_nolock;
56 }
57
58 if (x->props.mode == XFRM_MODE_TUNNEL) { 52 if (x->props.mode == XFRM_MODE_TUNNEL) {
59 err = xfrm6_tunnel_check_size(skb); 53 err = xfrm6_tunnel_check_size(skb);
60 if (err) 54 if (err)
61 goto error_nolock; 55 goto error_nolock;
62 } 56 }
63 57
64 do { 58 err = xfrm_output(skb);
65 spin_lock_bh(&x->lock); 59 if (err)
66 err = xfrm_state_check(x, skb); 60 goto error_nolock;
67 if (err)
68 goto error;
69
70 err = x->mode->output(x, skb);
71 if (err)
72 goto error;
73
74 err = x->type->output(x, skb);
75 if (err)
76 goto error;
77
78 x->curlft.bytes += skb->len;
79 x->curlft.packets++;
80 if (x->props.mode == XFRM_MODE_ROUTEOPTIMIZATION)
81 x->lastused = get_seconds();
82
83 spin_unlock_bh(&x->lock);
84
85 skb_reset_network_header(skb);
86
87 if (!(skb->dst = dst_pop(dst))) {
88 err = -EHOSTUNREACH;
89 goto error_nolock;
90 }
91 dst = skb->dst;
92 x = dst->xfrm;
93 } while (x && (x->props.mode != XFRM_MODE_TUNNEL));
94 61
95 IP6CB(skb)->flags |= IP6SKB_XFRM_TRANSFORMED; 62 IP6CB(skb)->flags |= IP6SKB_XFRM_TRANSFORMED;
96 err = 0; 63 err = 0;
97 64
98out_exit: 65out_exit:
99 return err; 66 return err;
100error:
101 spin_unlock_bh(&x->lock);
102error_nolock: 67error_nolock:
103 kfree_skb(skb); 68 kfree_skb(skb);
104 goto out_exit; 69 goto out_exit;