From patchwork Fri Feb 18 12:52:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Fialko X-Patchwork-Id: 107806 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B84C4A0032; Fri, 18 Feb 2022 13:53:55 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A8AA641143; Fri, 18 Feb 2022 13:53:55 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 6B0B140141 for ; Fri, 18 Feb 2022 13:53:53 +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 21IBsBwb026409; Fri, 18 Feb 2022 04:53:52 -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=lRjg+xbdaJhTAPyJo8s/UITEJlxEzquziHl+mfz9MgU=; b=D9uTYEQ6rukS2lNS5Lj+Wm2cjI7Ji2B4OkkEvuZGMhHnwl6KNbHMiMNn2ieqZLZhQYBw /giHQUP07fkZswEvQB8QD6xsjFittFz64FnBcF2rd1gN6EYzdcbOLwvXXsfQ2RunHtmo Bf9KewAVJWq8ZcF7H2LBsrKyOoQu9ohZNS8ksIwACXfWZRYUa32NltEydnB7+hK2tGDb HLWO5tmr6r0s6FAyjYNfBryl4UGweHMxxTb/yX6EsD0JgZiqlJOARlEzYHNRl95uq+fS 9uhkfD2XqcPQMooHnYHZhSwcd82J1QYW98TkFXfMzBaT4RSwzrfMuwiF3sofNxuAOjjo Xg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3eaayv067k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 18 Feb 2022 04:53:52 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 18 Feb 2022 04:53:51 -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; Fri, 18 Feb 2022 04:53:50 -0800 Received: from localhost.localdomain (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id B7A1F3F706D; Fri, 18 Feb 2022 04:53:48 -0800 (PST) From: Volodymyr Fialko To: , Akhil Goyal , Fan Zhang CC: , Volodymyr Fialko , Anoob Joseph Subject: [PATCH 1/2] test/crypto: add TTL and hop limit decrement cases Date: Fri, 18 Feb 2022 13:52:02 +0100 Message-ID: <20220218125203.489078-2-vfialko@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220218125203.489078-1-vfialko@marvell.com> References: <20220218125203.489078-1-vfialko@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: RIsDmUT6osxF-eS4syfXujaqf2x1bwvV X-Proofpoint-ORIG-GUID: RIsDmUT6osxF-eS4syfXujaqf2x1bwvV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-18_05,2022-02-18_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 Add test cases to verify TTL and hop limit decrement with lookaside IPsec offload. Signed-off-by: Volodymyr Fialko Acked-by: Anoob Joseph --- app/test/test_cryptodev.c | 29 +++++++++++++++++++ app/test/test_cryptodev_security_ipsec.c | 37 ++++++++++++++++++++++++ app/test/test_cryptodev_security_ipsec.h | 1 + 3 files changed, 67 insertions(+) diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index a63c199964..f6c3cd2b7b 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -9811,6 +9811,27 @@ test_PDCP_PROTO_all(void) return TEST_SUCCESS; } +static int +test_ipsec_proto_ipv4_ttl_decrement(const void *data __rte_unused) +{ + struct ipsec_test_flags flags = { + .dec_ttl_or_hop_limit = true + }; + + return test_ipsec_proto_all(&flags); +} + +static int +test_ipsec_proto_ipv6_hop_limit_decrement(const void *data __rte_unused) +{ + struct ipsec_test_flags flags = { + .ipv6 = true, + .dec_ttl_or_hop_limit = true + }; + + return test_ipsec_proto_all(&flags); +} + static int test_docsis_proto_uplink(const void *data) { @@ -14808,6 +14829,14 @@ static struct unit_test_suite ipsec_proto_testsuite = { "Tunnel header set DF 1 (inner 0)", ut_setup_security, ut_teardown, test_ipsec_proto_set_df_1_inner_0), + TEST_CASE_NAMED_ST( + "Tunnel header IPv4 decrement inner TTL", + ut_setup_security, ut_teardown, + test_ipsec_proto_ipv4_ttl_decrement), + TEST_CASE_NAMED_ST( + "Tunnel header IPv6 decrement inner hop limit", + ut_setup_security, ut_teardown, + test_ipsec_proto_ipv6_hop_limit_decrement), TEST_CASES_END() /**< NULL terminate unit test array */ } }; diff --git a/app/test/test_cryptodev_security_ipsec.c b/app/test/test_cryptodev_security_ipsec.c index 229eadf5de..77e4ee84cb 100644 --- a/app/test/test_cryptodev_security_ipsec.c +++ b/app/test/test_cryptodev_security_ipsec.c @@ -432,6 +432,9 @@ test_ipsec_td_prepare(const struct crypto_param *param1, if (flags->df == TEST_IPSEC_COPY_DF_INNER_0 || flags->df == TEST_IPSEC_COPY_DF_INNER_1) td->ipsec_xform.options.copy_df = 1; + + if (flags->dec_ttl_or_hop_limit) + td->ipsec_xform.options.dec_ttl = 1; } } @@ -639,6 +642,32 @@ test_ipsec_l4_csum_verify(struct rte_mbuf *m) return TEST_SUCCESS; } +static int +test_ipsec_ttl_or_hop_decrement_verify(void *received, void *expected) +{ + struct rte_ipv4_hdr *iph4_ex, *iph4_re; + struct rte_ipv6_hdr *iph6_ex, *iph6_re; + + if (is_ipv4(received) && is_ipv4(expected)) { + iph4_ex = expected; + iph4_re = received; + iph4_ex->time_to_live -= 1; + if (iph4_re->time_to_live != iph4_ex->time_to_live) + return TEST_FAILED; + } else if (!is_ipv4(received) && !is_ipv4(expected)) { + iph6_ex = expected; + iph6_re = received; + iph6_ex->hop_limits -= 1; + if (iph6_re->hop_limits != iph6_ex->hop_limits) + return TEST_FAILED; + } else { + printf("IP header version miss match\n"); + return TEST_FAILED; + } + + return TEST_SUCCESS; +} + static int test_ipsec_td_verify(struct rte_mbuf *m, const struct ipsec_test_data *td, bool silent, const struct ipsec_test_flags *flags) @@ -728,6 +757,14 @@ test_ipsec_td_verify(struct rte_mbuf *m, const struct ipsec_test_data *td, memcpy(td_output_text, td->output_text.data + skip, len); + if ((td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && + flags->dec_ttl_or_hop_limit) { + if (test_ipsec_ttl_or_hop_decrement_verify(output_text, td_output_text)) { + printf("Inner TTL/hop limit decrement test failed\n"); + return TEST_FAILED; + } + } + if (test_ipsec_pkt_update(td_output_text, flags)) { printf("Could not update expected vector"); return TEST_FAILED; diff --git a/app/test/test_cryptodev_security_ipsec.h b/app/test/test_cryptodev_security_ipsec.h index 12a9b77c55..faf2928846 100644 --- a/app/test/test_cryptodev_security_ipsec.h +++ b/app/test/test_cryptodev_security_ipsec.h @@ -74,6 +74,7 @@ struct ipsec_test_flags { bool fragment; bool stats_success; enum df_flags df; + bool dec_ttl_or_hop_limit; }; struct crypto_param {