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 01F18A050A; Sat, 16 Apr 2022 21:26:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5E61D4280B; Sat, 16 Apr 2022 21:26: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 04D424280B for ; Sat, 16 Apr 2022 21:26:21 +0200 (CEST) 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 23GIrJMq016143; Sat, 16 Apr 2022 12:26: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=Vvex0tdAYVGfVoDOaVXP0/Af+Pu777hV8T8eK6JkoO8=; b=Tdy9t6jKSSDA8BsxpZ8vW3qo3vmwK9cb/s6E0X2ekhxbDKZvov9AzVizURZkpQqUN1Gp V+lLZBNk3WRqeq2Am1fhZLwCSYlRJQC8ZirdZD/EKx34JJjMk2MtcTLTUE4ipTUw37uG /VdPnG6yL+jWcuvsiswlg58qHC/TAFnTng+mwTIcKn780qKUzKas0+igacxcAYgBTOLz gU6HgH2QYsZicQfHihavAGLOHtYtAoLco+qJm3VFaG4u5jVi5uNx+jMheMCxqIm/oDHi Z8m9jQVi5m3ZkiawOKR6k6YN7b19Vd2kOO0hT8vlDsH/AOU6xiHN/g+Eqx59AipZqeAP lg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3ffu5p910b-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sat, 16 Apr 2022 12:26:21 -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; Sat, 16 Apr 2022 12:26:19 -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; Sat, 16 Apr 2022 12:26:19 -0700 Received: from localhost.localdomain (unknown [10.28.48.55]) by maili.marvell.com (Postfix) with ESMTP id 44D253F7085; Sat, 16 Apr 2022 12:26:16 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , , , , Subject: [PATCH v4 10/10] test/security: add inline IPsec IPv6 flow label cases Date: Sun, 17 Apr 2022 00:55:30 +0530 Message-ID: <20220416192530.173895-11-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220416192530.173895-1-gakhil@marvell.com> References: <20220217172341.607360-1-gakhil@marvell.com> <20220416192530.173895-1-gakhil@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: z58JB2Y00PX55DC1G-ieE_mCtNnAzMl3 X-Proofpoint-ORIG-GUID: z58JB2Y00PX55DC1G-ieE_mCtNnAzMl3 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-04-16_08,2022-04-15_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 --- 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 418ab16ba6..9a3c021dd8 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; @@ -94,6 +103,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 15f08a2d6c..16fe164f77 100644 --- a/app/test/test_security_inline_proto.c +++ b/app/test/test_security_inline_proto.c @@ -163,6 +163,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, @@ -1883,6 +1890,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) { @@ -2329,6 +2392,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