In dpaa_checksum(), if mbuf->l3_len is zero the L4 header pointer
calculation (l3_hdr + mbuf->l3_len) points to the start of the L3
header rather than the L4 header, leading to incorrect checksum
computation. Add an early return guard when l3_len is zero.

A debug warning is logged to aid diagnosis of mbufs with
uninitialized or corrupt l3_len, since silently skipping checksum
offload would cause the packet to be transmitted without the
requested checksum.

Fixes: 5a8cf1bef775 ("net/dpaa: support checksum offload")
Cc: [email protected]

Signed-off-by: Hemant Agrawal <[email protected]>
---
 drivers/net/dpaa/dpaa_rxtx.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index c5e393159a..3734496d6f 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -377,6 +377,10 @@ static inline void dpaa_checksum(struct rte_mbuf *mbuf)
        struct rte_ipv6_hdr *ipv6_hdr = (struct rte_ipv6_hdr *)l3_hdr;
 
        DPAA_DP_LOG(DEBUG, "Calculating checksum for mbuf: %p", mbuf);
+       if (mbuf->l3_len == 0) {
+               DPAA_DP_LOG(WARNING, "l3_len is 0, skipping checksum for mbuf: 
%p", mbuf);
+               return;
+       }
 
        if (((mbuf->packet_type & RTE_PTYPE_L3_MASK) == RTE_PTYPE_L3_IPV4) ||
            ((mbuf->packet_type & RTE_PTYPE_L3_MASK) ==
-- 
2.43.0

Reply via email to