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 B709346D0F for ; Wed, 13 Aug 2025 01:57:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4F4844025D; Wed, 13 Aug 2025 01:57:13 +0200 (CEST) Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by mails.dpdk.org (Postfix) with ESMTP id 08B50400EF for ; Wed, 13 Aug 2025 01:57:11 +0200 (CEST) Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-3b9141866dcso640082f8f.2 for ; Tue, 12 Aug 2025 16:57:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1755043031; x=1755647831; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=gEdtsbhOM8cjMDqWRZ6d8klbeZ/9aUYGnX18iYbtDYE=; b=M2BfA8o6D7pXH+4l8gUaEcIGdZxhNWYvw0NRO/Ddn5edHOVofkPq915opuvWu86gkF 4/oJr81Ky3A9vc8c344XmzPMH89D306VR0O0eIPvFj9mZAelgD2Z9EQ1lojHCEsq1XAz Sr6MG0HhEsmZyFMtbye+U+TgEtXVw/1VZoT18IdLsV9txFZXyi+pqwVzAw+VtR937mZt CsL+ftvOZXyW3L7zvhFsrcXKBXfLh7t9uXiuEvvuLn9EZCkh51B9W3I9j4ztekMMXdBW Zg0nFZZ+T2SVnvYueDt5PKGK0RX/a1lrdJfCwodZZMaUHKav+BBZN6/xf7PgEsesZqTN ywKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755043031; x=1755647831; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gEdtsbhOM8cjMDqWRZ6d8klbeZ/9aUYGnX18iYbtDYE=; b=D/qiy0+ybZaET28aWxI8cbW8WGcgLvrR/rAYv7oaaaMI+PEpbjhIm9PbeaPRaUkobT kk3q58RV5vqp5tMDbF7geSKDnkaXocVsUram/8wKb5a7K3DN7Pj1hD1SilQJMW6Kw+pr 4mY4+thEAs6S6BM2YCYYAgT1zEO9klh6alIgU4Id/7JrQQVt1P7+IM5/+UjF0HIiSXES 9dKQI5/lCLAuZXwgFr3KtAwqX/PRURIPrFVGaqtZ/mCYU53Ir7UfvB9JMWMsyybYOey2 /UB03NU8EUbmUM6ib7Hri6kJSGh6AyF7+i8JjEOYeu+5CUjVv3slWXHYdgBbHoS4jDZE 147w== X-Gm-Message-State: AOJu0YyVUa0NcSZVi5/XV+xzGyQsWHhHk/ehTCFqrcmbl20kW5NtUqww xKxXBMjUxFXX5XoWhlrw8S96hnPYdJvpPdRK7guJmPqoGHAovgFLiC/QUWq/r/6KEEQ/s0MLTZ0 YE8ox X-Gm-Gg: ASbGncum02N/DmkENQ6xLUTO27cTY2eP1I+wgJ8iXq6nn6wtVr1xj9hosc2nAy0tkPV x3j/Bi7o18ojObyme2ktphqJ4wtu/t1LXnpkHaXijyvt8szBz7qiQHbrCUwNC0NRukSyo+OZSIR 6jTixwZmg/0MjeRV4OZtSk/QB/ACM4yF/Qf/Ww2VtbNkqiGTNc6KPLrm/7HzH1lrk5tVAbeazqT OAorivcxAtT5r0IDWtfw2wZ1900User/VzBxEs9YG++zUvAq3/wsEIE3r/d/MhB14nssBSvTOPf ClA21XPwwXkiXABweFyPMtmzN/8jU6KoAsDXZGUhvTQi3+7YMWlsgEKzm7eOv4sbQE4RNytx+eV rCnOcm3srX3srz55HSEly1aJfkDCucrov27fOLpN8eQw5WJ9mw+cs8zkbrVEf9T3rkxArXsdTtV w= X-Google-Smtp-Source: AGHT+IG1g2sCErW6qkKl0LPq8S9pFz2DZBWxxW4ONa298GNpJLlKQAeOwUL7Ol/QXeOAOVupcQU/Ow== X-Received: by 2002:a05:6000:2dc6:b0:3b7:b3f2:f8c3 with SMTP id ffacd0b85a97d-3b917eca9d0mr505329f8f.57.1755043031189; Tue, 12 Aug 2025 16:57:11 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b79c3abeb2sm45758673f8f.11.2025.08.12.16.57.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Aug 2025 16:57:10 -0700 (PDT) Date: Tue, 12 Aug 2025 16:57:06 -0700 From: Stephen Hemminger To: =?UTF-8?B?R8OhYm9y?= LENCSE Cc: "users@dpdk.org" Subject: Re: How to calculate ICMPv6 checksum? Message-ID: <20250812165706.52ac3b50@hermes.local> In-Reply-To: References: <40938de8-49b3-46d0-964b-9cd296000d10@hit.bme.hu> <20250807105703.22de669d@hermes.local> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 On Fri, 8 Aug 2025 20:56:33 +0200 G=C3=A1bor LENCSE wrote: > Dear Stephen, >=20 > Thank you very much for your answer. It helps me a lot, but I have=20 > further questions. Please see my comments inline. > > The pseudo-header part is different. =20 > If I understand it correctly, then it means that I need to write the=20 > ICMPv6 checksum function myself. To that end, I reviewed the source code= =20 > of the "rte_ipv6_udptcp_cksum()" function so that I can learn from it.=20 > However, I did not find where it differs from the one that I need. I=20 > took the below source code from here:=20 > https://doc.dpdk.org/api/rte__ip6_8h_source.html#l00610=20 > rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const void=20 > *l4_hdr) { uint16_t cksum =3D __rte_ipv6_udptcp_cksum(ipv6_hdr, l4_hdr);= =20 > cksum =3D ~cksum; /* * Per RFC 768: If the computed checksum is zero for= =20 > UDP, * it is transmitted as all ones * (the equivalent in one's=20 > complement arithmetic). */ if (cksum =3D=3D 0 && ipv6_hdr->proto =3D=3D=20 > IPPROTO_UDP) cksum =3D 0xffff; return cksum; } It is the highest level. I= t=20 > calls an internal function and at the end it considers the protocol=20 > number (with other words, the next header field of the IPv6 header) when= =20 > it handles UDP specific things, thus I think that this time it does not=20 > cause any problem in the case of ICMPv6. >=20 > This is the source code of the internal function: >=20 > static inline uint16_t > __rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const void=20 > *l4_hdr) > { > =C2=A0=C2=A0=C2=A0 uint32_t cksum; > =C2=A0=C2=A0=C2=A0 uint32_t l4_len; >=20 > =C2=A0=C2=A0=C2=A0 l4_len =3D rte_be_to_cpu_16(ipv6_hdr->payload_len); >=20 > =C2=A0=C2=A0=C2=A0 cksum =3D rte_raw_cksum(l4_hdr, l4_len); > =C2=A0=C2=A0=C2=A0 cksum +=3D rte_ipv6_phdr_cksum(ipv6_hdr, 0); >=20 > =C2=A0=C2=A0=C2=A0 cksum =3D ((cksum & 0xffff0000) >> 16) + (cksum & 0xf= fff); >=20 > =C2=A0=C2=A0=C2=A0 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