From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id B0C0F5A0285 for ; Mon, 29 Apr 2024 09:09:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1714374575; bh=VjwYlcLnQdBgGwjf16JO70ceRqeBHsdqx4cG0Ug1N2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DodIyqNVpA/Ii5oz+navstY1ls5tRID8CkRr7mtB2t+RXaQLGqmWeHbnlw0tX9KG3 uN6vl+NXjcUXDm9OkQeZS10NmAhMcBBbi5XxJ48se/PmvkZoTRKpff6vyjbdlJRvrl xpFrLLhzrX3+PwZ9Zpk7O/Wx7PV+dqgCSbHy2CrZXkdLpKCuXAQTVwaaf9DPj4+fij 2WzpE5hqKydcjWWTmCNO/Z/5jQzJhbuQ/pqxzA3nibtkODydtpIvw0/+z+Eb4pp+QO JRGhYj2i8mOxXxJDhHFn2sxe2BeXEWof7BxFgowqGefA9h9Nbac8nz+vffjZrAGPSG lMbZ/AC9O8/zw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4VSZFq4nsFz4x0C; Mon, 29 Apr 2024 17:09:35 +1000 (AEST) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 1/7] checksum: Use proto_ipv6_header_psum() for ICMPv6 as well Date: Mon, 29 Apr 2024 17:09:27 +1000 Message-ID: <20240429070933.1366881-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429070933.1366881-1-david@gibson.dropbear.id.au> References: <20240429070933.1366881-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: I5SJSZ4N2HH5KROWWZR4MNMGQV7UXEWB X-Message-ID-Hash: I5SJSZ4N2HH5KROWWZR4MNMGQV7UXEWB X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Laurent Vivier , David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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 */ -- 2.44.0