On Fri, 8 Aug 2025 20:56:33 +0200
Gábor LENCSE <len...@hit.bme.hu> wrote:

> Dear Stephen,
> 
> Thank you very much for your answer. It helps me a lot, but I have 
> further questions. Please see my comments inline.
> > The pseudo-header part is different.  
> If I understand it correctly, then it means that I need to write the 
> ICMPv6 checksum function myself. To that end, I reviewed the source code 
> of the "rte_ipv6_udptcp_cksum()" function so that I can learn from it. 
> However, I did not find where it differs from the one that I need. I 
> took the below source code from here: 
> https://doc.dpdk.org/api/rte__ip6_8h_source.html#l00610 
> rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const void 
> *l4_hdr) { uint16_t cksum = __rte_ipv6_udptcp_cksum(ipv6_hdr, l4_hdr); 
> cksum = ~cksum; /* * Per RFC 768: If the computed checksum is zero for 
> UDP, * it is transmitted as all ones * (the equivalent in one's 
> complement arithmetic). */ if (cksum == 0 && ipv6_hdr->proto == 
> IPPROTO_UDP) cksum = 0xffff; return cksum; } It is the highest level. It 
> calls an internal function and at the end it considers the protocol 
> number (with other words, the next header field of the IPv6 header) when 
> it handles UDP specific things, thus I think that this time it does not 
> cause any problem in the case of ICMPv6.
> 
> This is the source code of the internal function:
> 
> static inline uint16_t
> __rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const void 
> *l4_hdr)
> {
>      uint32_t cksum;
>      uint32_t l4_len;
> 
>      l4_len = rte_be_to_cpu_16(ipv6_hdr->payload_len);
> 
>      cksum = rte_raw_cksum(l4_hdr, l4_len);
>      cksum += rte_ipv6_phdr_cksum(ipv6_hdr, 0);
> 
>      cksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff);
> 
>      return (uint16_t)cksum;
> }

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.

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



Reply via email to