checksum: Use proto_ipv6_header_psum() for ICMPv6 as well

7df624e79 ("checksum: introduce functions to compute the header part
checksum for TCP/UDP") introduced a helper to compute the partial checksum
for the IPv6 pseudo-header used in L4 protocol checksums.  It used it in
csum_udp6() for UDP packets, but not in csum_icmp6() for the identical
calculation in csum_icmp6() for ICMPv6 packets.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
David Gibson 2024-05-01 16:53:44 +10:00 committed by Stefano Brivio
parent 76e32022c4
commit c27ca91564

View file

@ -253,10 +253,8 @@ void csum_icmp6(struct icmp6hdr *icmp6hr,
const struct in6_addr *saddr, const struct in6_addr *daddr, const struct in6_addr *saddr, const struct in6_addr *daddr,
const void *payload, size_t len) const void *payload, size_t len)
{ {
/* Partial checksum for the pseudo-IPv6 header */ uint32_t psum = proto_ipv6_header_psum(len + sizeof(*icmp6hr),
uint32_t psum = sum_16b(saddr, sizeof(*saddr)) + IPPROTO_ICMPV6, saddr, daddr);
sum_16b(daddr, sizeof(*daddr)) +
htons(len + sizeof(*icmp6hr)) + htons(IPPROTO_ICMPV6);
icmp6hr->icmp6_cksum = 0; icmp6hr->icmp6_cksum = 0;
/* Add in partial checksum for the ICMPv6 header alone */ /* Add in partial checksum for the ICMPv6 header alone */