DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] app/test: handle error packets from inline IPsec
@ 2023-03-09 11:53 Nithin Dabilpuram
  2023-03-16 18:26 ` Akhil Goyal
  0 siblings, 1 reply; 2+ messages in thread
From: Nithin Dabilpuram @ 2023-03-09 11:53 UTC (permalink / raw)
  To: Akhil Goyal, Fan Zhang; +Cc: jerinj, dev, Nithin Dabilpuram

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(-)

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-16 18:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-09 11:53 [PATCH] app/test: handle error packets from inline IPsec Nithin Dabilpuram
2023-03-16 18:26 ` Akhil Goyal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).