From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 56FDB5A0265 for ; Tue, 18 Oct 2022 14:08:11 +0200 (CEST) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4MsCLH4gBpz4xGT; Tue, 18 Oct 2022 23:08:07 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1666094887; bh=NkvhyR2XBAOQUr9GXctVs41gjNdl6WgRFt1WzQzJREE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HapTkL0LRy/9WbiQI3egXhpG62A1lIdN1pi0igEiIs3ZnISukcnYn93DZiuSxE4E+ Rz/I1pwb4kTZPPTqJusaXCj4YSuOj6Nu7Ja+a1ZOYPAhfyKhwIwldZIrXmR4oSsVbQ q9Sk6YGwCjME2KHOaH8dHLJwCS00DfvXjvP8yIy0= Date: Tue, 18 Oct 2022 23:07:00 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 05/14] Add csum_ip4_header() helper to calculate IPv4 header checksums Message-ID: References: <20221017085807.473470-1-david@gibson.dropbear.id.au> <20221017085807.473470-6-david@gibson.dropbear.id.au> <20221018050349.19c0a0a9@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="aFJgenZKnyDjWh9Y" Content-Disposition: inline In-Reply-To: <20221018050349.19c0a0a9@elisabeth> Message-ID-Hash: X4VMHYSMNWDY5YRFPK2YWPSB3I6BPR2A X-Message-ID-Hash: X4VMHYSMNWDY5YRFPK2YWPSB3I6BPR2A 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 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: --aFJgenZKnyDjWh9Y Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Oct 18, 2022 at 05:03:49AM +0200, Stefano Brivio wrote: > On Mon, 17 Oct 2022 19:57:58 +1100 > David Gibson wrote: >=20 > > We calculate IPv4 header checksums in at least two places, in dhcp() and > > in tap_ip_send. Add a helper to handle this calculation in both places. > >=20 > > Signed-off-by: David Gibson > > --- > > checksum.c | 6 ++++++ > > checksum.h | 1 + > > dhcp.c | 3 +-- > > tap.c | 3 +-- > > 4 files changed, 9 insertions(+), 4 deletions(-) > >=20 > > diff --git a/checksum.c b/checksum.c > > index 72f1cfb..f25a96a 100644 > > --- a/checksum.c > > +++ b/checksum.c > > @@ -114,6 +114,12 @@ uint16_t csum_unaligned(const void *buf, size_t le= n, uint32_t init) > > return (uint16_t)~csum_fold(sum_16b(buf, len) + init); > > } > > =20 >=20 > /** > * csum_ip4_header() - Calculate and set IPv4 header checksum > * @iph: IPv4 header > */ >=20 > ...I just tried to run Doxygen, I think it would be nice to have > eventually (especially for DOT call graphs), things don't look too bad. >=20 > > +void csum_ip4_header(struct iphdr *ip4hr) > > +{ > > + ip4hr->check =3D 0; > > + ip4hr->check =3D csum_unaligned(ip4hr, (size_t)ip4hr->ihl * 4, 0); >=20 > iph, for consistency. As noted before, I'd prefer to avoid the implication that IPv4 is normal and IPv6 is special. I have changed to just ip4h, though. --=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 --aFJgenZKnyDjWh9Y Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoULxWu4/Ws0dB+XtgypY4gEwYSIFAmNOlt4ACgkQgypY4gEw YSLaNA/+PFmIo3CfEYb1Aqf06DVRIGHBvnj0t+O4OC1AgvljnzVyDmDotib9DtHy l4bICaxpugAQUZ3i98vvK/OBv8yGoKRUAC5B+4JB0sx6Q+YMyW4+8XsOXmN/RSPm hRzYFcgCEUj62XQAKuZzrPj9kpxxrwIXbak5NGPV7S/Xf8kmzgWDsZWNXspHh1Em FISqDwKZti6b/O+8T8slAcFHF4cYuChfddrKNn006YIiW3Hj7vkuKG5pph1csJsu 4+5JpohxPCGVgKYIfbwJIxwVHpR9CGPIQ4+KLQ1nWsze3IDrxN4arUD0h6tJ6grI PA+5/zbG77mqNhtpPiuwnHL0maLAcPLroyblVOMXzmagwmcXeQ2boBTs4OQf87Xn ACISYBBYkl2PWsEgHQw68GY2aR6doIKwrQLngW9+x4vmYT/LzwKe/rX4d5wOTTKa dwPLUvHLoYCVnw1PhA+94dThGF/rgPKubk7IuPwETusCz/+QS9J//dPn56vMmsv4 c9Wv51uKRZ28lQhhjpBazLTb2z2RQaGyhnPOOeaxKn+LMw2Y8B+M48a7DHOkMlvm Wv8PonZDjE45LwBXPsa4vhD+Jsf0iYYwpym6ho0ZiWYbTSP7+WYrsxxnyHri3jgB ytNXajNJOea8nRlDd+VfqlVFIEF+pvrfw59k61WC5IEEsZgy2Z4= =Z3ZD -----END PGP SIGNATURE----- --aFJgenZKnyDjWh9Y--