DPDK usage discussions
 help / color / mirror / Atom feed
From: "Gábor LENCSE" <lencse@hit.bme.hu>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: "users@dpdk.org" <users@dpdk.org>
Subject: Solved! :-) -- Re: How to calculate ICMPv6 checksum?
Date: Thu, 14 Aug 2025 16:43:55 +0200	[thread overview]
Message-ID: <691b98f2-6dc6-47cd-a5a0-437f9858d115@hit.bme.hu> (raw)
In-Reply-To: <20250812165706.52ac3b50@hermes.local>

[-- Attachment #1: Type: text/plain, Size: 1605 bytes --]

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



[-- Attachment #2: Type: text/html, Size: 2827 bytes --]

      reply	other threads:[~2025-08-14 14:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-07 15:32 Gábor LENCSE
2025-08-07 17:57 ` Stephen Hemminger
2025-08-08 18:56   ` Gábor LENCSE
2025-08-12 23:57     ` Stephen Hemminger
2025-08-14 14:43       ` Gábor LENCSE [this message]

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=691b98f2-6dc6-47cd-a5a0-437f9858d115@hit.bme.hu \
    --to=lencse@hit.bme.hu \
    --cc=stephen@networkplumber.org \
    --cc=users@dpdk.org \
    /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.
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 NNTP newsgroup(s).