[dpdk-dev] [PATCH] bugfix: rte_raw_checksum

guohongzhi guohongzhi1 at huawei.com
Wed May 27 15:40:09 CEST 2020


From: Hongzhi Guo <guohongzhi1 at huawei.com>

__rte_raw_cksum should consider Big Endian.

Signed-off-by: Hongzhi Guo <guohongzhi1 at huawei.com>
---
 lib/librte_net/rte_ip.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h
index 1ceb7b7..eb863d4 100644
--- a/lib/librte_net/rte_ip.h
+++ b/lib/librte_net/rte_ip.h
@@ -140,7 +140,11 @@ __rte_raw_cksum(const void *buf, size_t len, uint32_t sum)
 
 	/* if length is in odd bytes */
 	if (len == 1)
+#if (RTE_BYTE_ORDER == RTE_BIG_ENDIAN)
+		sum += *((const uint8_t *)u16_buf) << 8;
+#else
 		sum += *((const uint8_t *)u16_buf);
+#endif
 
 	return sum;
 }
-- 
2.21.0.windows.1




More information about the dev mailing list