patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Yuanhan Liu <yliu@fridaylinux.org>
To: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Cc: Fan Zhang <roy.fan.zhang@intel.com>, dpdk stable <stable@dpdk.org>
Subject: [dpdk-stable] patch 'examples/l2fwd-crypto: fix padding' has been queued to LTS release 16.11.3
Date: Mon, 24 Jul 2017 03:07:32 +0800	[thread overview]
Message-ID: <1500836852-3563-7-git-send-email-yliu@fridaylinux.org> (raw)
In-Reply-To: <1500836852-3563-1-git-send-email-yliu@fridaylinux.org>

Hi,

FYI, your patch has been queued to LTS release 16.11.3

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 07/27/17. So please
shout if anyone has objections.

Thanks.

	--yliu

---
>From db9af4dc38c3bced06ca4cb7a2fa8550071a2a79 Mon Sep 17 00:00:00 2001
From: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Date: Thu, 9 Feb 2017 12:27:45 +0000
Subject: [PATCH] examples/l2fwd-crypto: fix padding

[ backported from upstream commit 5839fd20e7323850f3a411d9b5642d914fa2d3f0 ]

L2fwd-crypto app was padding an incoming buffer,
to be aligned with the algorithm block size, in all cases.
This was not the right approach, as padding is only necessary
when using block cipher algorithms, such as AES-CBC.
In case of using a stream cipher algorithm, such as SNOW3G UEA2,
there is no need to include padding and increase the buffer size.

Fixes: 387259bd6c67 ("examples/l2fwd-crypto: add sample application")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
---
 examples/l2fwd-crypto/main.c | 35 ++++++++++++++++++++++++++---------
 1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index 91d2c41..b40c49c 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -432,7 +432,8 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,
 	struct ether_hdr *eth_hdr;
 	struct ipv4_hdr *ip_hdr;
 
-	unsigned ipdata_offset, pad_len, data_len;
+	uint32_t ipdata_offset, data_len;
+	uint32_t pad_len = 0;
 	char *padding;
 
 	eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);
@@ -455,16 +456,32 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,
 	if (cparams->do_hash && cparams->hash_verify)
 		data_len -= cparams->digest_length;
 
-	pad_len = data_len % cparams->block_size ? cparams->block_size -
-			(data_len % cparams->block_size) : 0;
+	if (cparams->do_cipher) {
+		/*
+		 * Following algorithms are block cipher algorithms,
+		 * and might need padding
+		 */
+		switch (cparams->cipher_algo) {
+		case RTE_CRYPTO_CIPHER_AES_CBC:
+		case RTE_CRYPTO_CIPHER_AES_ECB:
+		case RTE_CRYPTO_CIPHER_3DES_CBC:
+		case RTE_CRYPTO_CIPHER_3DES_ECB:
+			if (data_len % cparams->block_size)
+				pad_len = cparams->block_size -
+					(data_len % cparams->block_size);
+			break;
+		default:
+			pad_len = 0;
+		}
 
-	if (pad_len) {
-		padding = rte_pktmbuf_append(m, pad_len);
-		if (unlikely(!padding))
-			return -1;
+		if (pad_len) {
+			padding = rte_pktmbuf_append(m, pad_len);
+			if (unlikely(!padding))
+				return -1;
 
-		data_len += pad_len;
-		memset(padding, 0, pad_len);
+			data_len += pad_len;
+			memset(padding, 0, pad_len);
+		}
 	}
 
 	/* Set crypto operation data parameters */
-- 
2.7.4

      parent reply	other threads:[~2017-07-23 19:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-23 19:07 [dpdk-stable] patch 'mbuf: fix VXLAN port in comment' " Yuanhan Liu
2017-07-23 19:07 ` [dpdk-stable] patch 'net/e1000: fix LSC interrupt' " Yuanhan Liu
2017-07-23 19:07 ` [dpdk-stable] patch 'net/i40e: fix ethertype filter for new FW' " Yuanhan Liu
2017-07-23 19:07 ` [dpdk-stable] patch 'net/ixgbe: fix Rx/Tx queue interrupt for x550 devices' " Yuanhan Liu
2017-07-23 19:07 ` [dpdk-stable] patch 'crypto/qat: fix NULL authentication hang' " Yuanhan Liu
2017-07-23 19:07 ` [dpdk-stable] patch 'examples/qos_sched: fix build for less lcores' " Yuanhan Liu
2017-07-23 19:07 ` Yuanhan Liu [this message]

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=1500836852-3563-7-git-send-email-yliu@fridaylinux.org \
    --to=yliu@fridaylinux.org \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=roy.fan.zhang@intel.com \
    --cc=stable@dpdk.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).