From: Aakash Sasidharan <asasidharan@marvell.com>
To: Akhil Goyal <gakhil@marvell.com>, Fan Zhang <fanzhang.oss@gmail.com>
Cc: <jerinj@marvell.com>, <anoobj@marvell.com>,
<vvelumuri@marvell.com>, <asasidharan@marvell.com>,
<dev@dpdk.org>
Subject: [PATCH v2 7/7] test/security: use single session in data walkthrough test
Date: Thu, 20 Jun 2024 20:20:56 +0530 [thread overview]
Message-ID: <20240620145056.3456650-8-asasidharan@marvell.com> (raw)
In-Reply-To: <20240620145056.3456650-1-asasidharan@marvell.com>
Existing data walkthrough test creates a new session
per each test packet size. Enhance the test to use single
session instead.
Signed-off-by: Aakash Sasidharan <asasidharan@marvell.com>
---
app/test/test_cryptodev.c | 49 +++++++++++++++++--
app/test/test_cryptodev_security_tls_record.h | 1 +
2 files changed, 45 insertions(+), 5 deletions(-)
diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index e6ef5a13e0..75f98b6744 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -11968,9 +11968,12 @@ test_tls_record_proto_process(const struct tls_record_test_data td[],
}
}
- /* Create security session */
- ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
- ts_params->session_mpool);
+ if (ut_params->sec_session == NULL) {
+ /* Create security session */
+ ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
+ ts_params->session_mpool);
+ }
+
if (ut_params->sec_session == NULL)
return TEST_SKIPPED;
@@ -12075,9 +12078,10 @@ test_tls_record_proto_process(const struct tls_record_test_data td[],
rte_pktmbuf_free(ut_params->ibuf);
ut_params->ibuf = NULL;
- if (ut_params->sec_session)
+ if (ut_params->sec_session != NULL && !flags->skip_sess_destroy) {
rte_security_session_destroy(ctx, ut_params->sec_session);
- ut_params->sec_session = NULL;
+ ut_params->sec_session = NULL;
+ }
RTE_SET_USED(flags);
@@ -12121,8 +12125,11 @@ static int
test_tls_record_proto_all(const struct tls_record_test_flags *flags)
{
unsigned int i, nb_pkts = 1, pass_cnt = 0, payload_len, max_payload_len;
+ struct crypto_unittest_params *ut_params = &unittest_params;
struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
+ void *sec_session_outb = NULL;
+ void *sec_session_inb = NULL;
int ret;
switch (flags->tls_version) {
@@ -12152,10 +12159,16 @@ test_tls_record_proto_all(const struct tls_record_test_flags *flags)
if (ret == TEST_SKIPPED)
continue;
+ if (flags->skip_sess_destroy)
+ ut_params->sec_session = sec_session_outb;
+
ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
if (ret == TEST_SKIPPED)
continue;
+ if (flags->skip_sess_destroy && sec_session_outb == NULL)
+ sec_session_outb = ut_params->sec_session;
+
if (flags->zero_len &&
((flags->content_type == TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE) ||
(flags->content_type == TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE) ||
@@ -12169,10 +12182,16 @@ test_tls_record_proto_all(const struct tls_record_test_flags *flags)
test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
+ if (flags->skip_sess_destroy)
+ ut_params->sec_session = sec_session_inb;
+
ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
if (ret == TEST_SKIPPED)
continue;
+ if (flags->skip_sess_destroy && sec_session_inb == NULL)
+ sec_session_inb = ut_params->sec_session;
+
if (flags->pkt_corruption || flags->padding_corruption) {
if (ret == TEST_SUCCESS)
return TEST_FAILED;
@@ -12188,6 +12207,22 @@ test_tls_record_proto_all(const struct tls_record_test_flags *flags)
if (flags->display_alg)
test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
+ if (flags->skip_sess_destroy) {
+ uint8_t dev_id = testsuite_params.valid_devs[0];
+ struct rte_security_ctx *ctx;
+
+ ctx = rte_cryptodev_get_sec_ctx(dev_id);
+ if (sec_session_inb != NULL) {
+ rte_security_session_destroy(ctx, sec_session_inb);
+ sec_session_inb = NULL;
+ }
+ if (sec_session_outb != NULL) {
+ rte_security_session_destroy(ctx, sec_session_outb);
+ sec_session_outb = NULL;
+ }
+ ut_params->sec_session = NULL;
+ }
+
pass_cnt++;
}
@@ -12205,6 +12240,7 @@ test_tls_1_2_record_proto_data_walkthrough(void)
memset(&flags, 0, sizeof(flags));
flags.data_walkthrough = true;
+ flags.skip_sess_destroy = true;
flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
return test_tls_record_proto_all(&flags);
@@ -12254,6 +12290,7 @@ test_tls_record_proto_sgl_data_walkthrough(enum rte_security_tls_version tls_ver
struct tls_record_test_flags flags = {
.nb_segs_in_mbuf = 5,
.tls_version = tls_version,
+ .skip_sess_destroy = true,
.data_walkthrough = true
};
struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -12430,6 +12467,7 @@ test_dtls_1_2_record_proto_data_walkthrough(void)
memset(&flags, 0, sizeof(flags));
flags.data_walkthrough = true;
+ flags.skip_sess_destroy = true;
flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
return test_tls_record_proto_all(&flags);
@@ -12804,6 +12842,7 @@ test_tls_1_3_record_proto_data_walkthrough(void)
memset(&flags, 0, sizeof(flags));
flags.data_walkthrough = true;
+ flags.skip_sess_destroy = true;
flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
return test_tls_record_proto_all(&flags);
diff --git a/app/test/test_cryptodev_security_tls_record.h b/app/test/test_cryptodev_security_tls_record.h
index acb7f15f1c..e4a291c153 100644
--- a/app/test/test_cryptodev_security_tls_record.h
+++ b/app/test/test_cryptodev_security_tls_record.h
@@ -100,6 +100,7 @@ struct tls_record_test_flags {
bool zero_len;
bool padding_corruption;
bool out_of_place;
+ bool skip_sess_destroy;
uint8_t nb_segs_in_mbuf;
uint8_t opt_padding;
enum rte_security_tls_version tls_version;
--
2.25.1
next prev parent reply other threads:[~2024-06-20 14:51 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-17 5:58 [PATCH 0/7] Improvements and new test cases Aakash Sasidharan
2024-06-17 5:58 ` [PATCH 1/7] test/crypto: unit tests for padding for TLS-1.3 Aakash Sasidharan
2024-06-17 5:58 ` [PATCH 2/7] test/crypto: add combined mode cases for TLS 1.3 Aakash Sasidharan
2024-06-17 5:58 ` [PATCH 3/7] test/security: add TLS 1.3 data walkthrough tests Aakash Sasidharan
2024-06-17 5:58 ` [PATCH 4/7] test/crypto: verify padding corruption in TLS-1.2 Aakash Sasidharan
2024-06-20 6:52 ` Akhil Goyal
2024-06-17 5:58 ` [PATCH 5/7] test/crypto: verify padding corruption in DTLS-1.2 Aakash Sasidharan
2024-06-17 5:58 ` [PATCH 6/7] test/security: add out of place sgl tests for TLS Aakash Sasidharan
2024-06-17 5:58 ` [PATCH 7/7] test/security: use single session in data walkthrough test Aakash Sasidharan
2024-06-17 7:21 ` [PATCH 0/7] Improvements and new test cases Anoob Joseph
2024-06-20 14:50 ` [PATCH v2 " Aakash Sasidharan
2024-06-20 14:50 ` [PATCH v2 1/7] test/crypto: unit tests for padding for TLS-1.3 Aakash Sasidharan
2024-06-20 14:50 ` [PATCH v2 2/7] test/crypto: add combined mode cases for TLS 1.3 Aakash Sasidharan
2024-06-20 14:50 ` [PATCH v2 3/7] test/security: add TLS 1.3 data walkthrough tests Aakash Sasidharan
2024-06-20 14:50 ` [PATCH v2 4/7] test/crypto: verify padding corruption in TLS-1.2 Aakash Sasidharan
2024-06-20 14:50 ` [PATCH v2 5/7] test/crypto: verify padding corruption in DTLS-1.2 Aakash Sasidharan
2024-06-20 14:50 ` [PATCH v2 6/7] test/security: add out of place sgl tests for TLS Aakash Sasidharan
2024-06-20 14:50 ` Aakash Sasidharan [this message]
2024-06-26 7:30 ` [PATCH v2 0/7] Improvements and new test cases Akhil Goyal
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=20240620145056.3456650-8-asasidharan@marvell.com \
--to=asasidharan@marvell.com \
--cc=anoobj@marvell.com \
--cc=dev@dpdk.org \
--cc=fanzhang.oss@gmail.com \
--cc=gakhil@marvell.com \
--cc=jerinj@marvell.com \
--cc=vvelumuri@marvell.com \
/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).