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 271BB41E25; Thu, 9 Mar 2023 12:53:50 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C3EDD40ED7; Thu, 9 Mar 2023 12:53:49 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 3A285400D7 for ; Thu, 9 Mar 2023 12:53:48 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 329BR9kl022833; Thu, 9 Mar 2023 03:53:47 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=cqLa7ZKJm9NrvTnrFGMQDmD6mjerujLSti4bSKDZOIM=; b=eJi4jTCkxwFQzDxmT5hHMil53vwnd+kkrjlG6N9bjM3bcTd9J7lPrJDu99XOBZ9gUdZr XHEuOib5IuU9dL4Hr6YXzhliPNwgwR1rXsOsaV4oHOBHkFwGeRKRYcyGed48LFJ7QeyE WyZ5ZSohdYjBS3Qu9F/uUOeysJAPvghKOFL2ffmI4eIIYgcG6nFQjnO98iwNpSE0OW8o iG7EauZ3u4AfkpccLxKuYrlIcdjElJDl0/nJ/fCBdSppsAtkjNJR+GXcpXuz0+4eN1aK JPMMGGtenINVgcQYeND36q9wkZBuZtjuinrJs7rY6IQFXrqALkMVJgEkWxSz6OldQQIF 7g== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3p6n7qm9hn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 09 Mar 2023 03:53:47 -0800 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.42; Thu, 9 Mar 2023 03:53:45 -0800 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.42 via Frontend Transport; Thu, 9 Mar 2023 03:53:45 -0800 Received: from hyd1588t430.caveonetworks.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id B4ECB3F704C; Thu, 9 Mar 2023 03:53:43 -0800 (PST) From: Nithin Dabilpuram To: Akhil Goyal , Fan Zhang CC: , , Nithin Dabilpuram Subject: [PATCH] app/test: handle error packets from inline IPsec Date: Thu, 9 Mar 2023 17:23:39 +0530 Message-ID: <20230309115339.1677916-1-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: 5ONSZZTr1BCdTijfXHuLVgnM0I__xnJk X-Proofpoint-GUID: 5ONSZZTr1BCdTijfXHuLVgnM0I__xnJk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-09_06,2023-03-08_03,2023-02-09_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 In inline IPsec path, when the ol_flags indicate error, pkt might be incomplete. Hence don't trust the m->pkt_len to determine the size of packet, rather consider even data length's per segment. Signed-off-by: Nithin Dabilpuram --- app/test/test_cryptodev_security_ipsec.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/test/test_cryptodev_security_ipsec.c b/app/test/test_cryptodev_security_ipsec.c index 221edaa98d..7a8688c692 100644 --- a/app/test/test_cryptodev_security_ipsec.c +++ b/app/test/test_cryptodev_security_ipsec.c @@ -1042,11 +1042,24 @@ test_ipsec_post_process(const struct rte_mbuf *m, const struct ipsec_test_data * struct ipsec_test_data *res_d, bool silent, const struct ipsec_test_flags *flags) { - uint32_t len = rte_pktmbuf_pkt_len(m); + uint32_t len = rte_pktmbuf_pkt_len(m), data_len; uint8_t output_text[IPSEC_TEXT_MAX_LEN]; + const struct rte_mbuf *seg; const uint8_t *output; int ret; + memset(output_text, 0, IPSEC_TEXT_MAX_LEN); + /* Actual data in packet might be less in error cases, + * hence take minimum of pkt_len and sum of data_len. + * This is done to run through negative test cases. + */ + data_len = 0; + seg = m; + while (seg) { + data_len += seg->data_len; + seg = seg->next; + } + len = RTE_MIN(len, data_len); /* Copy mbuf payload to continuous buffer */ output = rte_pktmbuf_read(m, 0, len, output_text); if (output != output_text) -- 2.25.1