[PATCH] net: fix cksum calculation for odd-sized segment
Stephen Hemminger
stephen at networkplumber.org
Tue Aug 18 04:16:52 CEST 2026
On Thu, 13 Aug 2026 23:22:35 +0300
Eva Kurchatova <eva.kurchatova at virtuozzo.com> wrote:
> The rte_raw_cksum_mbuf() performs rte_bswap16() on return value from
> __rte_raw_cksum() for odd-sized segments. However, __rte_raw_cksum()
> returns a 32-bit accumulator whose upper 16 bits may still contain
> carries that must be folded. Truncating those upper bits by passing to
> rte_bswap16() will produce an invalid checksum if they are non-zero.
>
> This is surely a rare encounter in practice, as most NICs have hardware
> checksum offloads, and even then encountering an odd-sized SG segment
> is not common, but currently such a case would miscompute the checksum.
>
> I found this issue by accident when comparing RVVM networking stack
> packet checksuming to DPDK, and noticed that this looked incorrect.
>
> Fix this by folding the odd-sized segment checksum before bswap16.
>
> Signed-off-by: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
Acked-by: Stephen Hemminger <stephen at networkplumber.org>
More information about the dev
mailing list