patch 'test/crypto: fix missing return checks' has been queued to stable release 20.11.4
Xueming Li
xuemingl at nvidia.com
Sun Nov 28 15:53:37 CET 2021
Hi,
FYI, your patch has been queued to stable release 20.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 11/30/21. 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/steevenlee/dpdk
This queued commit can be viewed at:
https://github.com/steevenlee/dpdk/commit/ce1df1c241eec4e077d0c705f59dbc878715a382
Thanks.
Xueming Li <xuemingl at nvidia.com>
---
>From ce1df1c241eec4e077d0c705f59dbc878715a382 Mon Sep 17 00:00:00 2001
From: Anoob Joseph <anoobj at marvell.com>
Date: Mon, 8 Nov 2021 20:43:46 +0530
Subject: [PATCH] test/crypto: fix missing return checks
Cc: Xueming Li <xuemingl at nvidia.com>
[ upstream commit 0015b149bcc59bdd5d8797c8e19c26b0f6f1b40d ]
The API could return errors. Add error checking for the same.
Fixes: b3bbd9e5f265 ("cryptodev: support device independent sessions")
Signed-off-by: Anoob Joseph <anoobj at marvell.com>
Acked-by: Akhil Goyal <gakhil at marvell.com>
---
app/test/test_cryptodev.c | 116 ++++++++++++++++++++++++++------------
1 file changed, 80 insertions(+), 36 deletions(-)
diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 7a205a2b00..a655c37a10 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -1675,6 +1675,7 @@ test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
{
struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params;
+ int status;
/* Verify the capabilities */
struct rte_cryptodev_sym_capability_idx cap_idx;
@@ -1721,12 +1722,17 @@ test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
ut_params->sess = rte_cryptodev_sym_session_create(
ts_params->session_mpool);
+ TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
/* Create crypto session*/
- rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+ status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
ut_params->sess, &ut_params->cipher_xform,
ts_params->session_priv_mpool);
- TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
+
+ if (status == -ENOTSUP)
+ return TEST_SKIPPED;
+
+ TEST_ASSERT_EQUAL(status, 0, "Session init failed");
/* Generate crypto op data structure */
ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
@@ -7439,6 +7445,7 @@ create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
uint8_t iv_len)
{
uint8_t aead_key[key_len];
+ int status;
struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params;
@@ -7462,14 +7469,13 @@ create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
/* Create Crypto session*/
ut_params->sess = rte_cryptodev_sym_session_create(
ts_params->session_mpool);
+ TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
- rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+ status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
&ut_params->aead_xform,
ts_params->session_priv_mpool);
- TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
-
- return 0;
+ return status;
}
static int
@@ -10190,6 +10196,7 @@ static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
const struct HMAC_MD5_vector *test_case)
{
uint8_t key[64];
+ int status;
memcpy(key, test_case->key.data, test_case->key.len);
@@ -10205,13 +10212,15 @@ static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
ut_params->sess = rte_cryptodev_sym_session_create(
ts_params->session_mpool);
+ TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
+ if (ut_params->sess == NULL)
+ return TEST_FAILED;
- rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+ status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
ut_params->sess, &ut_params->auth_xform,
ts_params->session_priv_mpool);
-
- if (ut_params->sess == NULL)
- return TEST_FAILED;
+ if (status == -ENOTSUP)
+ return TEST_SKIPPED;
ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
@@ -10424,6 +10433,7 @@ test_multi_session(void)
struct rte_cryptodev_sym_session **sessions;
uint16_t i;
+ int status;
/* Verify the capabilities */
struct rte_cryptodev_sym_capability_idx cap_idx;
@@ -10453,14 +10463,17 @@ test_multi_session(void)
sessions[i] = rte_cryptodev_sym_session_create(
ts_params->session_mpool);
-
- rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
- sessions[i], &ut_params->auth_xform,
- ts_params->session_priv_mpool);
TEST_ASSERT_NOT_NULL(sessions[i],
"Session creation failed at session number %u",
i);
+ status = rte_cryptodev_sym_session_init(
+ ts_params->valid_devs[0],
+ sessions[i], &ut_params->auth_xform,
+ ts_params->session_priv_mpool);
+ if (status == -ENOTSUP)
+ return TEST_SKIPPED;
+
/* Attempt to send a request on each session */
TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
sessions[i],
@@ -10553,6 +10566,7 @@ test_multi_session_random_usage(void)
},
};
+ int status;
/* Verify the capabilities */
struct rte_cryptodev_sym_capability_idx cap_idx;
@@ -10576,6 +10590,9 @@ test_multi_session_random_usage(void)
for (i = 0; i < MB_SESSION_NUMBER; i++) {
sessions[i] = rte_cryptodev_sym_session_create(
ts_params->session_mpool);
+ TEST_ASSERT_NOT_NULL(sessions[i],
+ "Session creation failed at session number %u",
+ i);
rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
sizeof(struct crypto_unittest_params));
@@ -10585,16 +10602,16 @@ test_multi_session_random_usage(void)
ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
/* Create multiple crypto sessions*/
- rte_cryptodev_sym_session_init(
+ status = rte_cryptodev_sym_session_init(
ts_params->valid_devs[0],
sessions[i],
&ut_paramz[i].ut_params.auth_xform,
ts_params->session_priv_mpool);
- TEST_ASSERT_NOT_NULL(sessions[i],
- "Session creation failed at session number %u",
- i);
+ if (status == -ENOTSUP)
+ return TEST_SKIPPED;
+ TEST_ASSERT_EQUAL(status, 0, "Session init failed");
}
srand(time(NULL));
@@ -10706,6 +10723,7 @@ test_null_burst_operation(void)
{
struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params;
+ int status;
unsigned i, burst_len = NULL_BURST_LENGTH;
@@ -10733,12 +10751,17 @@ test_null_burst_operation(void)
ut_params->sess = rte_cryptodev_sym_session_create(
ts_params->session_mpool);
+ TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
/* Create Crypto session*/
- rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+ status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
ut_params->sess, &ut_params->cipher_xform,
ts_params->session_priv_mpool);
- TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
+
+ if (status == -ENOTSUP)
+ return TEST_SKIPPED;
+
+ TEST_ASSERT_EQUAL(status, 0, "Session init failed");
TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
@@ -10896,6 +10919,7 @@ static int create_gmac_session(uint8_t dev_id,
enum rte_crypto_auth_operation auth_op)
{
uint8_t auth_key[tdata->key.len];
+ int status;
struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params;
@@ -10916,14 +10940,13 @@ static int create_gmac_session(uint8_t dev_id,
ut_params->sess = rte_cryptodev_sym_session_create(
ts_params->session_mpool);
+ TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
- rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+ status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
&ut_params->auth_xform,
ts_params->session_priv_mpool);
- TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
-
- return 0;
+ return status;
}
static int
@@ -10961,6 +10984,8 @@ test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
retval = create_gmac_session(ts_params->valid_devs[0],
tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
+ if (retval == -ENOTSUP)
+ return TEST_SKIPPED;
if (retval < 0)
return retval;
@@ -11090,6 +11115,8 @@ test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
retval = create_gmac_session(ts_params->valid_devs[0],
tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
+ if (retval == -ENOTSUP)
+ return TEST_SKIPPED;
if (retval < 0)
return retval;
@@ -11217,6 +11244,8 @@ test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
retval = create_gmac_session(ts_params->valid_devs[0],
tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
+ if (retval == -ENOTSUP)
+ return TEST_SKIPPED;
if (retval < 0)
return retval;
@@ -11546,6 +11575,7 @@ create_auth_session(struct crypto_unittest_params *ut_params,
{
struct crypto_testsuite_params *ts_params = &testsuite_params;
uint8_t auth_key[reference->auth_key.len + 1];
+ int status;
memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
@@ -11561,14 +11591,13 @@ create_auth_session(struct crypto_unittest_params *ut_params,
/* Create Crypto session*/
ut_params->sess = rte_cryptodev_sym_session_create(
ts_params->session_mpool);
+ TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
- rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+ status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
&ut_params->auth_xform,
ts_params->session_priv_mpool);
- TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
-
- return 0;
+ return status;
}
static int
@@ -11581,6 +11610,7 @@ create_auth_cipher_session(struct crypto_unittest_params *ut_params,
struct crypto_testsuite_params *ts_params = &testsuite_params;
uint8_t cipher_key[reference->cipher_key.len + 1];
uint8_t auth_key[reference->auth_key.len + 1];
+ int status;
memcpy(cipher_key, reference->cipher_key.data,
reference->cipher_key.len);
@@ -11614,14 +11644,13 @@ create_auth_cipher_session(struct crypto_unittest_params *ut_params,
/* Create Crypto session*/
ut_params->sess = rte_cryptodev_sym_session_create(
ts_params->session_mpool);
+ TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
- rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+ status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
&ut_params->auth_xform,
ts_params->session_priv_mpool);
- TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
-
- return 0;
+ return status;
}
static int
@@ -11837,6 +11866,9 @@ test_authentication_verify_fail_when_data_corruption(
ts_params->valid_devs[0],
reference,
RTE_CRYPTO_AUTH_OP_VERIFY);
+
+ if (retval == -ENOTSUP)
+ return TEST_SKIPPED;
if (retval < 0)
return retval;
@@ -12009,6 +12041,9 @@ test_authenticated_decryption_fail_when_corruption(
reference,
RTE_CRYPTO_AUTH_OP_VERIFY,
RTE_CRYPTO_CIPHER_OP_DECRYPT);
+
+ if (retval == -ENOTSUP)
+ return TEST_SKIPPED;
if (retval < 0)
return retval;
@@ -12121,13 +12156,17 @@ test_authenticated_encrypt_with_esn(
/* Create Crypto session*/
ut_params->sess = rte_cryptodev_sym_session_create(
ts_params->session_mpool);
+ TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
- rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+ status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
ut_params->sess,
&ut_params->cipher_xform,
ts_params->session_priv_mpool);
- TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
+ if (status == -ENOTSUP)
+ return TEST_SKIPPED;
+
+ TEST_ASSERT_EQUAL(status, 0, "Session init failed");
ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
TEST_ASSERT_NOT_NULL(ut_params->ibuf,
@@ -12203,6 +12242,7 @@ test_authenticated_decrypt_with_esn(
uint8_t cipher_key[reference->cipher_key.len + 1];
uint8_t auth_key[reference->auth_key.len + 1];
struct rte_cryptodev_info dev_info;
+ int status;
rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
uint64_t feat_flags = dev_info.feature_flags;
@@ -12253,13 +12293,17 @@ test_authenticated_decrypt_with_esn(
/* Create Crypto session*/
ut_params->sess = rte_cryptodev_sym_session_create(
ts_params->session_mpool);
+ TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
- rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+ retval = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
ut_params->sess,
&ut_params->auth_xform,
ts_params->session_priv_mpool);
- TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
+ if (retval == -ENOTSUP)
+ return TEST_SKIPPED;
+
+ TEST_ASSERT_EQUAL(retval, 0, "Session init failed");
ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
TEST_ASSERT_NOT_NULL(ut_params->ibuf,
--
2.34.0
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2021-11-28 22:41:05.095528780 +0800
+++ 0033-test-crypto-fix-missing-return-checks.patch 2021-11-28 22:41:03.273541825 +0800
@@ -1 +1 @@
-From 0015b149bcc59bdd5d8797c8e19c26b0f6f1b40d Mon Sep 17 00:00:00 2001
+From ce1df1c241eec4e077d0c705f59dbc878715a382 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 0015b149bcc59bdd5d8797c8e19c26b0f6f1b40d ]
@@ -9 +11,0 @@
-Cc: stable at dpdk.org
@@ -18 +20 @@
-index 29e8675e30..ef0433680c 100644
+index 7a205a2b00..a655c37a10 100644
@@ -21 +23 @@
-@@ -2138,6 +2138,7 @@ test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
+@@ -1675,6 +1675,7 @@ test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
@@ -29 +31 @@
-@@ -2184,12 +2185,17 @@ test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
+@@ -1721,12 +1722,17 @@ test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
@@ -49 +51 @@
-@@ -7972,6 +7978,7 @@ create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
+@@ -7439,6 +7445,7 @@ create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
@@ -57 +59 @@
-@@ -7995,14 +8002,13 @@ create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
+@@ -7462,14 +7469,13 @@ create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
@@ -75 +77 @@
-@@ -11103,6 +11109,7 @@ static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
+@@ -10190,6 +10196,7 @@ static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
@@ -83 +85 @@
-@@ -11118,13 +11125,15 @@ static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
+@@ -10205,13 +10212,15 @@ static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
@@ -103 +105 @@
-@@ -11337,6 +11346,7 @@ test_multi_session(void)
+@@ -10424,6 +10433,7 @@ test_multi_session(void)
@@ -111 +113 @@
-@@ -11366,14 +11376,17 @@ test_multi_session(void)
+@@ -10453,14 +10463,17 @@ test_multi_session(void)
@@ -133 +135 @@
-@@ -11466,6 +11479,7 @@ test_multi_session_random_usage(void)
+@@ -10553,6 +10566,7 @@ test_multi_session_random_usage(void)
@@ -141 +143 @@
-@@ -11489,6 +11503,9 @@ test_multi_session_random_usage(void)
+@@ -10576,6 +10590,9 @@ test_multi_session_random_usage(void)
@@ -151 +153 @@
-@@ -11498,16 +11515,16 @@ test_multi_session_random_usage(void)
+@@ -10585,16 +10602,16 @@ test_multi_session_random_usage(void)
@@ -172 +174 @@
-@@ -11619,6 +11636,7 @@ test_null_burst_operation(void)
+@@ -10706,6 +10723,7 @@ test_null_burst_operation(void)
@@ -180 +182 @@
-@@ -11646,12 +11664,17 @@ test_null_burst_operation(void)
+@@ -10733,12 +10751,17 @@ test_null_burst_operation(void)
@@ -200 +202 @@
-@@ -12049,6 +12072,7 @@ static int create_gmac_session(uint8_t dev_id,
+@@ -10896,6 +10919,7 @@ static int create_gmac_session(uint8_t dev_id,
@@ -208 +210 @@
-@@ -12069,14 +12093,13 @@ static int create_gmac_session(uint8_t dev_id,
+@@ -10916,14 +10940,13 @@ static int create_gmac_session(uint8_t dev_id,
@@ -226 +228 @@
-@@ -12114,6 +12137,8 @@ test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
+@@ -10961,6 +10984,8 @@ test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
@@ -235 +237 @@
-@@ -12243,6 +12268,8 @@ test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
+@@ -11090,6 +11115,8 @@ test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
@@ -244 +246 @@
-@@ -12370,6 +12397,8 @@ test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
+@@ -11217,6 +11244,8 @@ test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
@@ -253 +255 @@
-@@ -12699,6 +12728,7 @@ create_auth_session(struct crypto_unittest_params *ut_params,
+@@ -11546,6 +11575,7 @@ create_auth_session(struct crypto_unittest_params *ut_params,
@@ -261 +263 @@
-@@ -12714,14 +12744,13 @@ create_auth_session(struct crypto_unittest_params *ut_params,
+@@ -11561,14 +11591,13 @@ create_auth_session(struct crypto_unittest_params *ut_params,
@@ -279 +281 @@
-@@ -12734,6 +12763,7 @@ create_auth_cipher_session(struct crypto_unittest_params *ut_params,
+@@ -11581,6 +11610,7 @@ create_auth_cipher_session(struct crypto_unittest_params *ut_params,
@@ -287 +289 @@
-@@ -12767,14 +12797,13 @@ create_auth_cipher_session(struct crypto_unittest_params *ut_params,
+@@ -11614,14 +11644,13 @@ create_auth_cipher_session(struct crypto_unittest_params *ut_params,
@@ -305 +307 @@
-@@ -12990,6 +13019,9 @@ test_authentication_verify_fail_when_data_corruption(
+@@ -11837,6 +11866,9 @@ test_authentication_verify_fail_when_data_corruption(
@@ -315 +317 @@
-@@ -13165,6 +13197,9 @@ test_authenticated_decryption_fail_when_corruption(
+@@ -12009,6 +12041,9 @@ test_authenticated_decryption_fail_when_corruption(
@@ -325,9 +327 @@
-@@ -13226,6 +13261,7 @@ test_authenticated_encrypt_with_esn(
- uint8_t cipher_key[reference->cipher_key.len + 1];
- uint8_t auth_key[reference->auth_key.len + 1];
- struct rte_cryptodev_info dev_info;
-+ int status;
-
- rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
- uint64_t feat_flags = dev_info.feature_flags;
-@@ -13277,13 +13313,17 @@ test_authenticated_encrypt_with_esn(
+@@ -12121,13 +12156,17 @@ test_authenticated_encrypt_with_esn(
@@ -353 +347,9 @@
-@@ -13409,13 +13449,17 @@ test_authenticated_decrypt_with_esn(
+@@ -12203,6 +12242,7 @@ test_authenticated_decrypt_with_esn(
+ uint8_t cipher_key[reference->cipher_key.len + 1];
+ uint8_t auth_key[reference->auth_key.len + 1];
+ struct rte_cryptodev_info dev_info;
++ int status;
+
+ rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
+ uint64_t feat_flags = dev_info.feature_flags;
+@@ -12253,13 +12293,17 @@ test_authenticated_decrypt_with_esn(
More information about the stable
mailing list