[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240821142409.958668-1-krzysztof.galazka@intel.com>
Date: Wed, 21 Aug 2024 16:24:09 +0200
From: Krzysztof Galazka <krzysztof.galazka@...el.com>
To: intel-wired-lan@...ts.osuosl.org
Cc: netdev@...r.kernel.org,
Krzysztof Galazka <krzysztof.galazka@...el.com>,
Przemek Kitszel <przemyslaw.kitszel@...el.com>
Subject: [PATCH iwl-net] selftests/net: Fix csum test for short packets
For IPv4 and IPv6 packets shorter than minimum Ethernet
frame payload, recvmsg returns lenght including padding.
Use length from header for checksum verification to avoid
csum test failing on correct packets.
Fixes: 1d0dc857b5d8 (selftests: drv-net: add checksum tests)
Signed-off-by: Krzysztof Galazka <krzysztof.galazka@...el.com>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@...el.com>
---
tools/testing/selftests/net/lib/csum.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/testing/selftests/net/lib/csum.c b/tools/testing/selftests/net/lib/csum.c
index b9f3fc3c3426..3dbaf2ecd59e 100644
--- a/tools/testing/selftests/net/lib/csum.c
+++ b/tools/testing/selftests/net/lib/csum.c
@@ -658,6 +658,9 @@ static int recv_verify_packet_ipv4(void *nh, int len)
if (len < sizeof(*iph) || iph->protocol != proto)
return -1;
+ /* For short packets recvmsg returns length with padding, fix that */
+ len = ntohs(iph->tot_len);
+
iph_addr_p = &iph->saddr;
if (proto == IPPROTO_TCP)
return recv_verify_packet_tcp(iph + 1, len - sizeof(*iph));
@@ -673,6 +676,9 @@ static int recv_verify_packet_ipv6(void *nh, int len)
if (len < sizeof(*ip6h) || ip6h->nexthdr != proto)
return -1;
+ /* For short packets recvmsg returns length with padding, fix that */
+ len = sizeof(*ip6h) + ntohs(ip6h->payload_len);
+
iph_addr_p = &ip6h->saddr;
if (proto == IPPROTO_TCP)
--
2.43.0
Powered by blists - more mailing lists