diff mbox series

[net-next] selftests: net: csum: Clean up recv_verify_packet_ipv6

Message ID 20240930162935.980712-1-sean.anderson@linux.dev (mailing list archive)
State Accepted
Commit d772cc25ccf772f4cbb81270970cbe1356c23d3e
Delegated to: Netdev Maintainers
Headers show
Series [net-next] selftests: net: csum: Clean up recv_verify_packet_ipv6 | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 9 this patch: 9
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 9 this patch: 9
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 12 this patch: 12
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 27 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Sean Anderson Sept. 30, 2024, 4:29 p.m. UTC
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.

Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
---

 tools/testing/selftests/net/lib/csum.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Willem de Bruijn Sept. 30, 2024, 5:16 p.m. UTC | #1
Sean Anderson 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.
> 
> Signed-off-by: Sean Anderson <sean.anderson@linux.dev>

Not sure such refactoring patches are worth the effort.
Sean Anderson Sept. 30, 2024, 6:12 p.m. UTC | #2
On 9/30/24 13:16, Willem de Bruijn wrote:
> Sean Anderson 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.
>> 
>> Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
> 
> 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/66dbb4fcbf560_2af86229423@willemb.c.googlers.com.notmuch/

--Sean
Willem de Bruijn Sept. 30, 2024, 6:47 p.m. UTC | #3
Sean Anderson wrote:
> On 9/30/24 13:16, Willem de Bruijn wrote:
> > Sean Anderson 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.
> >> 
> >> Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
> > 
> > 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/66dbb4fcbf560_2af86229423@willemb.c.googlers.com.notmuch/

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.

Reviewed-by: Willem de Bruijn <willemb@google.com>
patchwork-bot+netdevbpf@kernel.org Oct. 4, 2024, midnight UTC | #4
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

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.
> 
> Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
> 
> [...]

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!
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/lib/csum.c b/tools/testing/selftests/net/lib/csum.c
index e0a34e5e8dd5..27437590eeb5 100644
--- a/tools/testing/selftests/net/lib/csum.c
+++ b/tools/testing/selftests/net/lib/csum.c
@@ -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 */