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 24424A0032; Fri, 21 Oct 2022 09:27:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6572B42BC3; Fri, 21 Oct 2022 09:27:32 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 056D942B95 for ; Fri, 21 Oct 2022 09:27:27 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29L2BDS5009575; Fri, 21 Oct 2022 00:27:27 -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=Bi4smQ8zaxo+pacCeFbvmmFvDJb0pniNjrD0o9F757o=; b=fz+2lSpjDRvSwI0iSpapJlpDJMlEVtnXqbs4e7rfHfY2F9bIlfmKn+Hd9vAQ3CLRlen8 aug1ZV9Khz3wwCaOJulFIVznpZP6utWOrPYa/4wcpJi/MUbeiUDMTK183bSfh+1eWDr5 Md+j3fafbei7BpjFR5s+Z0fENuXcRz8nfRlNERBVcYnztHrqOl1sMBJ+FXZSv1Yy38sZ DQ9LNtnQLs5b4gm5DCo8VVfV0yKI6RKk4RKurSFXqu1EBvX70ZGJiJKmYzXeBqpXOy4x 3Fe4GgWcnNWB8H/0xh8yMApMkH+Rju+lSC4GRbldFNG4XJMPXK8D+ntUDg3AkJYWvnEq TQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3kb125d6gw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 21 Oct 2022 00:27:27 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 21 Oct 2022 00:27:25 -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; Fri, 21 Oct 2022 00:27:25 -0700 Received: from hyd1554.marvell.com (unknown [10.29.57.11]) by maili.marvell.com (Postfix) with ESMTP id 57B495B69BB; Fri, 21 Oct 2022 00:27:10 -0700 (PDT) From: Tejasree Kondoj To: Akhil Goyal , Fan Zhang , Ciara Power CC: Vidya Sagar Velumuri , Anoob Joseph , Subject: [PATCH v2 6/6] test/crypto: add unit test for custom UDP ports Date: Fri, 21 Oct 2022 12:56:51 +0530 Message-ID: <20221021072651.1985340-7-ktejasree@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221021072651.1985340-1-ktejasree@marvell.com> References: <20221021072651.1985340-1-ktejasree@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: UJiH_8qfAA5WfcDkE8v9phVMp-gkHRA7 X-Proofpoint-ORIG-GUID: UJiH_8qfAA5WfcDkE8v9phVMp-gkHRA7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-21_03,2022-10-20_01,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: Vidya Sagar Velumuri Add unit test for custom UDP ports with UDP encapsulation. Verify UDP header in egress path for all unit tests. Signed-off-by: Tejasree Kondoj Signed-off-by: Vidya Sagar Velumuri --- app/test/test_cryptodev.c | 21 +++++++ app/test/test_cryptodev_security_ipsec.c | 71 ++++++++++++++++++------ app/test/test_cryptodev_security_ipsec.h | 1 + 3 files changed, 76 insertions(+), 17 deletions(-) diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 96941dd55c..43fcef7e73 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -9892,6 +9892,23 @@ test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused) return test_ipsec_proto_all(&flags); } +static int +test_ipsec_proto_udp_encap_custom_ports(const void *data __rte_unused) +{ + struct ipsec_test_flags flags; + + if (gbl_driver_id == rte_cryptodev_driver_id_get( + RTE_STR(CRYPTODEV_NAME_CN10K_PMD))) + return TEST_SKIPPED; + + memset(&flags, 0, sizeof(flags)); + + flags.udp_encap = true; + flags.udp_encap_custom_ports = true; + + return test_ipsec_proto_all(&flags); +} + static int test_ipsec_proto_udp_encap(const void *data __rte_unused) { @@ -15358,6 +15375,10 @@ static struct unit_test_suite ipsec_proto_testsuite = { "UDP encapsulation", ut_setup_security, ut_teardown, test_ipsec_proto_udp_encap), + TEST_CASE_NAMED_ST( + "UDP encapsulation with custom ports", + ut_setup_security, ut_teardown, + test_ipsec_proto_udp_encap_custom_ports), TEST_CASE_NAMED_ST( "UDP encapsulation ports verification test", ut_setup_security, ut_teardown, diff --git a/app/test/test_cryptodev_security_ipsec.c b/app/test/test_cryptodev_security_ipsec.c index 3219b41e39..d64e07f226 100644 --- a/app/test/test_cryptodev_security_ipsec.c +++ b/app/test/test_cryptodev_security_ipsec.c @@ -14,6 +14,8 @@ #include "test_cryptodev_security_ipsec.h" #define IV_LEN_MAX 16 +#define UDP_CUSTOM_SPORT 4650 +#define UDP_CUSTOM_DPORT 4660 #ifndef IPVERSION #define IPVERSION 4 @@ -508,6 +510,11 @@ test_ipsec_td_prepare(const struct crypto_param *param1, if (flags->dec_ttl_or_hop_limit) td->ipsec_xform.options.dec_ttl = 1; + + if (flags->udp_encap && flags->udp_encap_custom_ports) { + td->ipsec_xform.udp.sport = UDP_CUSTOM_SPORT; + td->ipsec_xform.udp.dport = UDP_CUSTOM_DPORT; + } } } @@ -765,23 +772,6 @@ test_ipsec_td_verify(struct rte_mbuf *m, const struct ipsec_test_data *td, if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS && flags->udp_encap) { - const struct rte_ipv4_hdr *iph4; - const struct rte_ipv6_hdr *iph6; - - if (td->ipsec_xform.tunnel.type == - RTE_SECURITY_IPSEC_TUNNEL_IPV4) { - iph4 = (const struct rte_ipv4_hdr *)output_text; - if (iph4->next_proto_id != IPPROTO_UDP) { - printf("UDP header is not found\n"); - return TEST_FAILED; - } - } else { - iph6 = (const struct rte_ipv6_hdr *)output_text; - if (iph6->proto != IPPROTO_UDP) { - printf("UDP header is not found\n"); - return TEST_FAILED; - } - } len -= sizeof(struct rte_udp_hdr); output_text += sizeof(struct rte_udp_hdr); @@ -1043,6 +1033,53 @@ test_ipsec_post_process(struct rte_mbuf *m, const struct ipsec_test_data *td, } } + if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS && + flags->udp_encap) { + const struct rte_ipv4_hdr *iph4; + const struct rte_ipv6_hdr *iph6; + + if (td->ipsec_xform.tunnel.type == + RTE_SECURITY_IPSEC_TUNNEL_IPV4) { + iph4 = (const struct rte_ipv4_hdr *)output_text; + + if (iph4->next_proto_id != IPPROTO_UDP) { + printf("UDP header is not found\n"); + return TEST_FAILED; + } + + if (flags->udp_encap_custom_ports) { + const struct rte_udp_hdr *udph; + + udph = (const struct rte_udp_hdr *)(output_text + + sizeof(struct rte_ipv4_hdr)); + if ((rte_be_to_cpu_16(udph->src_port) != UDP_CUSTOM_SPORT) || + (rte_be_to_cpu_16(udph->dst_port) != UDP_CUSTOM_DPORT)) { + printf("UDP custom ports not matching.\n"); + return TEST_FAILED; + } + } + } else { + iph6 = (const struct rte_ipv6_hdr *)output_text; + + if (iph6->proto != IPPROTO_UDP) { + printf("UDP header is not found\n"); + return TEST_FAILED; + } + + if (flags->udp_encap_custom_ports) { + const struct rte_udp_hdr *udph; + + udph = (const struct rte_udp_hdr *)(output_text + + sizeof(struct rte_ipv6_hdr)); + if ((rte_be_to_cpu_16(udph->src_port) != UDP_CUSTOM_SPORT) || + (rte_be_to_cpu_16(udph->dst_port) != UDP_CUSTOM_DPORT)) { + printf("UDP custom ports not matching.\n"); + return TEST_FAILED; + } + } + } + } + /* * In case of known vector tests & all inbound tests, res_d provided * would be NULL and output data need to be validated against expected. diff --git a/app/test/test_cryptodev_security_ipsec.h b/app/test/test_cryptodev_security_ipsec.h index b98f4741b2..008b17c290 100644 --- a/app/test/test_cryptodev_security_ipsec.h +++ b/app/test/test_cryptodev_security_ipsec.h @@ -93,6 +93,7 @@ struct ipsec_test_flags { uint32_t tunnel_hdr_verify; bool udp_encap; bool udp_ports_verify; + bool udp_encap_custom_ports; bool ip_csum; bool l4_csum; bool ipv6; -- 2.25.1