aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/ipcomp6.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-10-10 18:45:25 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:55:55 -0400
commit87bdc48d304191313203df9b98d783e1ab5a55ab (patch)
tree32f7bfb3a5fa7fe373f11e0ddadd95b6bcd9bd4f /net/ipv6/ipcomp6.c
parent37fedd3aab6517daec628764c5d66dd8761fbe5f (diff)
[IPSEC]: Get rid of ipv6_{auth,esp,comp}_hdr
This patch removes the duplicate ipv6_{auth,esp,comp}_hdr structures since they're identical to the IPv4 versions. Duplicating them would only create problems for ourselves later when we need to add things like extended sequence numbers. I've also added transport header type conversion headers for these types which are now used by the transforms. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/ipcomp6.c')
-rw-r--r--net/ipv6/ipcomp6.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
index 87e6407ebf97..8f3f32faaf4c 100644
--- a/net/ipv6/ipcomp6.c
+++ b/net/ipv6/ipcomp6.c
@@ -65,7 +65,7 @@ static LIST_HEAD(ipcomp6_tfms_list);
65static int ipcomp6_input(struct xfrm_state *x, struct sk_buff *skb) 65static int ipcomp6_input(struct xfrm_state *x, struct sk_buff *skb)
66{ 66{
67 int err = -ENOMEM; 67 int err = -ENOMEM;
68 struct ipv6_comp_hdr *ipch; 68 struct ip_comp_hdr *ipch;
69 int plen, dlen; 69 int plen, dlen;
70 struct ipcomp_data *ipcd = x->data; 70 struct ipcomp_data *ipcd = x->data;
71 u8 *start, *scratch; 71 u8 *start, *scratch;
@@ -92,12 +92,10 @@ static int ipcomp6_input(struct xfrm_state *x, struct sk_buff *skb)
92 tfm = *per_cpu_ptr(ipcd->tfms, cpu); 92 tfm = *per_cpu_ptr(ipcd->tfms, cpu);
93 93
94 err = crypto_comp_decompress(tfm, start, plen, scratch, &dlen); 94 err = crypto_comp_decompress(tfm, start, plen, scratch, &dlen);
95 if (err) { 95 if (err)
96 err = -EINVAL;
97 goto out_put_cpu; 96 goto out_put_cpu;
98 }
99 97
100 if (dlen < (plen + sizeof(struct ipv6_comp_hdr))) { 98 if (dlen < (plen + sizeof(*ipch))) {
101 err = -EINVAL; 99 err = -EINVAL;
102 goto out_put_cpu; 100 goto out_put_cpu;
103 } 101 }
@@ -122,7 +120,7 @@ static int ipcomp6_output(struct xfrm_state *x, struct sk_buff *skb)
122{ 120{
123 int err; 121 int err;
124 struct ipv6hdr *top_iph; 122 struct ipv6hdr *top_iph;
125 struct ipv6_comp_hdr *ipch; 123 struct ip_comp_hdr *ipch;
126 struct ipcomp_data *ipcd = x->data; 124 struct ipcomp_data *ipcd = x->data;
127 int plen, dlen; 125 int plen, dlen;
128 u8 *start, *scratch; 126 u8 *start, *scratch;
@@ -151,7 +149,7 @@ static int ipcomp6_output(struct xfrm_state *x, struct sk_buff *skb)
151 tfm = *per_cpu_ptr(ipcd->tfms, cpu); 149 tfm = *per_cpu_ptr(ipcd->tfms, cpu);
152 150
153 err = crypto_comp_compress(tfm, start, plen, scratch, &dlen); 151 err = crypto_comp_compress(tfm, start, plen, scratch, &dlen);
154 if (err || (dlen + sizeof(struct ipv6_comp_hdr)) >= plen) { 152 if (err || (dlen + sizeof(*ipch)) >= plen) {
155 put_cpu(); 153 put_cpu();
156 goto out_ok; 154 goto out_ok;
157 } 155 }
@@ -164,7 +162,7 @@ static int ipcomp6_output(struct xfrm_state *x, struct sk_buff *skb)
164 162
165 top_iph->payload_len = htons(skb->len - sizeof(struct ipv6hdr)); 163 top_iph->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
166 164
167 ipch = (struct ipv6_comp_hdr *)start; 165 ipch = ip_comp_hdr(skb);
168 ipch->nexthdr = *skb_mac_header(skb); 166 ipch->nexthdr = *skb_mac_header(skb);
169 ipch->flags = 0; 167 ipch->flags = 0;
170 ipch->cpi = htons((u16 )ntohl(x->id.spi)); 168 ipch->cpi = htons((u16 )ntohl(x->id.spi));
@@ -179,7 +177,8 @@ static void ipcomp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
179{ 177{
180 __be32 spi; 178 __be32 spi;
181 struct ipv6hdr *iph = (struct ipv6hdr*)skb->data; 179 struct ipv6hdr *iph = (struct ipv6hdr*)skb->data;
182 struct ipv6_comp_hdr *ipcomph = (struct ipv6_comp_hdr*)(skb->data+offset); 180 struct ip_comp_hdr *ipcomph =
181 (struct ip_comp_hdr *)(skb->data + offset);
183 struct xfrm_state *x; 182 struct xfrm_state *x;
184 183
185 if (type != ICMPV6_DEST_UNREACH && type != ICMPV6_PKT_TOOBIG) 184 if (type != ICMPV6_DEST_UNREACH && type != ICMPV6_PKT_TOOBIG)