Skip to content

Commit d772cc2

Browse files
Sean Andersonkuba-moo
authored andcommitted
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. Signed-off-by: Sean Anderson <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent be4e323 commit d772cc2

File tree

1 file changed

+5
-7
lines changed
  • tools/testing/selftests/net/lib

1 file changed

+5
-7
lines changed

tools/testing/selftests/net/lib/csum.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -675,22 +675,20 @@ static int recv_verify_packet_ipv6(void *nh, int len)
675675
{
676676
struct ipv6hdr *ip6h = nh;
677677
uint16_t proto = cfg_encap ? IPPROTO_UDP : cfg_proto;
678-
uint16_t ip_len;
678+
uint16_t payload_len;
679679

680680
if (len < sizeof(*ip6h) || ip6h->nexthdr != proto)
681681
return -1;
682682

683-
ip_len = ntohs(ip6h->payload_len);
684-
if (ip_len > len - sizeof(*ip6h))
683+
payload_len = ntohs(ip6h->payload_len);
684+
if (payload_len > len - sizeof(*ip6h))
685685
return -1;
686686

687-
len = ip_len;
688687
iph_addr_p = &ip6h->saddr;
689-
690688
if (proto == IPPROTO_TCP)
691-
return recv_verify_packet_tcp(ip6h + 1, len);
689+
return recv_verify_packet_tcp(ip6h + 1, payload_len);
692690
else
693-
return recv_verify_packet_udp(ip6h + 1, len);
691+
return recv_verify_packet_udp(ip6h + 1, payload_len);
694692
}
695693

696694
/* return whether auxdata includes TP_STATUS_CSUM_VALID */

0 commit comments

Comments
 (0)