From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>, passt-dev@passt.top
Cc: Laurent Vivier <lvivier@redhat.com>,
David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH 1/7] checksum: Use proto_ipv6_header_psum() for ICMPv6 as well
Date: Mon, 29 Apr 2024 17:09:27 +1000 [thread overview]
Message-ID: <20240429070933.1366881-2-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20240429070933.1366881-1-david@gibson.dropbear.id.au>
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>
---
checksum.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/checksum.c b/checksum.c
index f8a7b539..9cbe0b29 100644
--- a/checksum.c
+++ b/checksum.c
@@ -253,10 +253,8 @@ void csum_icmp6(struct icmp6hdr *icmp6hr,
const struct in6_addr *saddr, const struct in6_addr *daddr,
const void *payload, size_t len)
{
- /* Partial checksum for the pseudo-IPv6 header */
- uint32_t psum = sum_16b(saddr, sizeof(*saddr)) +
- sum_16b(daddr, sizeof(*daddr)) +
- htons(len + sizeof(*icmp6hr)) + htons(IPPROTO_ICMPV6);
+ uint32_t psum = proto_ipv6_header_psum(len + sizeof(*icmp6hr),
+ IPPROTO_ICMPV6, saddr, daddr);
icmp6hr->icmp6_cksum = 0;
/* Add in partial checksum for the ICMPv6 header alone */
--
@@ -253,10 +253,8 @@ void csum_icmp6(struct icmp6hdr *icmp6hr,
const struct in6_addr *saddr, const struct in6_addr *daddr,
const void *payload, size_t len)
{
- /* Partial checksum for the pseudo-IPv6 header */
- uint32_t psum = sum_16b(saddr, sizeof(*saddr)) +
- sum_16b(daddr, sizeof(*daddr)) +
- htons(len + sizeof(*icmp6hr)) + htons(IPPROTO_ICMPV6);
+ uint32_t psum = proto_ipv6_header_psum(len + sizeof(*icmp6hr),
+ IPPROTO_ICMPV6, saddr, daddr);
icmp6hr->icmp6_cksum = 0;
/* Add in partial checksum for the ICMPv6 header alone */
--
2.44.0
next prev parent reply other threads:[~2024-04-29 7:09 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-29 7:09 [PATCH 0/7] Small improvements to IOV handling David Gibson
2024-04-29 7:09 ` David Gibson [this message]
2024-04-29 7:09 ` [PATCH 2/7] tap: Split tap specific and L2 (ethernet) headers David Gibson
2024-04-30 18:46 ` Stefano Brivio
2024-04-30 23:53 ` David Gibson
2024-04-29 7:09 ` [PATCH 3/7] treewide: Standardise variable names for various packet lengths David Gibson
2024-04-30 18:46 ` Stefano Brivio
2024-05-01 0:05 ` David Gibson
2024-04-29 7:09 ` [PATCH 4/7] tcp: Simplify packet length calculation when preparing headers David Gibson
2024-04-29 7:09 ` [PATCH 5/7] tap, tcp: (Re-)abstract TAP specific header handling David Gibson
2024-04-30 18:47 ` Stefano Brivio
2024-05-01 0:06 ` David Gibson
2024-04-29 7:09 ` [PATCH 6/7] iov: Helper macro to construct iovs covering existing variables or fields David Gibson
2024-04-30 18:47 ` Stefano Brivio
2024-05-01 0:09 ` David Gibson
2024-04-29 7:09 ` [PATCH 7/7] tcp: Update tap specific header too in tcp_fill_headers[46]() David Gibson
2024-04-30 18:48 ` Stefano Brivio
2024-05-01 0:10 ` David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240429070933.1366881-2-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=lvivier@redhat.com \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).