patch 'app/crypto-perf: fix IPsec direction' has been queued to stable release 22.11.2

Xueming Li xuemingl at nvidia.com
Mon Feb 27 07:58:39 CET 2023


Hi,

FYI, your patch has been queued to stable release 22.11.2

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

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://git.dpdk.org/dpdk-stable/log/?h=22.11-staging

This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=22.11-staging&id=b81247d47bcf7493b1b7354f2ccf4997d99e783b

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From b81247d47bcf7493b1b7354f2ccf4997d99e783b Mon Sep 17 00:00:00 2001
From: Anoob Joseph <anoobj at marvell.com>
Date: Mon, 2 Jan 2023 17:16:55 +0530
Subject: [PATCH] app/crypto-perf: fix IPsec direction
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit 212304008255fa3aa9d380d912488e4552ea7c68 ]

The default value of options->auth_op & options->cipher_op are such that
an unconditional check for the same would always return true. Hence, the
direction is always determined to be outbound/egress.

The field options->aead_algo should be checked prior to checking above
fields. Since the same check would be required in datapath, introduce a
new flag in options for the same.

Fixes: 28dde5da503e ("app/crypto-perf: support lookaside IPsec")

Signed-off-by: Anoob Joseph <anoobj at marvell.com>
Acked-by: Akhil Goyal <gakhil at marvell.com>
---
 app/test-crypto-perf/cperf_ops.c             | 35 +++++++++++---------
 app/test-crypto-perf/cperf_options.h         |  1 +
 app/test-crypto-perf/cperf_options_parsing.c | 15 +++++++++
 3 files changed, 35 insertions(+), 16 deletions(-)

diff --git a/app/test-crypto-perf/cperf_ops.c b/app/test-crypto-perf/cperf_ops.c
index 4a1c9feb1c..93b9bfb240 100644
--- a/app/test-crypto-perf/cperf_ops.c
+++ b/app/test-crypto-perf/cperf_ops.c
@@ -42,8 +42,7 @@ test_ipsec_vec_populate(struct rte_mbuf *m, const struct cperf_options *options,
 {
 	struct rte_ipv4_hdr *ip = rte_pktmbuf_mtod(m, struct rte_ipv4_hdr *);

-	if ((options->aead_op == RTE_CRYPTO_AEAD_OP_ENCRYPT) ||
-		(options->cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT)) {
+	if (options->is_outbound) {
 		memcpy(ip, test_vector->plaintext.data,
 		       sizeof(struct rte_ipv4_hdr));

@@ -645,8 +644,9 @@ create_ipsec_session(struct rte_mempool *sess_mp,
 		const struct cperf_test_vector *test_vector,
 		uint16_t iv_offset)
 {
-	struct rte_crypto_sym_xform xform = {0};
 	struct rte_crypto_sym_xform auth_xform = {0};
+	struct rte_crypto_sym_xform *crypto_xform;
+	struct rte_crypto_sym_xform xform = {0};

 	if (options->aead_algo != 0) {
 		/* Setup AEAD Parameters */
@@ -660,10 +660,10 @@ create_ipsec_session(struct rte_mempool *sess_mp,
 		xform.aead.iv.length = test_vector->aead_iv.length;
 		xform.aead.digest_length = options->digest_sz;
 		xform.aead.aad_length = options->aead_aad_sz;
+		crypto_xform = &xform;
 	} else if (options->cipher_algo != 0 && options->auth_algo != 0) {
 		/* Setup Cipher Parameters */
 		xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
-		xform.next = NULL;
 		xform.cipher.algo = options->cipher_algo;
 		xform.cipher.op = options->cipher_op;
 		xform.cipher.iv.offset = iv_offset;
@@ -680,7 +680,6 @@ create_ipsec_session(struct rte_mempool *sess_mp,

 		/* Setup Auth Parameters */
 		auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
-		auth_xform.next = NULL;
 		auth_xform.auth.algo = options->auth_algo;
 		auth_xform.auth.op = options->auth_op;
 		auth_xform.auth.iv.offset = iv_offset +
@@ -699,7 +698,15 @@ create_ipsec_session(struct rte_mempool *sess_mp,
 			auth_xform.auth.iv.length = 0;
 		}

-		xform.next = &auth_xform;
+		if (options->is_outbound) {
+			crypto_xform = &xform;
+			xform.next = &auth_xform;
+			auth_xform.next = NULL;
+		} else {
+			crypto_xform = &auth_xform;
+			auth_xform.next = &xform;
+			xform.next = NULL;
+		}
 	} else {
 		return NULL;
 	}
@@ -729,23 +736,19 @@ create_ipsec_session(struct rte_mempool *sess_mp,
 			.salt = CPERF_IPSEC_SALT,
 			.options = { 0 },
 			.replay_win_sz = 0,
-			.direction =
-				((options->cipher_op ==
-					RTE_CRYPTO_CIPHER_OP_ENCRYPT) &&
-				(options->auth_op ==
-					RTE_CRYPTO_AUTH_OP_GENERATE)) ||
-				(options->aead_op ==
-					RTE_CRYPTO_AEAD_OP_ENCRYPT) ?
-				RTE_SECURITY_IPSEC_SA_DIR_EGRESS :
-				RTE_SECURITY_IPSEC_SA_DIR_INGRESS,
 			.proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
 			.mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
 			.tunnel = tunnel,
 		} },
 		.userdata = NULL,
-		.crypto_xform = &xform
+		.crypto_xform = crypto_xform,
 	};

+	if (options->is_outbound)
+		sess_conf.ipsec.direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS;
+	else
+		sess_conf.ipsec.direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS;
+
 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
 				rte_cryptodev_get_sec_ctx(dev_id);

diff --git a/app/test-crypto-perf/cperf_options.h b/app/test-crypto-perf/cperf_options.h
index 613d6d31e2..6966e0b286 100644
--- a/app/test-crypto-perf/cperf_options.h
+++ b/app/test-crypto-perf/cperf_options.h
@@ -105,6 +105,7 @@ struct cperf_options {
 	uint32_t out_of_place:1;
 	uint32_t silent:1;
 	uint32_t csv:1;
+	uint32_t is_outbound:1;

 	enum rte_crypto_cipher_algorithm cipher_algo;
 	enum rte_crypto_cipher_operation cipher_op;
diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c
index bc5e312c81..cb91bcc3c5 100644
--- a/app/test-crypto-perf/cperf_options_parsing.c
+++ b/app/test-crypto-perf/cperf_options_parsing.c
@@ -1318,6 +1318,21 @@ cperf_options_check(struct cperf_options *options)
 		if (check_docsis_buffer_length(options) < 0)
 			return -EINVAL;
 	}
+
+	if (options->op_type == CPERF_IPSEC) {
+		if (options->aead_algo) {
+			if (options->aead_op == RTE_CRYPTO_AEAD_OP_ENCRYPT)
+				options->is_outbound = 1;
+			else
+				options->is_outbound = 0;
+		} else {
+			if (options->cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT &&
+			    options->auth_op == RTE_CRYPTO_AUTH_OP_GENERATE)
+				options->is_outbound = 1;
+			else
+				options->is_outbound = 0;
+		}
+	}
 #endif

 	return 0;
--
2.25.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2023-02-27 14:08:41.379350300 +0800
+++ 0012-app-crypto-perf-fix-IPsec-direction.patch	2023-02-27 14:08:40.729237000 +0800
@@ -1 +1 @@
-From 212304008255fa3aa9d380d912488e4552ea7c68 Mon Sep 17 00:00:00 2001
+From b81247d47bcf7493b1b7354f2ccf4997d99e783b Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 212304008255fa3aa9d380d912488e4552ea7c68 ]
@@ -15 +17,0 @@
-Cc: stable at dpdk.org


More information about the stable mailing list