From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 7D6B85A0082 for ; Wed, 26 Oct 2022 02:07:19 +0200 (CEST) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Mxpyr0Rjqz4xGG; Wed, 26 Oct 2022 11:07:16 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1666742836; bh=GTPKOZi+fxngZ7TtUiKhBxi3evzqFgDgxmnxgj/KLdI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=m04v4KjimUgjmS0tNYObzu0OsJjCsPD9oefMVOHJ8Vu8p3RSAp8yPLHy9sIkKdN+n CbCaPkqxs275TKwmDjvFZlgq1I4vWSMtWyKA1VF+7syD5Av05Le+NR10UezAtiSqQQ 1mD3BIegbC1GWBw1ebqzwtqOfB19yRDRN8nQkqBc= Date: Wed, 26 Oct 2022 11:06:16 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] checksum: Fix calculation for ICMP checksum on IPv4 Message-ID: References: <20221025160713.1024373-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="4IgA57a7xUT96y9p" Content-Disposition: inline In-Reply-To: <20221025160713.1024373-1-sbrivio@redhat.com> Message-ID-Hash: MKWZH2APNJ2I4Y3PZVJQLQWVQWUOVOUA X-Message-ID-Hash: MKWZH2APNJ2I4Y3PZVJQLQWVQWUOVOUA X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, Paul Holzinger X-Mailman-Version: 3.3.3 Precedence: list List-Id: Development discussion and patches for passt Archived-At: <> Archived-At: List-Archive: <> List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --4IgA57a7xUT96y9p Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Oct 25, 2022 at 06:07:13PM +0200, Stefano Brivio wrote: > We need to zero out the checksum field before calculating the > checksum, of course. I have no idea how this passed the "icmp" test > set, looking into it. >=20 > Reported-by: Paul Holzinger > Fixes: 67ab6171729c ("Add csum_icmp4() helper for calculating ICMP checks= ums") > Signed-off-by: Stefano Brivio Oops, that's embarrassing. Reviewed-by: David Gibson > --- > checksum.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) >=20 > diff --git a/checksum.c b/checksum.c > index 09d2c7c..c59869c 100644 > --- a/checksum.c > +++ b/checksum.c > @@ -160,10 +160,13 @@ void csum_udp4(struct udphdr *udp4hr, in_addr_t sad= dr, in_addr_t daddr, > */ > void csum_icmp4(struct icmphdr *icmp4hr, const void *payload, size_t len) > { > - /* Partial checksum for ICMP header alone */ > - uint32_t psum =3D sum_16b(icmp4hr, sizeof(*icmp4hr)); > + uint32_t psum; > =20 > icmp4hr->checksum =3D 0; > + > + /* Partial checksum for ICMP header alone */ > + psum =3D sum_16b(icmp4hr, sizeof(*icmp4hr)); > + > icmp4hr->checksum =3D csum_unaligned(payload, len, psum); > } > =20 --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --4IgA57a7xUT96y9p Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoULxWu4/Ws0dB+XtgypY4gEwYSIFAmNYed4ACgkQgypY4gEw YSIR6Q//R2Uw1Qj6M0wGwtoJJ1VXkIydSiscHVYff42RU12hcZpPRmRiivgZVrzY 7attbHtjOTsabuIF5s2hCCWb5S9uTytjoSlLAcZ+2UyuqCI5RlgotupQp6ko6mnn MPSulpuQPjlicvT7T+rXUMmP4Fvo1yAh1Aq/A6Mc5x8eEYb0shxDUEfTobbuZ65g 1/qveNY7D/pW1O5kUnmWyTKjvbtkOpNR9A8vBQNcKBN0WRwYDsHoW8H/A6o4cHyk eXZ4XlWUr7qt40e4qv0PibSJxyZdlQn72SkRLVXhyIDCaJtGat/YfR4Dn1YpA/Xw RBOhJfzxSrRgsQothVNVhiIrDIlaGzyMJ9yb+0S5WoykzzoZlL7VHqaJQP9XzBBF HbpLV9A1JUE2VeCz/kM6tLgi1BeoM1nnkfLStTELvq/+MO2rHhZuItZA9L9YHN4c hPmZxcqC/GPfMHEgGYt7gZaDcUi/Vt3OrjEwBnQJ1wp7DQFZxIXiKKdg7yXYWPz5 zLhiPQiRKqzw90d2SJmONxK9gmyEfNubgqqKLk/xMIY07q5eRanAuZTqrwE6KyyH F7hZsl8PQf7rRQ9AmIvDI+kqzcmWwjR9clwm42DOPL3Y0xNBR726t43lUr+sDTXM szF6iovUR1WsAi2x5pZZhsTslxC0yurmSKfzfwsji7CcaiCSm/g= =rJAL -----END PGP SIGNATURE----- --4IgA57a7xUT96y9p--