]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
selftests: net: csum: Fix checksums for packets with non-zero padding
authorSean Anderson <sean.anderson@linux.dev>
Fri, 6 Sep 2024 21:07:43 +0000 (17:07 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Sep 2024 17:24:09 +0000 (19:24 +0200)
commit033a71efabac967241c885ee469823b0d560f4e6
tree6dd331edfae840ecc4d24eaa59f641a224ad15ec
parent38859fb5bdb64ec6d894be25c013295aa058277c
selftests: net: csum: Fix checksums for packets with non-zero padding

[ Upstream commit e8a63d473b49011a68a748aea1c8aefa046ebacf ]

Padding is not included in UDP and TCP checksums. Therefore, reduce the
length of the checksummed data to include only the data in the IP
payload. This fixes spurious reported checksum failures like

rx: pkt: sport=33000 len=26 csum=0xc850 verify=0xf9fe
pkt: bad csum

Technically it is possible for there to be trailing bytes after the UDP
data but before the Ethernet padding (e.g. if sizeof(ip) + sizeof(udp) +
udp.len < ip.len). However, we don't generate such packets.

Fixes: 91a7de85600d ("selftests/net: add csum offload test")
Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20240906210743.627413-1-sean.anderson@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/net/csum.c