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 <ndabilpu...@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

Reply via email to