Skip to contentSkip to conversation

app/test: handle error packets from inline IPsec

PATCH Applied Nithin Dabilpuram 2 participants 2 messages Mar 9, 2023 – Mar 16, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 app/test/test_cryptodev_security_ipsec.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
app/test/test_cryptodev_security_ipsec.c +14 -1
index 221edaa98d..7a8688c692 100644
@@ -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)
Signature · 1 line
2.25.1
Acked-by on v1 1/1 Applied
#1 lore raw
Quoted 8 lines

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.

---

Applied to dpdk-next-crypto

Thanks.