aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/esp6.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/esp6.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/esp6.c')
-rw-r--r--net/ipv6/esp6.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 21c93f026dbc..a64295d164ea 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -44,7 +44,7 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
44{ 44{
45 int err; 45 int err;
46 struct ipv6hdr *top_iph; 46 struct ipv6hdr *top_iph;
47 struct ipv6_esp_hdr *esph; 47 struct ip_esp_hdr *esph;
48 struct crypto_blkcipher *tfm; 48 struct crypto_blkcipher *tfm;
49 struct blkcipher_desc desc; 49 struct blkcipher_desc desc;
50 struct sk_buff *trailer; 50 struct sk_buff *trailer;
@@ -86,7 +86,7 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
86 86
87 skb_push(skb, -skb_network_offset(skb)); 87 skb_push(skb, -skb_network_offset(skb));
88 top_iph = ipv6_hdr(skb); 88 top_iph = ipv6_hdr(skb);
89 esph = (struct ipv6_esp_hdr *)skb_transport_header(skb); 89 esph = ip_esp_hdr(skb);
90 top_iph->payload_len = htons(skb->len + alen - sizeof(*top_iph)); 90 top_iph->payload_len = htons(skb->len + alen - sizeof(*top_iph));
91 *(skb_tail_pointer(trailer) - 1) = *skb_mac_header(skb); 91 *(skb_tail_pointer(trailer) - 1) = *skb_mac_header(skb);
92 *skb_mac_header(skb) = IPPROTO_ESP; 92 *skb_mac_header(skb) = IPPROTO_ESP;
@@ -142,19 +142,19 @@ error:
142static int esp6_input(struct xfrm_state *x, struct sk_buff *skb) 142static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
143{ 143{
144 struct ipv6hdr *iph; 144 struct ipv6hdr *iph;
145 struct ipv6_esp_hdr *esph; 145 struct ip_esp_hdr *esph;
146 struct esp_data *esp = x->data; 146 struct esp_data *esp = x->data;
147 struct crypto_blkcipher *tfm = esp->conf.tfm; 147 struct crypto_blkcipher *tfm = esp->conf.tfm;
148 struct blkcipher_desc desc = { .tfm = tfm }; 148 struct blkcipher_desc desc = { .tfm = tfm };
149 struct sk_buff *trailer; 149 struct sk_buff *trailer;
150 int blksize = ALIGN(crypto_blkcipher_blocksize(tfm), 4); 150 int blksize = ALIGN(crypto_blkcipher_blocksize(tfm), 4);
151 int alen = esp->auth.icv_trunc_len; 151 int alen = esp->auth.icv_trunc_len;
152 int elen = skb->len - sizeof(struct ipv6_esp_hdr) - esp->conf.ivlen - alen; 152 int elen = skb->len - sizeof(*esph) - esp->conf.ivlen - alen;
153 int hdr_len = skb_network_header_len(skb); 153 int hdr_len = skb_network_header_len(skb);
154 int nfrags; 154 int nfrags;
155 int ret = 0; 155 int ret = 0;
156 156
157 if (!pskb_may_pull(skb, sizeof(struct ipv6_esp_hdr))) { 157 if (!pskb_may_pull(skb, sizeof(*esph))) {
158 ret = -EINVAL; 158 ret = -EINVAL;
159 goto out; 159 goto out;
160 } 160 }
@@ -189,7 +189,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
189 189
190 skb->ip_summed = CHECKSUM_NONE; 190 skb->ip_summed = CHECKSUM_NONE;
191 191
192 esph = (struct ipv6_esp_hdr*)skb->data; 192 esph = (struct ip_esp_hdr *)skb->data;
193 iph = ipv6_hdr(skb); 193 iph = ipv6_hdr(skb);
194 194
195 /* Get ivec. This can be wrong, check against another impls. */ 195 /* Get ivec. This can be wrong, check against another impls. */
@@ -208,7 +208,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
208 goto out; 208 goto out;
209 } 209 }
210 } 210 }
211 skb_to_sgvec(skb, sg, sizeof(struct ipv6_esp_hdr) + esp->conf.ivlen, elen); 211 skb_to_sgvec(skb, sg, sizeof(*esph) + esp->conf.ivlen, elen);
212 ret = crypto_blkcipher_decrypt(&desc, sg, sg, elen); 212 ret = crypto_blkcipher_decrypt(&desc, sg, sg, elen);
213 if (unlikely(sg != &esp->sgbuf[0])) 213 if (unlikely(sg != &esp->sgbuf[0]))
214 kfree(sg); 214 kfree(sg);
@@ -260,7 +260,7 @@ static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
260 int type, int code, int offset, __be32 info) 260 int type, int code, int offset, __be32 info)
261{ 261{
262 struct ipv6hdr *iph = (struct ipv6hdr*)skb->data; 262 struct ipv6hdr *iph = (struct ipv6hdr*)skb->data;
263 struct ipv6_esp_hdr *esph = (struct ipv6_esp_hdr*)(skb->data+offset); 263 struct ip_esp_hdr *esph = (struct ip_esp_hdr *)(skb->data + offset);
264 struct xfrm_state *x; 264 struct xfrm_state *x;
265 265
266 if (type != ICMPV6_DEST_UNREACH && 266 if (type != ICMPV6_DEST_UNREACH &&
@@ -356,7 +356,7 @@ static int esp6_init_state(struct xfrm_state *x)
356 if (crypto_blkcipher_setkey(tfm, x->ealg->alg_key, 356 if (crypto_blkcipher_setkey(tfm, x->ealg->alg_key,
357 (x->ealg->alg_key_len + 7) / 8)) 357 (x->ealg->alg_key_len + 7) / 8))
358 goto error; 358 goto error;
359 x->props.header_len = sizeof(struct ipv6_esp_hdr) + esp->conf.ivlen; 359 x->props.header_len = sizeof(struct ip_esp_hdr) + esp->conf.ivlen;
360 if (x->props.mode == XFRM_MODE_TUNNEL) 360 if (x->props.mode == XFRM_MODE_TUNNEL)
361 x->props.header_len += sizeof(struct ipv6hdr); 361 x->props.header_len += sizeof(struct ipv6hdr);
362 x->data = esp; 362 x->data = esp;