app/test: handle error packets from inline IPsec

Message ID 20230309115339.1677916-1-ndabilpuram@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series app/test: handle error packets from inline IPsec |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-testing warning Testing issues
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Nithin Dabilpuram March 9, 2023, 11:53 a.m. UTC
  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 <ndabilpuram@marvell.com>
---
 app/test/test_cryptodev_security_ipsec.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
  

Comments

Akhil Goyal March 16, 2023, 6:26 p.m. UTC | #1
> Subject: [PATCH] app/test: handle error packets from inline IPsec
> 
> 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 <ndabilpuram@marvell.com>
> ---
Acked-by: Akhil Goyal <gakhil@marvell.com>

Applied to dpdk-next-crypto

Thanks.
  

Patch

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)