From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E32B546D28 for ; Thu, 14 Aug 2025 16:44:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DA0D8410E4; Thu, 14 Aug 2025 16:44:19 +0200 (CEST) Received: from frogstar.hit.bme.hu (frogstar.hit.bme.hu [152.66.248.44]) by mails.dpdk.org (Postfix) with ESMTP id 4E129402CA for ; Thu, 14 Aug 2025 16:44:18 +0200 (CEST) Received: from [172.16.18.16] ([193.225.151.17]) (authenticated bits=0) by frogstar.hit.bme.hu (8.18.1/8.17.1) with ESMTPSA id 57EEiBVs051629 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Thu, 14 Aug 2025 16:44:16 +0200 (CEST) (envelope-from lencse@hit.bme.hu) X-Authentication-Warning: frogstar.hit.bme.hu: Host [193.225.151.17] claimed to be [172.16.18.16] Content-Type: multipart/alternative; boundary="------------f0SnLLdYmavpQKV6WyITRWen" Message-ID: <691b98f2-6dc6-47cd-a5a0-437f9858d115@hit.bme.hu> Date: Thu, 14 Aug 2025 16:43:55 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Solved! :-) -- Re: How to calculate ICMPv6 checksum? To: Stephen Hemminger Cc: "users@dpdk.org" References: <40938de8-49b3-46d0-964b-9cd296000d10@hit.bme.hu> <20250807105703.22de669d@hermes.local> <20250812165706.52ac3b50@hermes.local> Content-Language: en-US From: =?UTF-8?Q?G=C3=A1bor_LENCSE?= In-Reply-To: <20250812165706.52ac3b50@hermes.local> X-Virus-Scanned: clamav-milter 1.4.3 at frogstar.hit.bme.hu X-Virus-Status: Clean Received-SPF: pass (frogstar.hit.bme.hu: authenticated connection) receiver=frogstar.hit.bme.hu; client-ip=193.225.151.17; helo=[172.16.18.16]; envelope-from=lencse@hit.bme.hu; x-software=spfmilter 2.001 http://www.acme.com/software/spfmilter/ with libspf2-1.2.11; X-DCC--Metrics: frogstar.hit.bme.hu; whitelist X-Spam-Status: No, score=-0.9 required=5.0 tests=ALL_TRUSTED, AWL, HTML_MESSAGE, PLING_QUERY,T_SCC_BODY_TEXT_LINE autolearn=disabled version=3.4.6-frogstar X-Spam-Checker-Version: SpamAssassin 3.4.6-frogstar (2021-04-09) on frogstar.hit.bme.hu X-Scanned-By: MIMEDefang 2.86 on 152.66.248.44 X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: users-bounces@dpdk.org This is a multi-part message in MIME format. --------------f0SnLLdYmavpQKV6WyITRWen Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Dear Stephen, On 8/13/2025 1:57 AM, Stephen Hemminger wrote: [...] > Yes this is similar but in UDP/TCP case the UDP/TCP header is included in > the checksum. l4_hdr points to the UDP/TCP header. l4_len is the payload > length that is TCP/UDP header and the associated data. Yes, when I tried using the rte_ipv6_udptcp_cksum() function, I supplied a pointer to the ICMPv6 header as the second argument. My code line was: reply_icmpv6_hdr->checksum=rte_ipv6_udptcp_cksum(reply_ipv6_hdr,reply_icmpv6_hdr); And the internal function reads out the payload length from the IPv6 header as follows:     l4_len = rte_be_to_cpu_16(ipv6_hdr->payload_len); This is also correct. > The pseudo header is done by rte_ipv6_phdr_cksum(). > > For ICMPv6 you would need to point l4_hdr at ICMP header. > Even though ICMP is not really an L4 protocol. > > https://en.wikipedia.org/wiki/ICMPv6#Checksum > Yes, I checked the drawing, this is the same as https://www.rfc-editor.org/rfc/rfc2460#section-8.1 and the code calculates exactly the same (with some trick, as I mentioned earlier). *And the calculated checksum is CORRECT! :-)* It turned out, that I had made a programming error. (My calculation of the address of the checksum field was incorrect, and thus I manipulated a wrong field.) Anyway, thank you very much for all your help! I learnt a lot from checking how ICMPv6 checksum is calculated. :-) And I hope that it will be useful information for others that the rte_ipv6_udptcp_cksum() function is perfectly suitable for calculating ICMPv6 checksum, too. :-) Best regards, Gábor --------------f0SnLLdYmavpQKV6WyITRWen Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Dear Stephen,

On 8/13/2025 1:57 AM, Stephen Hemminger wrote:
[...]

Yes this is similar but in UDP/TCP case the UDP/TCP header is included in
the checksum. l4_hdr points to the UDP/TCP header. l4_len is the payload
length that is TCP/UDP header and the associated data.

Yes, when I tried using the rte_ipv6_udptcp_cksum() function, I supplied a pointer to the ICMPv6 header as the second argument. My code line was:

    reply_icmpv6_hdr->checksum=rte_ipv6_udptcp_cksum(reply_ipv6_hdr,reply_icmpv6_hdr);  

And the internal function reads out the payload length from the IPv6 header as follows:

    l4_len = rte_be_to_cpu_16(ipv6_hdr->payload_len);

This is also correct.

The pseudo header is done by rte_ipv6_phdr_cksum().

For ICMPv6 you would need to point l4_hdr at ICMP header.
Even though ICMP is not really an L4 protocol.

https://en.wikipedia.org/wiki/ICMPv6#Checksum

Yes, I checked the drawing, this is the same as https://www.rfc-editor.org/rfc/rfc2460#section-8.1 and the code calculates exactly the same (with some trick, as I mentioned earlier).

And the calculated checksum is CORRECT! :-)

It turned out, that I had made a programming error. (My calculation of the address of the checksum field was incorrect, and thus I manipulated a wrong field.)

Anyway, thank you very much for all your help! 

I learnt a lot from checking how ICMPv6 checksum is calculated. :-)

And I hope that it will be useful information for others that the rte_ipv6_udptcp_cksum() function is perfectly suitable for calculating ICMPv6 checksum, too. :-)

Best regards,

Gábor



--------------f0SnLLdYmavpQKV6WyITRWen--