From patchwork Mon Sep 26 17:07:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 116899 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 C1934A00C2; Mon, 26 Sep 2022 19:07:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 97F5C415D7; Mon, 26 Sep 2022 19:07:23 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 54DAA4114B for ; Mon, 26 Sep 2022 19:07:22 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28QH6HAP032130; Mon, 26 Sep 2022 10:07:21 -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=bJCI/YRzz5aNxR8di5Nu+DDXwCed6ygGYtEJ5F5IJ9o=; b=T9q1HAYrnk3Be9pR42YXddn3lc834kDDU+Riv/+/lcvknQgSze901WFYNf9LVQkgW7Cw YmoltgBwgU947h7RGfKIDbgyfb3gQmgXyTB2vrRzrljcAdtGVW+2w6ytlm4tTTejvyN/ Hmma4j8xKIB9/zc0Sex/qPkCmW8kTbNAFJI2eWVD42r7qh0xOFz9MvydPxDVmbrCjyw/ l3SqQq4hNLhg28lSl56e2QgXnuqSbHmE76oJClxN2R8zjkX/QMo7lTFRWAMoqs0mcKJz uZW8p0Tzev8NiJrilXngdrQkam/9WWA11y/8g5vIby5vOFAux+x4YGzD2wyNyv9zK10i hg== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3jucsq0ttx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 26 Sep 2022 10:07:21 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 26 Sep 2022 10:07:19 -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.18 via Frontend Transport; Mon, 26 Sep 2022 10:07:19 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 2AFBA3F70E8; Mon, 26 Sep 2022 10:07:15 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , , , , , , Akhil Goyal Subject: [PATCH v6 1/3] ethdev: add IPsec SA expiry event subtypes Date: Mon, 26 Sep 2022 22:37:07 +0530 Message-ID: <20220926170709.367891-2-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220926170709.367891-1-gakhil@marvell.com> References: <20220924135758.3402392-1-gakhil@marvell.com> <20220926170709.367891-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: OFNbJZ9SwHvqg99EAfJ9ZeioceWFfnce X-Proofpoint-ORIG-GUID: OFNbJZ9SwHvqg99EAfJ9ZeioceWFfnce X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-26_09,2022-09-22_02,2022-06-22_01 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: Vamsi Attunuru Patch adds new event subtypes for notifying expiry events upon reaching IPsec SA soft packet expiry and hard packet/byte expiry limits. Signed-off-by: Vamsi Attunuru Signed-off-by: Akhil Goyal Acked-by: Thomas Monjalon --- lib/ethdev/rte_ethdev.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index 2e783536c1..3ee6786a79 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -3875,8 +3875,26 @@ enum rte_eth_event_ipsec_subtype { RTE_ETH_EVENT_IPSEC_ESN_OVERFLOW, /** Soft time expiry of SA */ RTE_ETH_EVENT_IPSEC_SA_TIME_EXPIRY, - /** Soft byte expiry of SA */ + /** + * Soft byte expiry of SA determined by + * @ref rte_security_ipsec_lifetime::bytes_soft_limit + */ RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY, + /** + * Soft packet expiry of SA determined by + * @ref rte_security_ipsec_lifetime::packets_soft_limit + */ + RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY, + /** + * Hard byte expiry of SA determined by + * @ref rte_security_ipsec_lifetime::bytes_hard_limit + */ + RTE_ETH_EVENT_IPSEC_SA_BYTE_HARD_EXPIRY, + /** + * Hard packet expiry of SA determined by + * @ref rte_security_ipsec_lifetime::packets_hard_limit + */ + RTE_ETH_EVENT_IPSEC_SA_PKT_HARD_EXPIRY, /** Max value of this enum */ RTE_ETH_EVENT_IPSEC_MAX }; @@ -3898,6 +3916,9 @@ struct rte_eth_event_ipsec_desc { * - @ref RTE_ETH_EVENT_IPSEC_ESN_OVERFLOW * - @ref RTE_ETH_EVENT_IPSEC_SA_TIME_EXPIRY * - @ref RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY + * - @ref RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY + * - @ref RTE_ETH_EVENT_IPSEC_SA_BYTE_HARD_EXPIRY + * - @ref RTE_ETH_EVENT_IPSEC_SA_PKT_HARD_EXPIRY * * @see struct rte_security_session_conf * From patchwork Mon Sep 26 17:07:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 116900 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 CFB53A00C2; Mon, 26 Sep 2022 19:07:33 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7AA05427ED; Mon, 26 Sep 2022 19:07:27 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 8D8C5427EC for ; Mon, 26 Sep 2022 19:07:26 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28QH66HD031941; Mon, 26 Sep 2022 10:07:25 -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=7vS0SIl/oQVkDGqm9srjKVUhnjESDBy7QIhDIfLpAUw=; b=STePspB+35ZTXFiDkoosF1inneXfF0/9YhLUwTYiNNmRau5Kx5xWzkxwR/IgAz2Knr5h C5DxjHERfeQT53Tr+QPMpQhrp0hnc056xWobDRtPTRkQ/g5+73fswxl52N4b5uHO7o6r 3XSdQ4S7/PAzD1eKRhKmNoKTXbw3WceBntutRTgzVeMIhY6nw1iFPm2YxN1oNv2AiZEU 9RfzcpNplri2h1madlFRFaiunf4bAcgj8bbnjCdFTK5RaAIxNBqLHuO6r/1yB0OaPZro LCplGPNV7GfrwrKY2BPGrPSoIir2r8lvC6FfGlfpTYWuwO9FkleIFH2gtYWu3sff1kcp Lw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3jucsq0tuy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 26 Sep 2022 10:07:25 -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.2; Mon, 26 Sep 2022 10:07:23 -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.18 via Frontend Transport; Mon, 26 Sep 2022 10:07:23 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 4A4613F70D9; Mon, 26 Sep 2022 10:07:20 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , , , , , , Akhil Goyal Subject: [PATCH v6 2/3] test/security: add inline IPsec SA soft expiry cases Date: Mon, 26 Sep 2022 22:37:08 +0530 Message-ID: <20220926170709.367891-3-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220926170709.367891-1-gakhil@marvell.com> References: <20220924135758.3402392-1-gakhil@marvell.com> <20220926170709.367891-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: dBxyenK6rqqdc5H-qsmzJ4FUMTcGRrG8 X-Proofpoint-ORIG-GUID: dBxyenK6rqqdc5H-qsmzJ4FUMTcGRrG8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-26_09,2022-09-22_02,2022-06-22_01 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: Vamsi Attunuru Patch adds unit tests for packet & byte soft expiry events. Signed-off-by: Vamsi Attunuru Acked-by: Akhil Goyal --- app/test/test_cryptodev_security_ipsec.h | 2 + app/test/test_security_inline_proto.c | 105 +++++++++++++++++- app/test/test_security_inline_proto_vectors.h | 6 + 3 files changed, 112 insertions(+), 1 deletion(-) diff --git a/app/test/test_cryptodev_security_ipsec.h b/app/test/test_cryptodev_security_ipsec.h index 744dd64a9e..9a3c021dd8 100644 --- a/app/test/test_cryptodev_security_ipsec.h +++ b/app/test/test_cryptodev_security_ipsec.h @@ -86,6 +86,8 @@ struct ipsec_test_flags { bool display_alg; bool sa_expiry_pkts_soft; bool sa_expiry_pkts_hard; + bool sa_expiry_bytes_soft; + bool sa_expiry_bytes_hard; bool icv_corrupt; bool iv_gen; uint32_t tunnel_hdr_verify; diff --git a/app/test/test_security_inline_proto.c b/app/test/test_security_inline_proto.c index 5f26a04b06..5747ee0990 100644 --- a/app/test/test_security_inline_proto.c +++ b/app/test/test_security_inline_proto.c @@ -947,6 +947,62 @@ event_rx_burst(struct rte_mbuf **rx_pkts, uint16_t nb_pkts_to_rx) return nb_rx; } +static int +test_ipsec_inline_sa_exp_event_callback(uint16_t port_id, + enum rte_eth_event_type type, void *param, void *ret_param) +{ + struct sa_expiry_vector *vector = (struct sa_expiry_vector *)param; + struct rte_eth_event_ipsec_desc *event_desc = NULL; + + RTE_SET_USED(port_id); + + if (type != RTE_ETH_EVENT_IPSEC) + return -1; + + event_desc = ret_param; + if (event_desc == NULL) { + printf("Event descriptor not set\n"); + return -1; + } + vector->notify_event = true; + if (event_desc->metadata != (uint64_t)vector->sa_data) { + printf("Mismatch in event specific metadata\n"); + return -1; + } + if (event_desc->subtype == RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY) { + vector->event = RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY; + return 0; + } else if (event_desc->subtype == RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY) { + vector->event = RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY; + return 0; + } else if (event_desc->subtype >= RTE_ETH_EVENT_IPSEC_MAX) { + printf("Invalid IPsec event reported\n"); + return -1; + } + + return -1; +} + +static enum rte_eth_event_ipsec_subtype +test_ipsec_inline_setup_expiry_vector(struct sa_expiry_vector *vector, + const struct ipsec_test_flags *flags, + struct ipsec_test_data *tdata) +{ + enum rte_eth_event_ipsec_subtype event = RTE_ETH_EVENT_IPSEC_UNKNOWN; + + vector->event = RTE_ETH_EVENT_IPSEC_UNKNOWN; + vector->notify_event = false; + vector->sa_data = (void *)tdata; + if (flags->sa_expiry_pkts_soft) + event = RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY; + else + event = RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY; + rte_eth_dev_callback_register(port_id, RTE_ETH_EVENT_IPSEC, + test_ipsec_inline_sa_exp_event_callback, vector); + + return event; +} + static int test_ipsec_inline_proto_process(struct ipsec_test_data *td, struct ipsec_test_data *res_d, @@ -954,10 +1010,12 @@ test_ipsec_inline_proto_process(struct ipsec_test_data *td, bool silent, const struct ipsec_test_flags *flags) { + enum rte_eth_event_ipsec_subtype event = RTE_ETH_EVENT_IPSEC_UNKNOWN; struct rte_security_session_conf sess_conf = {0}; struct rte_crypto_sym_xform cipher = {0}; struct rte_crypto_sym_xform auth = {0}; struct rte_crypto_sym_xform aead = {0}; + struct sa_expiry_vector vector = {0}; struct rte_security_session *ses; struct rte_security_ctx *ctx; int nb_rx = 0, nb_sent; @@ -966,6 +1024,12 @@ test_ipsec_inline_proto_process(struct ipsec_test_data *td, memset(rx_pkts_burst, 0, sizeof(rx_pkts_burst[0]) * nb_pkts); + if (flags->sa_expiry_pkts_soft || flags->sa_expiry_bytes_soft) { + if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) + return TEST_SUCCESS; + event = test_ipsec_inline_setup_expiry_vector(&vector, flags, td); + } + if (td->aead) { sess_conf.crypto_xform = &aead; } else { @@ -1083,6 +1147,15 @@ test_ipsec_inline_proto_process(struct ipsec_test_data *td, out: if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) destroy_default_flow(port_id); + if (flags->sa_expiry_pkts_soft || flags->sa_expiry_bytes_soft) { + if (vector.notify_event && (vector.event == event)) + ret = TEST_SUCCESS; + else + ret = TEST_FAILED; + + rte_eth_dev_callback_unregister(port_id, RTE_ETH_EVENT_IPSEC, + test_ipsec_inline_sa_exp_event_callback, &vector); + } /* Destroy session so that other cases can create the session again */ rte_security_session_destroy(ctx, ses); @@ -1100,6 +1173,7 @@ test_ipsec_inline_proto_all(const struct ipsec_test_flags *flags) int ret; if (flags->iv_gen || flags->sa_expiry_pkts_soft || + flags->sa_expiry_bytes_soft || flags->sa_expiry_pkts_hard) nb_pkts = IPSEC_TEST_PACKETS_MAX; @@ -1132,6 +1206,11 @@ test_ipsec_inline_proto_all(const struct ipsec_test_flags *flags) if (flags->udp_encap) td_outb.ipsec_xform.options.udp_encap = 1; + if (flags->sa_expiry_bytes_soft) + td_outb.ipsec_xform.life.bytes_soft_limit = + (((td_outb.output_text.len + RTE_ETHER_HDR_LEN) + * nb_pkts) >> 3) - 1; + ret = test_ipsec_inline_proto_process(&td_outb, &td_inb, nb_pkts, false, flags); if (ret == TEST_SKIPPED) @@ -2242,6 +2321,23 @@ test_ipsec_inline_proto_iv_gen(const void *data __rte_unused) return test_ipsec_inline_proto_all(&flags); } +static int +test_ipsec_inline_proto_sa_pkt_soft_expiry(const void *data __rte_unused) +{ + struct ipsec_test_flags flags = { + .sa_expiry_pkts_soft = true + }; + return test_ipsec_inline_proto_all(&flags); +} +static int +test_ipsec_inline_proto_sa_byte_soft_expiry(const void *data __rte_unused) +{ + struct ipsec_test_flags flags = { + .sa_expiry_bytes_soft = true + }; + return test_ipsec_inline_proto_all(&flags); +} + static int test_ipsec_inline_proto_known_vec_fragmented(const void *test_data) { @@ -2644,7 +2740,14 @@ static struct unit_test_suite inline_ipsec_testsuite = { "IV generation", ut_setup_inline_ipsec, ut_teardown_inline_ipsec, test_ipsec_inline_proto_iv_gen), - + TEST_CASE_NAMED_ST( + "SA soft expiry with packet limit", + ut_setup_inline_ipsec, ut_teardown_inline_ipsec, + test_ipsec_inline_proto_sa_pkt_soft_expiry), + TEST_CASE_NAMED_ST( + "SA soft expiry with byte limit", + ut_setup_inline_ipsec, ut_teardown_inline_ipsec, + test_ipsec_inline_proto_sa_byte_soft_expiry), TEST_CASE_NAMED_WITH_DATA( "Antireplay with window size 1024", diff --git a/app/test/test_security_inline_proto_vectors.h b/app/test/test_security_inline_proto_vectors.h index c18965d80f..003537e200 100644 --- a/app/test/test_security_inline_proto_vectors.h +++ b/app/test/test_security_inline_proto_vectors.h @@ -36,6 +36,12 @@ struct reassembly_vector { bool burst; }; +struct sa_expiry_vector { + struct ipsec_session_data *sa_data; + enum rte_eth_event_ipsec_subtype event; + bool notify_event; +}; + /* The source file includes below test vectors */ /* IPv6: * From patchwork Mon Sep 26 17:07:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 116901 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 20278A00C2; Mon, 26 Sep 2022 19:07:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5EA3A4114B; Mon, 26 Sep 2022 19:07:32 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id B3AFD40146 for ; Mon, 26 Sep 2022 19:07:30 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28QH6Fle032060; Mon, 26 Sep 2022 10:07:29 -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=xvcn1JKuI8AU47b0ojlgrKGhRMRmxe343dYB9U7UCqI=; b=VX2N7WMGxRmquUArztqSGVjO+xUdP5jKRC03sjO31bEmheUOPKT8C2tpRjAXNpxfm3Oa +YHJd8JE2PTAuubvx0CaSPYUHzu2+eb5Wa5ndfAeQDibTvrys5RGC6RCR0tYF5MfB0WE 2Ju/Q56HJ2E9C7lKYA+3u6XQOlvG9IZruIZDdVLpB4id8BkVreUOKp5Qqqk56eBmSwcB wuetKFrGgPof0o1UCJihJOmGj6lAhfAZxn89hOtyLWgBffUViwrAKXnFmY3n50DFXYNQ uJLir1paBynZVLS6JcqtORj2+D2/gPtGJT7S030dnB3RR89K2CZ5q9aRgMyBQBrHayw3 Uw== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3jucsq0tvb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 26 Sep 2022 10:07:29 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 26 Sep 2022 10:07:28 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 26 Sep 2022 10:07:28 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 696173F70DA; Mon, 26 Sep 2022 10:07:24 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , , , , , , Akhil Goyal Subject: [PATCH v6 3/3] test/security: add inline IPsec SA hard expiry cases Date: Mon, 26 Sep 2022 22:37:09 +0530 Message-ID: <20220926170709.367891-4-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220926170709.367891-1-gakhil@marvell.com> References: <20220924135758.3402392-1-gakhil@marvell.com> <20220926170709.367891-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: 1etcDN7lvGYNuQG5SvYkcIthtK0hJDp- X-Proofpoint-ORIG-GUID: 1etcDN7lvGYNuQG5SvYkcIthtK0hJDp- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-26_09,2022-09-22_02,2022-06-22_01 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: Vamsi Attunuru Patch adds hard expiry unit tests for both packet and byte limits. Signed-off-by: Vamsi Attunuru Acked-by: Akhil Goyal --- app/test/test_security_inline_proto.c | 71 +++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 10 deletions(-) diff --git a/app/test/test_security_inline_proto.c b/app/test/test_security_inline_proto.c index 5747ee0990..8d0dd7765c 100644 --- a/app/test/test_security_inline_proto.c +++ b/app/test/test_security_inline_proto.c @@ -969,18 +969,25 @@ test_ipsec_inline_sa_exp_event_callback(uint16_t port_id, printf("Mismatch in event specific metadata\n"); return -1; } - if (event_desc->subtype == RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY) { + switch (event_desc->subtype) { + case RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY: vector->event = RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY; - return 0; - } else if (event_desc->subtype == RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY) { + break; + case RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY: vector->event = RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY; - return 0; - } else if (event_desc->subtype >= RTE_ETH_EVENT_IPSEC_MAX) { + break; + case RTE_ETH_EVENT_IPSEC_SA_PKT_HARD_EXPIRY: + vector->event = RTE_ETH_EVENT_IPSEC_SA_PKT_HARD_EXPIRY; + break; + case RTE_ETH_EVENT_IPSEC_SA_BYTE_HARD_EXPIRY: + vector->event = RTE_ETH_EVENT_IPSEC_SA_BYTE_HARD_EXPIRY; + break; + default: printf("Invalid IPsec event reported\n"); return -1; } - return -1; + return 0; } static enum rte_eth_event_ipsec_subtype @@ -995,8 +1002,12 @@ test_ipsec_inline_setup_expiry_vector(struct sa_expiry_vector *vector, vector->sa_data = (void *)tdata; if (flags->sa_expiry_pkts_soft) event = RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY; - else + else if (flags->sa_expiry_bytes_soft) event = RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY; + else if (flags->sa_expiry_pkts_hard) + event = RTE_ETH_EVENT_IPSEC_SA_PKT_HARD_EXPIRY; + else + event = RTE_ETH_EVENT_IPSEC_SA_BYTE_HARD_EXPIRY; rte_eth_dev_callback_register(port_id, RTE_ETH_EVENT_IPSEC, test_ipsec_inline_sa_exp_event_callback, vector); @@ -1024,7 +1035,8 @@ test_ipsec_inline_proto_process(struct ipsec_test_data *td, memset(rx_pkts_burst, 0, sizeof(rx_pkts_burst[0]) * nb_pkts); - if (flags->sa_expiry_pkts_soft || flags->sa_expiry_bytes_soft) { + if (flags->sa_expiry_pkts_soft || flags->sa_expiry_bytes_soft || + flags->sa_expiry_pkts_hard || flags->sa_expiry_bytes_hard) { if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) return TEST_SUCCESS; event = test_ipsec_inline_setup_expiry_vector(&vector, flags, td); @@ -1112,7 +1124,9 @@ test_ipsec_inline_proto_process(struct ipsec_test_data *td, break; } while (j++ < 5 || nb_rx == 0); - if (nb_rx != nb_sent) { + if (!flags->sa_expiry_pkts_hard && + !flags->sa_expiry_bytes_hard && + (nb_rx != nb_sent)) { printf("\nUnable to RX all %d packets, received(%i)", nb_sent, nb_rx); while (--nb_rx >= 0) @@ -1147,7 +1161,8 @@ test_ipsec_inline_proto_process(struct ipsec_test_data *td, out: if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) destroy_default_flow(port_id); - if (flags->sa_expiry_pkts_soft || flags->sa_expiry_bytes_soft) { + if (flags->sa_expiry_pkts_soft || flags->sa_expiry_bytes_soft || + flags->sa_expiry_pkts_hard || flags->sa_expiry_bytes_hard) { if (vector.notify_event && (vector.event == event)) ret = TEST_SUCCESS; else @@ -1174,6 +1189,7 @@ test_ipsec_inline_proto_all(const struct ipsec_test_flags *flags) if (flags->iv_gen || flags->sa_expiry_pkts_soft || flags->sa_expiry_bytes_soft || + flags->sa_expiry_bytes_hard || flags->sa_expiry_pkts_hard) nb_pkts = IPSEC_TEST_PACKETS_MAX; @@ -1210,6 +1226,13 @@ test_ipsec_inline_proto_all(const struct ipsec_test_flags *flags) td_outb.ipsec_xform.life.bytes_soft_limit = (((td_outb.output_text.len + RTE_ETHER_HDR_LEN) * nb_pkts) >> 3) - 1; + if (flags->sa_expiry_pkts_hard) + td_outb.ipsec_xform.life.packets_hard_limit = + IPSEC_TEST_PACKETS_MAX - 1; + if (flags->sa_expiry_bytes_hard) + td_outb.ipsec_xform.life.bytes_hard_limit = + (((td_outb.output_text.len + RTE_ETHER_HDR_LEN) + * nb_pkts) >> 3) - 1; ret = test_ipsec_inline_proto_process(&td_outb, &td_inb, nb_pkts, false, flags); @@ -2338,6 +2361,26 @@ test_ipsec_inline_proto_sa_byte_soft_expiry(const void *data __rte_unused) return test_ipsec_inline_proto_all(&flags); } +static int +test_ipsec_inline_proto_sa_pkt_hard_expiry(const void *data __rte_unused) +{ + struct ipsec_test_flags flags = { + .sa_expiry_pkts_hard = true + }; + + return test_ipsec_inline_proto_all(&flags); +} + +static int +test_ipsec_inline_proto_sa_byte_hard_expiry(const void *data __rte_unused) +{ + struct ipsec_test_flags flags = { + .sa_expiry_bytes_hard = true + }; + + return test_ipsec_inline_proto_all(&flags); +} + static int test_ipsec_inline_proto_known_vec_fragmented(const void *test_data) { @@ -2748,6 +2791,14 @@ static struct unit_test_suite inline_ipsec_testsuite = { "SA soft expiry with byte limit", ut_setup_inline_ipsec, ut_teardown_inline_ipsec, test_ipsec_inline_proto_sa_byte_soft_expiry), + TEST_CASE_NAMED_ST( + "SA hard expiry with packet limit", + ut_setup_inline_ipsec, ut_teardown_inline_ipsec, + test_ipsec_inline_proto_sa_pkt_hard_expiry), + TEST_CASE_NAMED_ST( + "SA hard expiry with byte limit", + ut_setup_inline_ipsec, ut_teardown_inline_ipsec, + test_ipsec_inline_proto_sa_byte_hard_expiry), TEST_CASE_NAMED_WITH_DATA( "Antireplay with window size 1024",