Skip to contentSkip to conversation

selftests: net: csum: Clean up recv_verify_packet_ipv6

PATCH Applied Sean Anderson 3 participants 5 messages Sep 30, 2024 – Oct 4, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: net: csum: Clean up recv_verify_packet_ipv6

Rename ip_len to payload_len since the length in this case refers only to the payload, and not the entire IP packet like for IPv4. While we're at it, just use the variable directly when calling recv_verify_packet_udp/tcp.

---

 tools/testing/selftests/net/lib/csum.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
tools/testing/selftests/net/lib/csum.c +5 -7
index e0a34e5e8dd5..27437590eeb5 100644
@@ -675,22 +675,20 @@ static int recv_verify_packet_ipv6(void *nh, int len)
 {
 	struct ipv6hdr *ip6h = nh;
 	uint16_t proto = cfg_encap ? IPPROTO_UDP : cfg_proto;
-	uint16_t ip_len;
+	uint16_t payload_len;
 
 	if (len < sizeof(*ip6h) || ip6h->nexthdr != proto)
 		return -1;
 
-	ip_len = ntohs(ip6h->payload_len);
-	if (ip_len > len - sizeof(*ip6h))
+	payload_len = ntohs(ip6h->payload_len);
+	if (payload_len > len - sizeof(*ip6h))
 		return -1;
 
-	len = ip_len;
 	iph_addr_p = &ip6h->saddr;
-
 	if (proto == IPPROTO_TCP)
-		return recv_verify_packet_tcp(ip6h + 1, len);
+		return recv_verify_packet_tcp(ip6h + 1, payload_len);
 	else
-		return recv_verify_packet_udp(ip6h + 1, len);
+		return recv_verify_packet_udp(ip6h + 1, payload_len);
 }
 
 /* return whether auxdata includes TP_STATUS_CSUM_VALID */
Signature · 1 line
2.35.1.1320.gc452695387.dirty
#1 lore raw
Quoted 6 lines · Sean Anderson

Rename ip_len to payload_len since the length in this case refers only to the payload, and not the entire IP packet like for IPv4. While we're at it, just use the variable directly when calling recv_verify_packet_udp/tcp.

Not sure such refactoring patches are worth the effort.

#2 lore raw
Quoted 9 lines · Willem de Bruijn
Quoted 6 lines · Sean Anderson

Rename ip_len to payload_len since the length in this case refers only to the payload, and not the entire IP packet like for IPv4. While we're at it, just use the variable directly when calling recv_verify_packet_udp/tcp.

Not sure such refactoring patches are worth the effort.

Well, FWIW you commented on this in your review, so I figured I'd send it.

https://lore.kernel.org/all/[email protected]/

--Sean

Reviewed-by
#3 lore raw
Quoted 7 lines · Sean Anderson
Quoted 6 lines · Willem de Bruijn
Quoted 5 lines · Sean Anderson

Rename ip_len to payload_len since the length in this case refers only to the payload, and not the entire IP packet like for IPv4. While we're at it, just use the variable directly when calling recv_verify_packet_udp/tcp.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Not sure such refactoring patches are worth the effort.

Well, FWIW you commented on this in your review, so I figured I'd send it.

https://lore.kernel.org/all/[email protected]/

True. I meant if respun.

Whether such changes are worth it as standalone patch is subjective. And I get where you're coming from, given that thread.

#4 lore raw
In reply to Sean Anderson
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Mon, 30 Sep 2024 12:29:34 -0400 you wrote:

Rename ip_len to payload_len since the length in this case refers only to the payload, and not the entire IP packet like for IPv4. While we're at it, just use the variable directly when calling recv_verify_packet_udp/tcp.

[...]

Here is the summary with links:
- [net-next] selftests: net: csum: Clean up recv_verify_packet_ipv6

    https://git.kernel.org/netdev/net-next/c/d772cc25ccf7

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html