From patchwork Wed Jun 7 15:19:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 128335 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E9D1842C4E; Wed, 7 Jun 2023 17:21:23 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 08D0442D86; Wed, 7 Jun 2023 17:20:37 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 4247442D10 for ; Wed, 7 Jun 2023 17:20:35 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 357Dvj7x028182; Wed, 7 Jun 2023 08:20:32 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=iozv4oTPdxq+e0eRjdE5Qm2QRfrN2VIW+dmmBsrw11M=; b=e4ARYt3TbJbg0YwZ/AFUNUc1nILNa194s9AZdXuFP/Jw/DGGfG22kSeakXu+VtXWRaZI pdV/1LCk+fjP0uPuxR14wSJYOMPRmAiYGB2+RkBMjIDOyIgRsydiSkPAI8HtEENkkBEf 3SDnRJ0I2j+W7KCqws8nOuGVYDzASwHF8f+nwg1VUXNB9dnS0JLhHaYvZKnEWEhSqwwr sVhoGhmsFqQRqdu01eMLQZ8QtHuA2oVqwf05C7BMnOXT5JvZ5zy5cIH9AWBMnsCgcscM LyWhXSa6KMp0TaT/EgzmaT367diLSJWaTHM7aajtjJd6GKCS8Q8mUpMV/zt0Rjgy6vIa 4g== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3r2a7bv6c4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 07 Jun 2023 08:20:32 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Wed, 7 Jun 2023 08:20:30 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Wed, 7 Jun 2023 08:20:30 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 643E73F7084; Wed, 7 Jun 2023 08:20:27 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , , , , Subject: [PATCH v2 11/13] test/security: verify MACsec Rx rekey Date: Wed, 7 Jun 2023 20:49:38 +0530 Message-ID: <20230607151940.223417-12-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230607151940.223417-1-gakhil@marvell.com> References: <20230523194918.1940212-1-gakhil@marvell.com> <20230607151940.223417-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: KPbkho-uV5pcMc9wvJm7Ogt6_g2Yl1PB X-Proofpoint-GUID: KPbkho-uV5pcMc9wvJm7Ogt6_g2Yl1PB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-07_07,2023-06-07_01,2023-05-22_02 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Ankur Dwivedi This patch enables the Rx rekey test case for MACSEC. Signed-off-by: Ankur Dwivedi --- app/test/test_security_inline_macsec.c | 50 +++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/app/test/test_security_inline_macsec.c b/app/test/test_security_inline_macsec.c index 2172f61199..d832dfc170 100644 --- a/app/test/test_security_inline_macsec.c +++ b/app/test/test_security_inline_macsec.c @@ -906,8 +906,14 @@ test_macsec(const struct mcs_test_vector *td[], enum mcs_op op, const struct mcs if (op == MCS_DECAP || op == MCS_ENCAP_DECAP || op == MCS_VERIFY_ONLY || op == MCS_AUTH_VERIFY) { for (an = 0; an < RTE_SECURITY_MACSEC_NUM_AN; an++) { + if (opts->rekey_en && an == + (opts->rekey_td->secure_pkt.data[tci_off] & + RTE_MACSEC_AN_MASK)) + fill_macsec_sa_conf(opts->rekey_td, &sa_conf, + RTE_SECURITY_MACSEC_DIR_RX, an, tci_off); + else /* For simplicity, using same SA conf for all AN */ - fill_macsec_sa_conf(td[i], &sa_conf, + fill_macsec_sa_conf(td[i], &sa_conf, RTE_SECURITY_MACSEC_DIR_RX, an, tci_off); id = rte_security_macsec_sa_create(ctx, &sa_conf); if (id < 0) { @@ -1054,6 +1060,9 @@ test_macsec(const struct mcs_test_vector *td[], enum mcs_op op, const struct mcs } tx_sa_id[0][0] = (uint16_t)id; break; + case RTE_ETH_EVENT_MACSEC_RX_SA_PN_SOFT_EXP: + printf("Received RTE_ETH_EVENT_MACSEC_RX_SA_PN_SOFT_EXP event\n"); + break; default: printf("Received unsupported event\n"); } @@ -1951,6 +1960,41 @@ test_inline_macsec_rekey_tx(const void *data __rte_unused) return all_err; } +static int +test_inline_macsec_rekey_rx(const void *data __rte_unused) +{ + const struct mcs_test_vector *cur_td; + struct mcs_test_opts opts = {0}; + int err, all_err = 0; + int i, size; + + opts.val_frames = RTE_SECURITY_MACSEC_VALIDATE_STRICT; + opts.protect_frames = true; + opts.sa_in_use = 1; + opts.nb_td = 1; + opts.sectag_insert_mode = 1; + opts.mtu = RTE_ETHER_MTU; + opts.rekey_en = 1; + + size = (sizeof(list_mcs_rekey_vectors) / sizeof((list_mcs_rekey_vectors)[0])); + for (i = 0; i < size; i++) { + cur_td = &list_mcs_rekey_vectors[i]; + opts.rekey_td = &list_mcs_rekey_vectors[++i]; + err = test_macsec(&cur_td, MCS_DECAP, &opts); + if (err) { + printf("Rx rekey test case %d failed\n", i); + err = -1; + } else { + printf("Rx rekey test case %d passed\n", i); + err = 0; + } + all_err += err; + } + + printf("\n%s: Success: %d, Failure: %d\n", __func__, size + all_err, -all_err); + return all_err; +} + static int ut_setup_inline_macsec(void) { @@ -2184,6 +2228,10 @@ static struct unit_test_suite inline_macsec_testsuite = { "MACsec re-key Tx", ut_setup_inline_macsec, ut_teardown_inline_macsec, test_inline_macsec_rekey_tx), + TEST_CASE_NAMED_ST( + "MACsec re-key Rx", + ut_setup_inline_macsec, ut_teardown_inline_macsec, + test_inline_macsec_rekey_rx), TEST_CASES_END() /**< NULL terminate unit test array */ },