<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Dear Stephen,</p>
    <div class="moz-cite-prefix">On 8/13/2025 1:57 AM, Stephen Hemminger
      wrote:</div>
    <div class="moz-cite-prefix"><span style="white-space: pre-wrap">
</span></div>
    <div class="moz-cite-prefix">[...]</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <span style="white-space: pre-wrap">
</span>
    <blockquote type="cite"
      cite="mid:20250812165706.52ac3b50@hermes.local">
      <pre wrap="" class="moz-quote-pre">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.</pre>
    </blockquote>
    <p>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:</p>
    <p><font face="monospace">   
reply_icmpv6_hdr->checksum=rte_ipv6_udptcp_cksum(reply_ipv6_hdr,reply_icmpv6_hdr);  </font></p>
    <p>And the internal function reads out the payload length from the
      IPv6 header as follows:</p>
    <p><font face="monospace">    l4_len =
        rte_be_to_cpu_16(ipv6_hdr->payload_len);</font></p>
    <p>This is also correct.</p>
    <blockquote type="cite"
      cite="mid:20250812165706.52ac3b50@hermes.local">
      <pre wrap="" class="moz-quote-pre">
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.

<a class="moz-txt-link-freetext" href="https://en.wikipedia.org/wiki/ICMPv6#Checksum">https://en.wikipedia.org/wiki/ICMPv6#Checksum</a>

</pre>
    </blockquote>
    <p>Yes, I checked the drawing, this is the same as
      <a class="moz-txt-link-freetext" href="https://www.rfc-editor.org/rfc/rfc2460#section-8.1">https://www.rfc-editor.org/rfc/rfc2460#section-8.1</a> and the code
      calculates exactly the same (with some trick, as I mentioned
      earlier).</p>
    <b>And the calculated checksum is CORRECT! :-)</b>
    <p>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.)</p>
    <p>Anyway, thank you very much for all your help! </p>
    <p>I learnt a lot from checking how ICMPv6 checksum is calculated.
      :-)</p>
    <p>And I hope that it will be useful information for others that
      the <font face="monospace">rte_ipv6_udptcp_cksum()</font> function
      is perfectly suitable for calculating ICMPv6 checksum, too. :-)</p>
    <p>Best regards,</p>
    <p>Gábor</p>
    <p><br>
    </p>
    <p><br>
    </p>
  </body>
</html>