From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5E64241D52 for ; Thu, 23 Feb 2023 16:07:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3E81E43232; Thu, 23 Feb 2023 16:07:03 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 1BD9B4321C for ; Thu, 23 Feb 2023 16:07:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677164821; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CEkPDwVohMBWjY6Gqa500p+8eZqTkEvjVH/29uphi5o=; b=PFgxxkN8mKpvrGydpEDIf+vHtVGZvsCueC/lMDhfuSkitiqR96zLg0fRyVHV2Ev2g/tsdt Lj8ux9gcetQA8FGRiBgIwShKyg/scMj66jsqc6dBEDOtAavLy+FHc4+kL185XDanFwdHBM g+gvGHde0D3lGJ2eV418M2D3la0zNik= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-558-12ata2gtOo6MEX6oWeMVhA-1; Thu, 23 Feb 2023 10:06:59 -0500 X-MC-Unique: 12ata2gtOo6MEX6oWeMVhA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 61DB31C087BF; Thu, 23 Feb 2023 15:06:59 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.192.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE5932166B2C; Thu, 23 Feb 2023 15:06:58 +0000 (UTC) From: Kevin Traynor To: Anoob Joseph Cc: Akhil Goyal , dpdk stable Subject: patch 'app/crypto-perf: fix IPsec direction' has been queued to stable release 21.11.4 Date: Thu, 23 Feb 2023 15:04:58 +0000 Message-Id: <20230223150631.723699-7-ktraynor@redhat.com> In-Reply-To: <20230223150631.723699-1-ktraynor@redhat.com> References: <20230223150631.723699-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 21.11.4 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/28/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://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/a66803521710012213535e8e0f66508e14ed6501 Thanks. Kevin --- >From a66803521710012213535e8e0f66508e14ed6501 Mon Sep 17 00:00:00 2001 From: Anoob Joseph Date: Mon, 2 Jan 2023 17:16:55 +0530 Subject: [PATCH] app/crypto-perf: fix IPsec direction [ 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 Acked-by: Akhil Goyal --- 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 3b8b97b043..698c44ed30 100644 --- a/app/test-crypto-perf/cperf_ops.c +++ b/app/test-crypto-perf/cperf_ops.c @@ -44,6 +44,5 @@ 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, m->data_len); @@ -614,6 +613,7 @@ create_ipsec_session(struct rte_mempool *sess_mp, 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) { @@ -629,8 +629,8 @@ create_ipsec_session(struct rte_mempool *sess_mp, 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; @@ -649,5 +649,4 @@ 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; @@ -668,5 +667,13 @@ create_ipsec_session(struct rte_mempool *sess_mp, } - 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; @@ -698,13 +705,4 @@ create_ipsec_session(struct rte_mempool *sess_mp, .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, @@ -712,7 +710,12 @@ create_ipsec_session(struct rte_mempool *sess_mp, } }, .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 031b238b20..5533b2e6fb 100644 --- a/app/test-crypto-perf/cperf_options.h +++ b/app/test-crypto-perf/cperf_options.h @@ -104,4 +104,5 @@ struct cperf_options { uint32_t silent:1; uint32_t csv:1; + uint32_t is_outbound:1; enum rte_crypto_cipher_algorithm cipher_algo; diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c index 59a9dc596a..0858640723 100644 --- a/app/test-crypto-perf/cperf_options_parsing.c +++ b/app/test-crypto-perf/cperf_options_parsing.c @@ -1249,4 +1249,19 @@ cperf_options_check(struct cperf_options *options) 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 -- 2.39.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-02-23 14:46:24.038725011 +0000 +++ 0007-app-crypto-perf-fix-IPsec-direction.patch 2023-02-23 14:46:23.704235736 +0000 @@ -1 +1 @@ -From 212304008255fa3aa9d380d912488e4552ea7c68 Mon Sep 17 00:00:00 2001 +From a66803521710012213535e8e0f66508e14ed6501 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 212304008255fa3aa9d380d912488e4552ea7c68 ] + @@ -15 +16,0 @@ -Cc: stable@dpdk.org @@ -26 +27 @@ -index 4a1c9feb1c..93b9bfb240 100644 +index 3b8b97b043..698c44ed30 100644 @@ -29 +30 @@ -@@ -43,6 +43,5 @@ test_ipsec_vec_populate(struct rte_mbuf *m, const struct cperf_options *options, +@@ -44,6 +44,5 @@ test_ipsec_vec_populate(struct rte_mbuf *m, const struct cperf_options *options, @@ -35,3 +36,3 @@ - memcpy(ip, test_vector->plaintext.data, - sizeof(struct rte_ipv4_hdr)); -@@ -646,6 +645,7 @@ create_ipsec_session(struct rte_mempool *sess_mp, + memcpy(ip, test_vector->plaintext.data, m->data_len); + +@@ -614,6 +613,7 @@ create_ipsec_session(struct rte_mempool *sess_mp, @@ -46 +47 @@ -@@ -661,8 +661,8 @@ create_ipsec_session(struct rte_mempool *sess_mp, +@@ -629,8 +629,8 @@ create_ipsec_session(struct rte_mempool *sess_mp, @@ -56 +57 @@ -@@ -681,5 +681,4 @@ create_ipsec_session(struct rte_mempool *sess_mp, +@@ -649,5 +649,4 @@ create_ipsec_session(struct rte_mempool *sess_mp, @@ -62 +63 @@ -@@ -700,5 +699,13 @@ create_ipsec_session(struct rte_mempool *sess_mp, +@@ -668,5 +667,13 @@ create_ipsec_session(struct rte_mempool *sess_mp, @@ -77 +78 @@ -@@ -730,13 +737,4 @@ create_ipsec_session(struct rte_mempool *sess_mp, +@@ -698,13 +705,4 @@ create_ipsec_session(struct rte_mempool *sess_mp, @@ -91 +92 @@ -@@ -744,7 +742,12 @@ create_ipsec_session(struct rte_mempool *sess_mp, +@@ -712,7 +710,12 @@ create_ipsec_session(struct rte_mempool *sess_mp, @@ -106 +107 @@ -index 613d6d31e2..6966e0b286 100644 +index 031b238b20..5533b2e6fb 100644 @@ -109 +110 @@ -@@ -106,4 +106,5 @@ struct cperf_options { +@@ -104,4 +104,5 @@ struct cperf_options { @@ -116 +117 @@ -index bc5e312c81..cb91bcc3c5 100644 +index 59a9dc596a..0858640723 100644 @@ -119 +120 @@ -@@ -1319,4 +1319,19 @@ cperf_options_check(struct cperf_options *options) +@@ -1249,4 +1249,19 @@ cperf_options_check(struct cperf_options *options)