linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steffen Klassert <steffen.klassert@secunet.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org, netdev@vger.kernel.org
Subject: [RFC] [PATCH 1/7] esp: Add an additional scatterlist entry for the assoc data
Date: Thu, 16 Jul 2009 13:16:29 +0200	[thread overview]
Message-ID: <20090716111629.GQ20288@secunet.com> (raw)
In-Reply-To: <20090716111548.GP20288@secunet.com>

To be able to chain all the scatterlists we add an additional
scatterlist entry to the scatterlist of the associated data.
To keep compatibility we set the termination bit at the first
entry. This can be reverted as soon as we can use sg_chain().

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 net/ipv4/esp4.c |   23 +++++++++++++++++------
 net/ipv6/esp6.c |   25 +++++++++++++++++++------
 2 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index 18bb383..dbb1a33 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -139,14 +139,14 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
 		goto error;
 	nfrags = err;
 
-	tmp = esp_alloc_tmp(aead, nfrags + 1);
+	tmp = esp_alloc_tmp(aead, nfrags + 2);
 	if (!tmp)
 		goto error;
 
 	iv = esp_tmp_iv(aead, tmp);
 	req = esp_tmp_givreq(aead, iv);
 	asg = esp_givreq_sg(aead, req);
-	sg = asg + 1;
+	sg = asg + 2;
 
 	/* Fill padding... */
 	tail = skb_tail_pointer(trailer);
@@ -205,7 +205,16 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
 	skb_to_sgvec(skb, sg,
 		     esph->enc_data + crypto_aead_ivsize(aead) - skb->data,
 		     clen + alen);
-	sg_init_one(asg, esph, sizeof(*esph));
+
+	/*
+	 * We add an additional scatterlist entry to be able to chain up
+	 * the scatterlists in the crypto layer. To keep compatibility we
+	 * set the termination bit at the first entry. This can be removed
+	 * as soon as as architectures support scatterlist chaining.
+	 */
+	sg_init_table(asg, 2);
+	sg_mark_end(asg);
+	sg_set_buf(asg, esph, sizeof(*esph));
 
 	aead_givcrypt_set_callback(req, 0, esp_output_done, skb);
 	aead_givcrypt_set_crypt(req, sg, sg, clen, iv);
@@ -347,7 +356,7 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
 	nfrags = err;
 
 	err = -ENOMEM;
-	tmp = esp_alloc_tmp(aead, nfrags + 1);
+	tmp = esp_alloc_tmp(aead, nfrags + 2);
 	if (!tmp)
 		goto out;
 
@@ -355,7 +364,7 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
 	iv = esp_tmp_iv(aead, tmp);
 	req = esp_tmp_req(aead, iv);
 	asg = esp_req_sg(aead, req);
-	sg = asg + 1;
+	sg = asg + 2;
 
 	skb->ip_summed = CHECKSUM_NONE;
 
@@ -366,7 +375,9 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
 
 	sg_init_table(sg, nfrags);
 	skb_to_sgvec(skb, sg, sizeof(*esph) + crypto_aead_ivsize(aead), elen);
-	sg_init_one(asg, esph, sizeof(*esph));
+	sg_init_table(asg, 2);
+	sg_mark_end(asg);
+	sg_set_buf(asg, esph, sizeof(*esph));
 
 	aead_request_set_callback(req, 0, esp_input_done, skb);
 	aead_request_set_crypt(req, sg, sg, elen, iv);
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 678bb95..6ba707a 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -163,14 +163,14 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
 		goto error;
 	nfrags = err;
 
-	tmp = esp_alloc_tmp(aead, nfrags + 1);
+	tmp = esp_alloc_tmp(aead, nfrags + 2);
 	if (!tmp)
 		goto error;
 
 	iv = esp_tmp_iv(aead, tmp);
 	req = esp_tmp_givreq(aead, iv);
 	asg = esp_givreq_sg(aead, req);
-	sg = asg + 1;
+	sg = asg + 2;
 
 	/* Fill padding... */
 	tail = skb_tail_pointer(trailer);
@@ -194,7 +194,17 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
 	skb_to_sgvec(skb, sg,
 		     esph->enc_data + crypto_aead_ivsize(aead) - skb->data,
 		     clen + alen);
-	sg_init_one(asg, esph, sizeof(*esph));
+
+
+	/*
+	 * We add an additional scatterlist entry to be able to chain up
+	 * the scatterlists in the crypto layer. To keep compatibility we
+	 * set the termination bit at the first entry. This can be removed
+	 * as soon as as architectures support scatterlist chaining.
+	 */
+	sg_init_table(asg, 2);
+	sg_mark_end(asg);
+	sg_set_buf(asg, esph, sizeof(*esph));
 
 	aead_givcrypt_set_callback(req, 0, esp_output_done, skb);
 	aead_givcrypt_set_crypt(req, sg, sg, clen, iv);
@@ -298,7 +308,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
 	}
 
 	ret = -ENOMEM;
-	tmp = esp_alloc_tmp(aead, nfrags + 1);
+	tmp = esp_alloc_tmp(aead, nfrags + 2);
 	if (!tmp)
 		goto out;
 
@@ -306,7 +316,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
 	iv = esp_tmp_iv(aead, tmp);
 	req = esp_tmp_req(aead, iv);
 	asg = esp_req_sg(aead, req);
-	sg = asg + 1;
+	sg = asg + 2;
 
 	skb->ip_summed = CHECKSUM_NONE;
 
@@ -317,7 +327,10 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
 
 	sg_init_table(sg, nfrags);
 	skb_to_sgvec(skb, sg, sizeof(*esph) + crypto_aead_ivsize(aead), elen);
-	sg_init_one(asg, esph, sizeof(*esph));
+
+	sg_init_table(asg, 2);
+	sg_mark_end(asg);
+	sg_set_buf(asg, esph, sizeof(*esph));
 
 	aead_request_set_callback(req, 0, esp_input_done, skb);
 	aead_request_set_crypt(req, sg, sg, elen, iv);
-- 
1.5.4.2


  reply	other threads:[~2009-07-16 11:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-16 11:15 [RFC] [PATCH 0/7] IPsec: convert to ahash Steffen Klassert
2009-07-16 11:16 ` Steffen Klassert [this message]
2009-07-16 11:17 ` [RFC] [PATCH 2/7] crypto: authenc - " Steffen Klassert
2009-07-17 17:03   ` David Miller
2009-07-20  6:26     ` Steffen Klassert
2009-07-20  6:55       ` Herbert Xu
2009-07-20  7:57         ` Steffen Klassert
2009-07-20  8:21           ` Herbert Xu
2009-07-20  8:36             ` Steffen Klassert
2009-07-20  8:50               ` Herbert Xu
2009-07-16 11:18 ` [RFC] [PATCH 3/7] ah: Add struct crypto_ahash to ah_data Steffen Klassert
2009-07-16 11:19 ` [RFC] [PATCH 4/7] ah4: convert to ahash Steffen Klassert
2009-07-21  6:53   ` Herbert Xu
2009-07-16 11:19 ` [RFC] [PATCH 5/7] ah6: " Steffen Klassert
2009-07-16 11:20 ` [RFC] [PATCH 6/7] ah: Remove obsolete code Steffen Klassert
2009-07-16 11:21 ` [RFC] [PATCH 7/7] xfrm: remove skb_icv_walk Steffen Klassert
2009-07-16 15:46 ` [RFC] [PATCH 0/7] IPsec: convert to ahash Herbert Xu
2009-07-17  6:11   ` Steffen Klassert
2009-07-17  7:42   ` Steffen Klassert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090716111629.GQ20288@secunet.com \
    --to=steffen.klassert@secunet.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).