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 C6C77A00C3; Fri, 13 May 2022 09:33:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E400F4283B; Fri, 13 May 2022 09:32:40 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id B74A640DDE for ; Fri, 13 May 2022 09:32:39 +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 24CNcfEV010448; Fri, 13 May 2022 00:32:39 -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=MGxd5Kdgp04EzNPW4RUi2SkgtksTrjqxHpDAm1Vs+OU=; b=RSlu1O5XmAw5iA7snOH+w8tsbSWO7tQsCV+ufZHtbiTzYlabLWdBdIO9/LLVLBv/1CiN v47Ne2o3dDms5raQmjSI6hXujuB3VLbGtz3cZGdkidnHa3XWAT4LZWzbbxLoDHTnc7xl qV1e89JCrhu/wTtwXiiSlLI0T3nTP8JhpA3zzcIKrYzRNO3Y/Yh6klPBbYIw7ch44CHD 2k27rX34E6Kyhugvz8ikYvfPmLIxUyDj++53Z+sET1i7kMSDmXyU/QrA/xp3dA2tlzyH fo5SLX+xfqGzz2wT3EJJcLl/AhcsLh24pf3m5H81HKXy8rCtgwjF1MSzEDN6gJxv6UrD Gg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3g1c379fn6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 13 May 2022 00:32:39 -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, 13 May 2022 00:32:36 -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, 13 May 2022 00:32:36 -0700 Received: from localhost.localdomain (unknown [10.28.48.55]) by maili.marvell.com (Postfix) with ESMTP id 823403F7063; Fri, 13 May 2022 00:32:33 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , , , , , Fan Zhang Subject: [PATCH v6 7/7] test/security: add inline IPsec IPv6 flow label cases Date: Fri, 13 May 2022 13:02:01 +0530 Message-ID: <20220513073201.2320812-8-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220513073201.2320812-1-gakhil@marvell.com> References: <20220427151054.2536675-1-gakhil@marvell.com> <20220513073201.2320812-1-gakhil@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: QC-LqIeuZ0UgvVwI8sGlzyMuYKygbbCt X-Proofpoint-ORIG-GUID: QC-LqIeuZ0UgvVwI8sGlzyMuYKygbbCt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-13_02,2022-05-12_01,2022-02-23_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 IPv6 flow label set & copy operations. Signed-off-by: Vamsi Attunuru Acked-by: Fan Zhang --- app/test/test_cryptodev_security_ipsec.c | 35 ++++++++++- app/test/test_cryptodev_security_ipsec.h | 10 +++ app/test/test_security_inline_proto.c | 79 ++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 1 deletion(-) diff --git a/app/test/test_cryptodev_security_ipsec.c b/app/test/test_cryptodev_security_ipsec.c index 14c6ba681f..408bd0bc82 100644 --- a/app/test/test_cryptodev_security_ipsec.c +++ b/app/test/test_cryptodev_security_ipsec.c @@ -495,6 +495,10 @@ test_ipsec_td_prepare(const struct crypto_param *param1, flags->dscp == TEST_IPSEC_COPY_DSCP_INNER_1) td->ipsec_xform.options.copy_dscp = 1; + if (flags->flabel == TEST_IPSEC_COPY_FLABEL_INNER_0 || + flags->flabel == TEST_IPSEC_COPY_FLABEL_INNER_1) + td->ipsec_xform.options.copy_flabel = 1; + if (flags->dec_ttl_or_hop_limit) td->ipsec_xform.options.dec_ttl = 1; } @@ -933,6 +937,7 @@ test_ipsec_iph6_hdr_validate(const struct rte_ipv6_hdr *iph6, const struct ipsec_test_flags *flags) { uint32_t vtc_flow; + uint32_t flabel; uint8_t dscp; if (!is_valid_ipv6_pkt(iph6)) { @@ -959,6 +964,23 @@ test_ipsec_iph6_hdr_validate(const struct rte_ipv6_hdr *iph6, } } + flabel = vtc_flow & RTE_IPV6_HDR_FL_MASK; + + if (flags->flabel == TEST_IPSEC_COPY_FLABEL_INNER_1 || + flags->flabel == TEST_IPSEC_SET_FLABEL_1_INNER_0) { + if (flabel != TEST_IPSEC_FLABEL_VAL) { + printf("FLABEL value is not matching [exp: %x, actual: %x]\n", + TEST_IPSEC_FLABEL_VAL, flabel); + return -1; + } + } else { + if (flabel != 0) { + printf("FLABEL value is set [exp: 0, actual: %x]\n", + flabel); + return -1; + } + } + return 0; } @@ -1159,7 +1181,11 @@ test_ipsec_pkt_update(uint8_t *pkt, const struct ipsec_test_flags *flags) if (flags->dscp == TEST_IPSEC_COPY_DSCP_INNER_1 || flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1 || flags->dscp == TEST_IPSEC_COPY_DSCP_INNER_0 || - flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0) { + flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0 || + flags->flabel == TEST_IPSEC_COPY_FLABEL_INNER_1 || + flags->flabel == TEST_IPSEC_SET_FLABEL_0_INNER_1 || + flags->flabel == TEST_IPSEC_COPY_FLABEL_INNER_0 || + flags->flabel == TEST_IPSEC_SET_FLABEL_1_INNER_0) { if (is_ipv4(iph4)) { uint8_t tos; @@ -1187,6 +1213,13 @@ test_ipsec_pkt_update(uint8_t *pkt, const struct ipsec_test_flags *flags) else vtc_flow &= ~RTE_IPV6_HDR_DSCP_MASK; + if (flags->flabel == TEST_IPSEC_COPY_FLABEL_INNER_1 || + flags->flabel == TEST_IPSEC_SET_FLABEL_0_INNER_1) + vtc_flow |= (RTE_IPV6_HDR_FL_MASK & + (TEST_IPSEC_FLABEL_VAL << RTE_IPV6_HDR_FL_SHIFT)); + else + vtc_flow &= ~RTE_IPV6_HDR_FL_MASK; + iph6->vtc_flow = rte_cpu_to_be_32(vtc_flow); } } diff --git a/app/test/test_cryptodev_security_ipsec.h b/app/test/test_cryptodev_security_ipsec.h index 0d9b5b6e2e..744dd64a9e 100644 --- a/app/test/test_cryptodev_security_ipsec.h +++ b/app/test/test_cryptodev_security_ipsec.h @@ -73,6 +73,15 @@ enum dscp_flags { TEST_IPSEC_SET_DSCP_1_INNER_0, }; +#define TEST_IPSEC_FLABEL_VAL 0x1234 + +enum flabel_flags { + TEST_IPSEC_COPY_FLABEL_INNER_0 = 1, + TEST_IPSEC_COPY_FLABEL_INNER_1, + TEST_IPSEC_SET_FLABEL_0_INNER_1, + TEST_IPSEC_SET_FLABEL_1_INNER_0, +}; + struct ipsec_test_flags { bool display_alg; bool sa_expiry_pkts_soft; @@ -92,6 +101,7 @@ struct ipsec_test_flags { bool antireplay; enum df_flags df; enum dscp_flags dscp; + enum flabel_flags flabel; bool dec_ttl_or_hop_limit; bool ah; }; diff --git a/app/test/test_security_inline_proto.c b/app/test/test_security_inline_proto.c index 1c32141cd1..e082a1612f 100644 --- a/app/test/test_security_inline_proto.c +++ b/app/test/test_security_inline_proto.c @@ -162,6 +162,13 @@ create_inline_ipsec_session(struct ipsec_test_data *sa, uint16_t portid, sess_conf->ipsec.tunnel.ipv6.dscp = TEST_IPSEC_DSCP_VAL; + if (flags->flabel == TEST_IPSEC_SET_FLABEL_0_INNER_1) + sess_conf->ipsec.tunnel.ipv6.flabel = 0; + + if (flags->flabel == TEST_IPSEC_SET_FLABEL_1_INNER_0) + sess_conf->ipsec.tunnel.ipv6.flabel = + TEST_IPSEC_FLABEL_VAL; + memcpy(&sess_conf->ipsec.tunnel.ipv6.src_addr, &src_v6, sizeof(src_v6)); memcpy(&sess_conf->ipsec.tunnel.ipv6.dst_addr, &dst_v6, @@ -1792,6 +1799,62 @@ test_ipsec_inline_proto_ipv6_set_dscp_1_inner_0(const void *data __rte_unused) return test_ipsec_inline_proto_all(&flags); } +static int +test_ipsec_inline_proto_ipv6_copy_flabel_inner_0(const void *data __rte_unused) +{ + struct ipsec_test_flags flags; + + memset(&flags, 0, sizeof(flags)); + + flags.ipv6 = true; + flags.tunnel_ipv6 = true; + flags.flabel = TEST_IPSEC_COPY_FLABEL_INNER_0; + + return test_ipsec_inline_proto_all(&flags); +} + +static int +test_ipsec_inline_proto_ipv6_copy_flabel_inner_1(const void *data __rte_unused) +{ + struct ipsec_test_flags flags; + + memset(&flags, 0, sizeof(flags)); + + flags.ipv6 = true; + flags.tunnel_ipv6 = true; + flags.flabel = TEST_IPSEC_COPY_FLABEL_INNER_1; + + return test_ipsec_inline_proto_all(&flags); +} + +static int +test_ipsec_inline_proto_ipv6_set_flabel_0_inner_1(const void *data __rte_unused) +{ + struct ipsec_test_flags flags; + + memset(&flags, 0, sizeof(flags)); + + flags.ipv6 = true; + flags.tunnel_ipv6 = true; + flags.flabel = TEST_IPSEC_SET_FLABEL_0_INNER_1; + + return test_ipsec_inline_proto_all(&flags); +} + +static int +test_ipsec_inline_proto_ipv6_set_flabel_1_inner_0(const void *data __rte_unused) +{ + struct ipsec_test_flags flags; + + memset(&flags, 0, sizeof(flags)); + + flags.ipv6 = true; + flags.tunnel_ipv6 = true; + flags.flabel = TEST_IPSEC_SET_FLABEL_1_INNER_0; + + return test_ipsec_inline_proto_all(&flags); +} + static int test_ipsec_inline_proto_ipv4_ttl_decrement(const void *data __rte_unused) { @@ -2201,6 +2264,22 @@ static struct unit_test_suite inline_ipsec_testsuite = { "Tunnel header IPv6 set DSCP 1 (inner 0)", ut_setup_inline_ipsec, ut_teardown_inline_ipsec, test_ipsec_inline_proto_ipv6_set_dscp_1_inner_0), + TEST_CASE_NAMED_ST( + "Tunnel header IPv6 copy FLABEL (inner 0)", + ut_setup_inline_ipsec, ut_teardown_inline_ipsec, + test_ipsec_inline_proto_ipv6_copy_flabel_inner_0), + TEST_CASE_NAMED_ST( + "Tunnel header IPv6 copy FLABEL (inner 1)", + ut_setup_inline_ipsec, ut_teardown_inline_ipsec, + test_ipsec_inline_proto_ipv6_copy_flabel_inner_1), + TEST_CASE_NAMED_ST( + "Tunnel header IPv6 set FLABEL 0 (inner 1)", + ut_setup_inline_ipsec, ut_teardown_inline_ipsec, + test_ipsec_inline_proto_ipv6_set_flabel_0_inner_1), + TEST_CASE_NAMED_ST( + "Tunnel header IPv6 set FLABEL 1 (inner 0)", + ut_setup_inline_ipsec, ut_teardown_inline_ipsec, + test_ipsec_inline_proto_ipv6_set_flabel_1_inner_0), TEST_CASE_NAMED_ST( "Tunnel header IPv4 decrement inner TTL", ut_setup_inline_ipsec, ut_teardown_inline_ipsec, -- 2.25.1