diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2007-11-14 00:40:52 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:53:45 -0500 |
commit | 36cf9acf93e8561d9faec24849e57688a81eb9c5 (patch) | |
tree | fd4fab84132f1784a23441e03c4a0b9aea6cc43a /net/ipv6/xfrm6_output.c | |
parent | 29bb43b4ec4e625b0659186fc8a7c8f8b7c81982 (diff) |
[IPSEC]: Separate inner/outer mode processing on output
With inter-family transforms the inner mode differs from the outer
mode. Attempting to handle both sides from the same function means
that it needs to handle both IPv4 and IPv6 which creates duplication
and confusion.
This patch separates the two parts on the output path so that each
function deals with one family only.
In particular, the functions xfrm4_extract_output/xfrm6_extract_output
moves the pertinent fields from the IPv4/IPv6 IP headers into a
neutral format stored in skb->cb. This is then used by the outer mode
output functions to write the outer IP header. In this way the output
function no longer has to know about the inner address family.
Since the extract functions are only called by tunnel modes (the only
modes that can support inter-family transforms), I've also moved the
xfrm*_tunnel_check_size calls into them. This allows the correct ICMP
message to be sent as opposed to now where you might call icmp_send
with an IPv6 packet and vice versa.
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.c | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c index 656976760ad4..bc2e80e3b0b1 100644 --- a/net/ipv6/xfrm6_output.c +++ b/net/ipv6/xfrm6_output.c | |||
@@ -10,10 +10,12 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/if_ether.h> | 12 | #include <linux/if_ether.h> |
13 | #include <linux/compiler.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/module.h> | ||
14 | #include <linux/skbuff.h> | 15 | #include <linux/skbuff.h> |
15 | #include <linux/icmpv6.h> | 16 | #include <linux/icmpv6.h> |
16 | #include <linux/netfilter_ipv6.h> | 17 | #include <linux/netfilter_ipv6.h> |
18 | #include <net/dst.h> | ||
17 | #include <net/ipv6.h> | 19 | #include <net/ipv6.h> |
18 | #include <net/xfrm.h> | 20 | #include <net/xfrm.h> |
19 | 21 | ||
@@ -43,19 +45,38 @@ static int xfrm6_tunnel_check_size(struct sk_buff *skb) | |||
43 | return ret; | 45 | return ret; |
44 | } | 46 | } |
45 | 47 | ||
48 | int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb) | ||
49 | { | ||
50 | int err; | ||
51 | |||
52 | err = xfrm6_tunnel_check_size(skb); | ||
53 | if (err) | ||
54 | return err; | ||
55 | |||
56 | return xfrm6_extract_header(skb); | ||
57 | } | ||
58 | |||
59 | int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb) | ||
60 | { | ||
61 | int err; | ||
62 | |||
63 | err = x->inner_mode->afinfo->extract_output(x, skb); | ||
64 | if (err) | ||
65 | return err; | ||
66 | |||
67 | memset(IP6CB(skb), 0, sizeof(*IP6CB(skb))); | ||
68 | |||
69 | skb->protocol = htons(ETH_P_IPV6); | ||
70 | |||
71 | return x->outer_mode->output2(x, skb); | ||
72 | } | ||
73 | EXPORT_SYMBOL(xfrm6_prepare_output); | ||
74 | |||
46 | static inline int xfrm6_output_one(struct sk_buff *skb) | 75 | static inline int xfrm6_output_one(struct sk_buff *skb) |
47 | { | 76 | { |
48 | struct dst_entry *dst = skb->dst; | ||
49 | struct xfrm_state *x = dst->xfrm; | ||
50 | struct ipv6hdr *iph; | 77 | struct ipv6hdr *iph; |
51 | int err; | 78 | int err; |
52 | 79 | ||
53 | if (x->outer_mode->flags & XFRM_MODE_FLAG_TUNNEL) { | ||
54 | err = xfrm6_tunnel_check_size(skb); | ||
55 | if (err) | ||
56 | goto error_nolock; | ||
57 | } | ||
58 | |||
59 | err = xfrm_output(skb); | 80 | err = xfrm_output(skb); |
60 | if (err) | 81 | if (err) |
61 | goto error_nolock; | 82 | goto error_nolock; |