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 CA091A04A3; Mon, 3 Jan 2022 16:09:15 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8425341157; Mon, 3 Jan 2022 16:09:00 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id A46D241163 for ; Mon, 3 Jan 2022 16:08:58 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 203EHCRc016199; Mon, 3 Jan 2022 07:08:57 -0800 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=5H+QgDl6fSeP8VOwPTWuGfducSDVELPSdF0yL0oAw20=; b=SYWuwMet1c1J3/t9XLaG77upXI9K7kCu/CmzMUTMyAxcRdmoZB9nC4Icqw4rwXXydx6h O1zDdTXI6iPUMNaIuDmD1Rt7g7k93RSRQ96QZDESzBPiH/QwShJeFTjDXRzNVlTw44qD oOYr2OUUGoD42oFY+rMGl/U7rBNdUCbAqy69MzA4yn+caRienuwd/nxnFjtKY1MTar6G MlvV97L18yToJJfrpkjdJa/wRikhLa3invCRhFL0QFV4cAi0iDC9VH+UsPynTC6h6Yjn O31Qp+VMPW3FAJNUPnDrcNAOrH0bMEmz+RfX5tbi44D1fYSygPN3BsRFNB//tX6mRXbV 6Q== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3dbmvswf9v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 03 Jan 2022 07:08:56 -0800 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, 3 Jan 2022 07:08:55 -0800 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, 3 Jan 2022 07:08:55 -0800 Received: from localhost.localdomain (unknown [10.28.48.55]) by maili.marvell.com (Postfix) with ESMTP id A6A333F7095; Mon, 3 Jan 2022 07:08:51 -0800 (PST) From: Akhil Goyal To: CC: , , , , , , , , , , , Akhil Goyal Subject: [PATCH 6/8] app/test: add IP reassembly case with no frags Date: Mon, 3 Jan 2022 20:38:11 +0530 Message-ID: <20220103150813.1694888-7-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220103150813.1694888-1-gakhil@marvell.com> References: <20210823100259.1619886-1-gakhil@marvell.com> <20220103150813.1694888-1-gakhil@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: uXlSU5zjxSSocHUgw4a4tAvlG4onli6h X-Proofpoint-GUID: uXlSU5zjxSSocHUgw4a4tAvlG4onli6h X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-03_06,2022-01-01_01,2021-12-02_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 test_inline_ipsec testsuite is extended to test IP reassembly of inbound fragmented packets. The fragmented packet is sent on an interface which encrypts the packet and then it is loopbacked on the same interface which decrypts the packet and then attempts IP reassembly of the decrypted packets. In this patch, a case is added for packets without fragmentation to verify the complete path. Other cases are added in subsequent patches. Signed-off-by: Akhil Goyal --- app/test/test_inline_ipsec.c | 154 +++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/app/test/test_inline_ipsec.c b/app/test/test_inline_ipsec.c index 54b56ba9e8..f704725c0f 100644 --- a/app/test/test_inline_ipsec.c +++ b/app/test/test_inline_ipsec.c @@ -460,6 +460,145 @@ create_default_flow(uint16_t port_id) struct rte_mbuf **tx_pkts_burst; +static int +compare_pkt_data(struct rte_mbuf *m, uint8_t *ref, unsigned int tot_len) +{ + unsigned int len; + unsigned int nb_segs = m->nb_segs; + unsigned int matched = 0; + + while (m && nb_segs != 0) { + len = tot_len; + if (len > m->data_len) + len = m->data_len; + if (len != 0) { + if (memcmp(rte_pktmbuf_mtod(m, char *), + ref + matched, len)) { + printf("\n====Reassembly case failed: Data Mismatch"); + rte_hexdump(stdout, "Reassembled", + rte_pktmbuf_mtod(m, char *), + len); + rte_hexdump(stdout, "reference", + ref + matched, + len); + return TEST_FAILED; + } + } + tot_len -= len; + matched += len; + m = m->next; + nb_segs--; + } + return TEST_SUCCESS; +} + +static int +test_reassembly(struct reassembly_vector *vector, + enum rte_security_ipsec_tunnel_type tun_type) +{ + struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; + unsigned i, portid, nb_rx = 0, nb_tx = 0; + struct rte_ipsec_session out_ips = {0}; + struct rte_ipsec_session in_ips = {0}; + struct rte_eth_dev_info dev_info = {0}; + int ret = 0; + + /* Initialize mbuf with test vectors. */ + nb_tx = reass_test_vectors_init(vector); + + portid = lcore_cfg.port; + rte_eth_dev_info_get(portid, &dev_info); + if (dev_info.reass_capa.max_frags < nb_tx) + return TEST_SKIPPED; + + /** + * Set some finite value in timeout incase PMD support much + * more than requied in this app. + */ + if (dev_info.reass_capa.reass_timeout > APP_REASS_TIMEOUT) { + dev_info.reass_capa.reass_timeout = APP_REASS_TIMEOUT; + rte_eth_ip_reassembly_conf_set(portid, &dev_info.reass_capa); + } + + init_traffic(mbufpool[lcore_cfg.socketid], + tx_pkts_burst, vector->frags, nb_tx); + + /* Create Inline IPsec outbound session. */ + ret = create_inline_ipsec_session(vector->sa_data, portid, &out_ips, + RTE_SECURITY_IPSEC_SA_DIR_EGRESS, tun_type); + if (ret) + return ret; + for (i = 0; i < nb_tx; i++) { + if (out_ips.security.ol_flags & + RTE_SECURITY_TX_OLOAD_NEED_MDATA) + rte_security_set_pkt_metadata(out_ips.security.ctx, + out_ips.security.ses, tx_pkts_burst[i], NULL); + tx_pkts_burst[i]->ol_flags |= RTE_MBUF_F_TX_SEC_OFFLOAD; + tx_pkts_burst[i]->l2_len = RTE_ETHER_HDR_LEN; + } + /* Create Inline IPsec inbound session. */ + create_inline_ipsec_session(vector->sa_data, portid, &in_ips, + RTE_SECURITY_IPSEC_SA_DIR_INGRESS, tun_type); + create_default_flow(portid); + + nb_tx = rte_eth_tx_burst(portid, 0, tx_pkts_burst, nb_tx); + + rte_pause(); + + do { + nb_rx = rte_eth_rx_burst(portid, 0, pkts_burst, MAX_PKT_BURST); + for (i = 0; i < nb_rx; i++) { + if ((pkts_burst[i]->ol_flags & + RTE_MBUF_F_RX_IPREASSEMBLY_INCOMPLETE) && + rte_eth_ip_reass_dynfield_is_registered()) { + rte_eth_ip_reass_dynfield_t *dynfield[MAX_PKT_BURST]; + int j = 0; + + dynfield[j] = rte_eth_ip_reass_dynfield(pkts_burst[i]); + while ((dynfield[j]->next_frag->ol_flags & + RTE_MBUF_F_RX_IPREASSEMBLY_INCOMPLETE) && + dynfield[j]->nb_frags > 0) { + + rte_pktmbuf_dump(stdout, + dynfield[j]->next_frag, + dynfield[j]->next_frag->data_len); + j++; + dynfield[j] = rte_eth_ip_reass_dynfield( + dynfield[j-1]->next_frag); + } + /** + * IP reassembly offload is incomplete, and + * fragments are listed in dynfield which + * can be reassembled in SW. + */ + printf("\nHW IP Reassembly failed," + "\nAttempt SW IP Reassembly," + "\nmbuf is chained with fragments.\n"); + } + } + } while (nb_rx == 0); + + /* Clear session data. */ + rte_security_session_destroy(out_ips.security.ctx, + out_ips.security.ses); + rte_security_session_destroy(in_ips.security.ctx, + in_ips.security.ses); + + /* Compare results with known vectors. */ + if (nb_rx == 1) { + if (vector->full_pkt->len == pkts_burst[0]->pkt_len) + return compare_pkt_data(pkts_burst[0], + vector->full_pkt->data, + vector->full_pkt->len); + else { + rte_pktmbuf_dump(stdout, pkts_burst[0], + pkts_burst[0]->pkt_len); + } + } + + return TEST_FAILED; +} + static int test_ipsec(struct reassembly_vector *vector, enum rte_security_ipsec_sa_direction dir, @@ -703,6 +842,18 @@ test_ipsec_ipv4_decap_nofrag(void) { RTE_SECURITY_IPSEC_TUNNEL_IPV4); } +static int +test_reassembly_ipv4_nofrag(void) { + struct reassembly_vector ipv4_nofrag_case = { + .sa_data = &conf_aes_128_gcm, + .full_pkt = &pkt_ipv4_plain, + .frags[0] = &pkt_ipv4_plain, + }; + return test_reassembly(&ipv4_nofrag_case, + RTE_SECURITY_IPSEC_TUNNEL_IPV4); +} + + static struct unit_test_suite inline_ipsec_testsuite = { .suite_name = "Inline IPsec Ethernet Device Unit Test Suite", .setup = testsuite_setup, @@ -714,6 +865,9 @@ static struct unit_test_suite inline_ipsec_testsuite = { TEST_CASE_ST(ut_setup_inline_ipsec, ut_teardown_inline_ipsec, test_ipsec_ipv4_decap_nofrag), + TEST_CASE_ST(ut_setup_inline_ipsec, + ut_teardown_inline_ipsec, + test_reassembly_ipv4_nofrag), TEST_CASES_END() /**< NULL terminate unit test array */ } -- 2.25.1