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 9633BA034C; Wed, 23 Feb 2022 11:41:02 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 85E87411EB; Wed, 23 Feb 2022 11:41:02 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id AA6A940E64 for ; Wed, 23 Feb 2022 11:41:00 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 21N9b5Z3009625; Wed, 23 Feb 2022 02:41:00 -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=NPaRTbRPzRPgSyjNl8UMOcKz5Cft7x3gr/i+GkSzGu4=; b=CWI4Dp/Ewk0anke+qmDdujAsmwIXFCHk++nIj1jbEHKfvbx/XzvmMw32dQ7lN0TpCgaI sK5S03gn+cNnJtEXgaRl8+JHcv0vc9LwEUd0Qmv1c9cJQh0oVPiGKek3PkrhZJ3gOfga +yBfqXHgYy/X2mJfx5XB+aMhScPCRZ/ObQ8HIMdNGj+IXTG8D2ORR0hg8/ceJukumLL1 EexsyeXbm6/LN1VacFKC9CRC9U/VC7YR46ayP6Zzl/8QCtNMmnLNWKOTDR3qyozvzDmL VBxydKkHI0Ko/ZjPWskYdisqHTZTzxw88VgRxOop57K2TSF0OSAQ9gXEGTnYz7RUFNVh 6A== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3edjerg775-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 23 Feb 2022 02:40:59 -0800 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; Wed, 23 Feb 2022 02:40:58 -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; Wed, 23 Feb 2022 02:40:58 -0800 Received: from localhost.localdomain (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id B80963F7079; Wed, 23 Feb 2022 02:40:55 -0800 (PST) From: Volodymyr Fialko To: , Akhil Goyal , Fan Zhang CC: , Volodymyr Fialko , Anoob Joseph Subject: [PATCH v2 1/2] test/crypto: add TTL and hop limit decrement cases Date: Wed, 23 Feb 2022 11:40:45 +0100 Message-ID: <20220223104046.1231153-2-vfialko@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220223104046.1231153-1-vfialko@marvell.com> References: <20220218125203.489078-1-vfialko@marvell.com> <20220223104046.1231153-1-vfialko@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: GGaXis0DOkdUz02Ijhgdk0rQh-RS7C5r X-Proofpoint-GUID: GGaXis0DOkdUz02Ijhgdk0rQh-RS7C5r X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-02-23_03,2022-02-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 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 fc3c09d86f..694b073f4f 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -10102,6 +10102,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) { @@ -15158,6 +15179,14 @@ static struct unit_test_suite ipsec_proto_testsuite = { ut_setup_security, ut_teardown, test_ipsec_proto_pkt_esn_antireplay4096, &pkt_aes_128_gcm), + 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 3887b05135..f66360f4c4 100644 --- a/app/test/test_cryptodev_security_ipsec.c +++ b/app/test/test_cryptodev_security_ipsec.c @@ -443,6 +443,9 @@ test_ipsec_td_prepare(const struct crypto_param *param1, if (flags->dscp == TEST_IPSEC_COPY_DSCP_INNER_0 || flags->dscp == TEST_IPSEC_COPY_DSCP_INNER_1) td->ipsec_xform.options.copy_dscp = 1; + + if (flags->dec_ttl_or_hop_limit) + td->ipsec_xform.options.dec_ttl = 1; } } @@ -650,6 +653,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) @@ -740,6 +769,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 a15c1d3015..7529d2ae50 100644 --- a/app/test/test_cryptodev_security_ipsec.h +++ b/app/test/test_cryptodev_security_ipsec.h @@ -87,6 +87,7 @@ struct ipsec_test_flags { bool antireplay; enum df_flags df; enum dscp_flags dscp; + bool dec_ttl_or_hop_limit; }; struct crypto_param { -- 2.25.1