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 16A96A04FF; Tue, 24 May 2022 09:56:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 20F9542B6E; Tue, 24 May 2022 09:55:57 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id DCC8142B6C for ; Tue, 24 May 2022 09:55:54 +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 24NNBP35022543; Tue, 24 May 2022 00:55:54 -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=nE9kuceTjc7h/OQHfgBjcibNDC12yWgmOIiOPiIXqNs=; b=c5d2aaJ1aiAHnEvYaaDfZ1gUghAr0aML4LT8BvViUBPtfMJjywwntVPnDVnB3JX5jeeY TooYFA2Z6zAcmnAhrVQ3ZqpwFo1ty2yr/37AbLSGeEgp7bBilK8iNf1ZntR8xTuPCnS8 k8BZcv8UjsKJlpGtK53gIJ7muhkYWi3N0s13gVhJPWe/Tkgakx2K3//sXdKZnCwjC1ZH X55HRhFGd0kuawzzphYVeFbGC47JSOVbsg5f/KpxRe2m0kZ0GeganF4EMRP/wc283Cte xN5mK3LH723PI+uvD0jJ8d8MsmJpXdH2oUZqxHw8opi53yyFlTnaUUbx8nPVxc0HAQO3 wA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3g8kqjhjq6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 24 May 2022 00:55:53 -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; Tue, 24 May 2022 00:55:52 -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; Tue, 24 May 2022 00:55:52 -0700 Received: from localhost.localdomain (unknown [10.28.48.55]) by maili.marvell.com (Postfix) with ESMTP id F2AFA67469; Tue, 24 May 2022 00:22:46 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , , , , , Fan Zhang Subject: [PATCH v7 7/7] test/security: add inline IPsec IPv6 flow label cases Date: Tue, 24 May 2022 12:52:16 +0530 Message-ID: <20220524072216.1283647-8-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220524072216.1283647-1-gakhil@marvell.com> References: <20220513073201.2320812-1-gakhil@marvell.com> <20220524072216.1283647-1-gakhil@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: MTTjZZpkw4hIKisPbMTo-eiWvbocEFX4 X-Proofpoint-GUID: MTTjZZpkw4hIKisPbMTo-eiWvbocEFX4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-24_05,2022-05-23_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 518fb09113..82d27550f4 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