aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/esp6.c
diff options
context:
space:
mode:
authorMathias Krause <mathias.krause@secunet.com>2013-10-18 06:09:05 -0400
committerSteffen Klassert <steffen.klassert@secunet.com>2013-10-29 01:39:42 -0400
commit1c5ad13f7c2b2afe30e43858d04fff979dc9d243 (patch)
treefc68ea62c7d59c08b464ad47daea13db0adf1484 /net/ipv6/esp6.c
parent123b0d1ba0a98ef12550d82b79ccb8d89090f871 (diff)
net: esp{4,6}: get rid of struct esp_data
struct esp_data consists of a single pointer, vanishing the need for it to be a structure. Fold the pointer into 'data' direcly, removing one level of pointer indirection. Signed-off-by: Mathias Krause <mathias.krause@secunet.com> Cc: Steffen Klassert <steffen.klassert@secunet.com> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: "David S. Miller" <davem@davemloft.net> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Diffstat (limited to 'net/ipv6/esp6.c')
-rw-r--r--net/ipv6/esp6.c39
1 files changed, 14 insertions, 25 deletions
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 0073cd096984..87eb79e65e49 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -164,10 +164,9 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
164 u8 *iv; 164 u8 *iv;
165 u8 *tail; 165 u8 *tail;
166 __be32 *seqhi; 166 __be32 *seqhi;
167 struct esp_data *esp = x->data;
168 167
169 /* skb is pure payload to encrypt */ 168 /* skb is pure payload to encrypt */
170 aead = esp->aead; 169 aead = x->data;
171 alen = crypto_aead_authsize(aead); 170 alen = crypto_aead_authsize(aead);
172 171
173 tfclen = 0; 172 tfclen = 0;
@@ -269,8 +268,7 @@ error:
269static int esp_input_done2(struct sk_buff *skb, int err) 268static int esp_input_done2(struct sk_buff *skb, int err)
270{ 269{
271 struct xfrm_state *x = xfrm_input_state(skb); 270 struct xfrm_state *x = xfrm_input_state(skb);
272 struct esp_data *esp = x->data; 271 struct crypto_aead *aead = x->data;
273 struct crypto_aead *aead = esp->aead;
274 int alen = crypto_aead_authsize(aead); 272 int alen = crypto_aead_authsize(aead);
275 int hlen = sizeof(struct ip_esp_hdr) + crypto_aead_ivsize(aead); 273 int hlen = sizeof(struct ip_esp_hdr) + crypto_aead_ivsize(aead);
276 int elen = skb->len - hlen; 274 int elen = skb->len - hlen;
@@ -323,8 +321,7 @@ static void esp_input_done(struct crypto_async_request *base, int err)
323static int esp6_input(struct xfrm_state *x, struct sk_buff *skb) 321static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
324{ 322{
325 struct ip_esp_hdr *esph; 323 struct ip_esp_hdr *esph;
326 struct esp_data *esp = x->data; 324 struct crypto_aead *aead = x->data;
327 struct crypto_aead *aead = esp->aead;
328 struct aead_request *req; 325 struct aead_request *req;
329 struct sk_buff *trailer; 326 struct sk_buff *trailer;
330 int elen = skb->len - sizeof(*esph) - crypto_aead_ivsize(aead); 327 int elen = skb->len - sizeof(*esph) - crypto_aead_ivsize(aead);
@@ -412,8 +409,8 @@ out:
412 409
413static u32 esp6_get_mtu(struct xfrm_state *x, int mtu) 410static u32 esp6_get_mtu(struct xfrm_state *x, int mtu)
414{ 411{
415 struct esp_data *esp = x->data; 412 struct crypto_aead *aead = x->data;
416 u32 blksize = ALIGN(crypto_aead_blocksize(esp->aead), 4); 413 u32 blksize = ALIGN(crypto_aead_blocksize(aead), 4);
417 unsigned int net_adj; 414 unsigned int net_adj;
418 415
419 if (x->props.mode != XFRM_MODE_TUNNEL) 416 if (x->props.mode != XFRM_MODE_TUNNEL)
@@ -421,7 +418,7 @@ static u32 esp6_get_mtu(struct xfrm_state *x, int mtu)
421 else 418 else
422 net_adj = 0; 419 net_adj = 0;
423 420
424 return ((mtu - x->props.header_len - crypto_aead_authsize(esp->aead) - 421 return ((mtu - x->props.header_len - crypto_aead_authsize(aead) -
425 net_adj) & ~(blksize - 1)) + net_adj - 2; 422 net_adj) & ~(blksize - 1)) + net_adj - 2;
426} 423}
427 424
@@ -452,18 +449,16 @@ static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
452 449
453static void esp6_destroy(struct xfrm_state *x) 450static void esp6_destroy(struct xfrm_state *x)
454{ 451{
455 struct esp_data *esp = x->data; 452 struct crypto_aead *aead = x->data;
456 453
457 if (!esp) 454 if (!aead)
458 return; 455 return;
459 456
460 crypto_free_aead(esp->aead); 457 crypto_free_aead(aead);
461 kfree(esp);
462} 458}
463 459
464static int esp_init_aead(struct xfrm_state *x) 460static int esp_init_aead(struct xfrm_state *x)
465{ 461{
466 struct esp_data *esp = x->data;
467 struct crypto_aead *aead; 462 struct crypto_aead *aead;
468 int err; 463 int err;
469 464
@@ -472,7 +467,7 @@ static int esp_init_aead(struct xfrm_state *x)
472 if (IS_ERR(aead)) 467 if (IS_ERR(aead))
473 goto error; 468 goto error;
474 469
475 esp->aead = aead; 470 x->data = aead;
476 471
477 err = crypto_aead_setkey(aead, x->aead->alg_key, 472 err = crypto_aead_setkey(aead, x->aead->alg_key,
478 (x->aead->alg_key_len + 7) / 8); 473 (x->aead->alg_key_len + 7) / 8);
@@ -489,7 +484,6 @@ error:
489 484
490static int esp_init_authenc(struct xfrm_state *x) 485static int esp_init_authenc(struct xfrm_state *x)
491{ 486{
492 struct esp_data *esp = x->data;
493 struct crypto_aead *aead; 487 struct crypto_aead *aead;
494 struct crypto_authenc_key_param *param; 488 struct crypto_authenc_key_param *param;
495 struct rtattr *rta; 489 struct rtattr *rta;
@@ -524,7 +518,7 @@ static int esp_init_authenc(struct xfrm_state *x)
524 if (IS_ERR(aead)) 518 if (IS_ERR(aead))
525 goto error; 519 goto error;
526 520
527 esp->aead = aead; 521 x->data = aead;
528 522
529 keylen = (x->aalg ? (x->aalg->alg_key_len + 7) / 8 : 0) + 523 keylen = (x->aalg ? (x->aalg->alg_key_len + 7) / 8 : 0) +
530 (x->ealg->alg_key_len + 7) / 8 + RTA_SPACE(sizeof(*param)); 524 (x->ealg->alg_key_len + 7) / 8 + RTA_SPACE(sizeof(*param));
@@ -579,7 +573,6 @@ error:
579 573
580static int esp6_init_state(struct xfrm_state *x) 574static int esp6_init_state(struct xfrm_state *x)
581{ 575{
582 struct esp_data *esp;
583 struct crypto_aead *aead; 576 struct crypto_aead *aead;
584 u32 align; 577 u32 align;
585 int err; 578 int err;
@@ -587,11 +580,7 @@ static int esp6_init_state(struct xfrm_state *x)
587 if (x->encap) 580 if (x->encap)
588 return -EINVAL; 581 return -EINVAL;
589 582
590 esp = kzalloc(sizeof(*esp), GFP_KERNEL); 583 x->data = NULL;
591 if (esp == NULL)
592 return -ENOMEM;
593
594 x->data = esp;
595 584
596 if (x->aead) 585 if (x->aead)
597 err = esp_init_aead(x); 586 err = esp_init_aead(x);
@@ -601,7 +590,7 @@ static int esp6_init_state(struct xfrm_state *x)
601 if (err) 590 if (err)
602 goto error; 591 goto error;
603 592
604 aead = esp->aead; 593 aead = x->data;
605 594
606 x->props.header_len = sizeof(struct ip_esp_hdr) + 595 x->props.header_len = sizeof(struct ip_esp_hdr) +
607 crypto_aead_ivsize(aead); 596 crypto_aead_ivsize(aead);
@@ -621,7 +610,7 @@ static int esp6_init_state(struct xfrm_state *x)
621 } 610 }
622 611
623 align = ALIGN(crypto_aead_blocksize(aead), 4); 612 align = ALIGN(crypto_aead_blocksize(aead), 4);
624 x->props.trailer_len = align + 1 + crypto_aead_authsize(esp->aead); 613 x->props.trailer_len = align + 1 + crypto_aead_authsize(aead);
625 614
626error: 615error:
627 return err; 616 return err;