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 D5E645A02EA for ; Wed, 1 May 2024 02:10:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1714522228; bh=8dAkNKxGRM5awgG7BI0ZM0g709X1HutnGKaEhAg74k0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mM9spoOuJHx5hT3NTa3HFXU/i5T+00BQvXnnJ5AeH+0fw23UNxi3N5JWD0WA6RSMB PFY/Fl5DNOG6SDv+auy74fGoMu2OfxDUsWxRbj9uq3MCAO9K9KyXE2skxhGLGHgMHb ASp283raRYl9IpNP13haGI5HafEMec2BI8hzifnGBYeBJwbuuh+fem0Hb8OIVcazGB GlqQm6Qzl0Tb2QRHFkpG5ZvB0UpcesUUW3zlP5tXwXcFSXM0SxHO0K0mG1hJnQsfIc XAG3OBb6bE+Vi7o5+caEGZfBMuHGir7B8FgD/v6V0Sql74luA38jZuUPexPc2EF1im 0ZNmy92lRrW1g== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4VTcsJ38Pyz4xLw; Wed, 1 May 2024 10:10:28 +1000 (AEST) Date: Wed, 1 May 2024 10:09:02 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 6/7] iov: Helper macro to construct iovs covering existing variables or fields Message-ID: References: <20240429070933.1366881-1-david@gibson.dropbear.id.au> <20240429070933.1366881-7-david@gibson.dropbear.id.au> <20240430204746.6441f86b@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="eP4pwbh+oCd+UOfP" Content-Disposition: inline In-Reply-To: <20240430204746.6441f86b@elisabeth> Message-ID-Hash: 35XU7IHDQNRKPH3LZFQIVH3IXNFUPIDM X-Message-ID-Hash: 35XU7IHDQNRKPH3LZFQIVH3IXNFUPIDM 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, Laurent Vivier X-Mailman-Version: 3.3.8 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: --eP4pwbh+oCd+UOfP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 30, 2024 at 08:47:46PM +0200, Stefano Brivio wrote: > On Mon, 29 Apr 2024 17:09:32 +1000 > David Gibson wrote: >=20 > > Laurent's recent changes mean we use IO vectors much more heavily in the > > TCP code. In many of those cases, and few others around the code base, > > individual iovs of these vectors are constructed to exactly cover exist= ing > > variables or fields. We can make initializing such iovs shorter and > > clearer with a macro for the purpose. > >=20 > > Signed-off-by: David Gibson > > --- > > iov.h | 3 +++ > > tap.c | 3 +-- > > tcp.c | 24 +++++++++--------------- > > udp.c | 7 +++---- > > 4 files changed, 16 insertions(+), 21 deletions(-) > >=20 > > diff --git a/iov.h b/iov.h > > index 6058af77..5668ca5f 100644 > > --- a/iov.h > > +++ b/iov.h > > @@ -18,6 +18,9 @@ > > #include > > #include > > =20 > > +#define IOV_OF_LVALUE(lval) \ > > + (struct iovec){ .iov_base =3D &(lval), .iov_len =3D sizeof(lval) } >=20 > I'm not sure if IOV_OF_LVALUE() is much clearer than IOV_FROM() or > IOV_OF(). No strong preference though. Yeah, I don't love the name but it was the best I came up with. I wanted to emphasise the fact that it must be given an lvalue - this has to be a macro, not a function (even inline). [snip] > > @@ -315,8 +316,7 @@ static void udp_sock4_iov_init_one(const struct ctx= *c, size_t i) > > .iph =3D L2_BUF_IP4_INIT(IPPROTO_UDP) > > }; > > =20 > > - siov->iov_base =3D buf->data; > > - siov->iov_len =3D sizeof(buf->data); > > + *siov =3D IOV_OF_LVALUE(buf->data); > > =20 > > mh->msg_name =3D &buf->s_in; > > mh->msg_namelen =3D sizeof(buf->s_in); > > @@ -343,8 +343,7 @@ static void udp_sock6_iov_init_one(const struct ctx= *c, size_t i) > > .ip6h =3D L2_BUF_IP6_INIT(IPPROTO_UDP) > > }; > > =20 > > - siov->iov_base =3D buf->data; > > - siov->iov_len =3D sizeof(buf->data); > > + *siov =3D IOV_OF_LVALUE(buf->data); >=20 > Extra whitespace between tabs and =3D. Oops, fixed. --=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 --eP4pwbh+oCd+UOfP Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmYxiB0ACgkQzQJF27ox 2Gf2rhAAhdVW6+3hyJnqFHhY7dN0O80KWABDguZ645RYEQ67Zx/E/2AHagD08sav 2SqMNXsyoN3Jnvy6OF5/k/zlQolLTeCu+st9R0weXJ0Ut89ofLtcRn6GWHlXvc5T 4KM667dWK6xFnPewtxLTOHYDMsLRPkv1M5P8faHIV4Wa5Ibb4sbyQx68vvYJQOdv spl7Z/wuEvMhlis7Moy9IoO9PBg756m2Dr1HrMVGM5VRcW9wd/gDLEeBxl4VcDZS oBz98avQOT4VhDsyr+7iosVxUFRvacF+OGLH4zXTMWRxYCJnKyVJLwAtcAncO9S9 JZ3MNDPpW3vrhQlo2QeRz1TfaP22EBbklv5Ctz6k/GikbjTBqcHL1L/3VZLf6l1P rzWY+mvzasntVaFKumboGLc8iYA7PfSy6Mnec8FGVV0w28SLk1u7CLtiiBiKr5Is ptOY0PIIaxl77R4lSFD8mhsvX3EdXJz1xmsAVndyI+JT9f85fQFg96L0FQZrSYJK NZpFMUA1C/VnQqcjBpabwV5KvesL8w/JPXjYqgab8ddS4xpx0t1iaQS30dBJxa01 /vBE0D+THr5EvCVYtjXDGRcQbXOB60NfOpVyfvHemBAr5HXTYSE2o3+Q/IiN508H /A2fKYe4Xffrui4Pgn2ObqBDP4d10BsgbxBsGMQLxNplpFC/Egc= =nK79 -----END PGP SIGNATURE----- --eP4pwbh+oCd+UOfP--