From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202602 header.b=MaSd5rgO; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id DE43E5A0262 for ; Mon, 13 Apr 2026 03:44:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1776044666; bh=+ZQyxhIgEl69sURw77XM/HnzjzgxrTsh9qWyw8rEldI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MaSd5rgOA/jK9q2g2PeNOpSWcY5L/5eaCV/8InQz2wo+7H3PuFceWBq8Lv3jYaO9r 7T1rHkUalS3kzgnQlLFmBvTkIo4K0ZNrRBCnj1AwSpYNGtLbYP5wpQDsaSHqAise/E gpg8S6cp2VNnc0h0Ds99tURCzSlwgaZlqiFEDSK3OZB33agPRUCpnCri94w/Zf0myS WH5s4Aa2U0RwBTBeQQE9K4sekvzFyDnvro/KsrgfwvZ6sA8ldkuzJjBlG2Elr7+r/c 3g+XB5NbkkRB3lg3/683KdVL1rYYX8UOzx0eW7fPkYwHEI+UtGf0NeUNF1BhclB1WN 4Q19+QLk/IMKg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4fv9F62X9qz4wJ1; Mon, 13 Apr 2026 11:44:26 +1000 (AEST) Date: Mon, 13 Apr 2026 11:43:04 +1000 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH v7 2/3] iov: Introduce IOV_PUSH_HEADER() macro Message-ID: References: <20260403164241.3212528-1-lvivier@redhat.com> <20260403164241.3212528-3-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Y6ZtPu+EtCMfpZHD" Content-Disposition: inline In-Reply-To: <20260403164241.3212528-3-lvivier@redhat.com> Message-ID-Hash: ATOEH5EINDU3FVKLJEZSKXANNCEHSQJE X-Message-ID-Hash: ATOEH5EINDU3FVKLJEZSKXANNCEHSQJE 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.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: --Y6ZtPu+EtCMfpZHD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Apr 03, 2026 at 06:42:40PM +0200, Laurent Vivier wrote: > Add iov_push_header_() and its typed wrapper IOV_PUSH_HEADER() to write > a header into an iov_tail at the current offset and advance past it. >=20 > This is the write counterpart to IOV_PEEK_HEADER() / IOV_REMOVE_HEADER(), > using iov_from_buf() to copy the header data across iovec boundaries. >=20 > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson > --- > iov.c | 23 +++++++++++++++++++++++ > iov.h | 11 +++++++++++ > 2 files changed, 34 insertions(+) >=20 > diff --git a/iov.c b/iov.c > index 28c6d40d2986..b1bcdc4649df 100644 > --- a/iov.c > +++ b/iov.c > @@ -360,6 +360,29 @@ void *iov_peek_header_(struct iov_tail *tail, void *= v, size_t len, size_t align) > return v; > } > =20 > +/** > + * iov_push_header_() - Write a new header to an IOV tail > + * @tail: IOV tail to write header to > + * @v: Pointer to header data to write > + * @len: Length of header to write, in bytes > + * > + * Return: number of bytes written > + */ > +/* cppcheck-suppress unusedFunction */ > +size_t iov_push_header_(struct iov_tail *tail, const void *v, size_t len) > +{ > + size_t l; > + > + if (!iov_tail_prune(tail)) > + return 0; /* No space */ > + > + l =3D iov_from_buf(tail->iov, tail->cnt, tail->off, v, len); > + > + tail->off =3D tail->off + l; > + > + return l; > +} > + > /** > * iov_remove_header_() - Remove a header from an IOV tail > * @tail: IOV tail to remove header from (modified) > diff --git a/iov.h b/iov.h > index 3c63308e554f..4fdf14a85b19 100644 > --- a/iov.h > +++ b/iov.h > @@ -93,6 +93,7 @@ bool iov_tail_prune(struct iov_tail *tail); > size_t iov_tail_size(struct iov_tail *tail); > bool iov_drop_header(struct iov_tail *tail, size_t len); > void *iov_peek_header_(struct iov_tail *tail, void *v, size_t len, size_= t align); > +size_t iov_push_header_(struct iov_tail *tail, const void *v, size_t len= ); > void *iov_remove_header_(struct iov_tail *tail, void *v, size_t len, siz= e_t align); > ssize_t iov_tail_clone(struct iovec *dst_iov, size_t dst_iov_cnt, > struct iov_tail *tail); > @@ -115,6 +116,16 @@ ssize_t iov_tail_clone(struct iovec *dst_iov, size_t= dst_iov_cnt, > sizeof(var_), \ > __alignof__(var_)))) > =20 > +/** > + * IOV_PUSH_HEADER() - Write a new header to an IOV tail > + * @tail_: IOV tail to write header to > + * @var_: A variable containing the header data to write > + * > + * Return: number of bytes written > + */ > +#define IOV_PUSH_HEADER(tail_, var_) \ > + (iov_push_header_((tail_), &(var_), sizeof(var_))) > + > /** > * IOV_REMOVE_HEADER() - Remove and return typed header from an IOV tail > * @tail_: IOV tail to remove header from (modified) > --=20 > 2.53.0 >=20 --=20 David Gibson (he or they) | 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 --Y6ZtPu+EtCMfpZHD Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmncSicACgkQzQJF27ox 2GdsXw/+JMB3RE1YFmOIXQDKpsy7WQEL8Q1QbiH+1WfJriQXkRaGBo07/R8JbH0Y ovKFauI7GAe7YP6vmUzuOLlqeMHjrey1JtjIY3lcvNXJbm7IlLhJ7RA2aRajSGbB WKEMczdt3+Lf6YSwLZzuU9/bO4EBCloPNzuGJXB5gtOgf8E7D1AdWMeWwlaGm0ba eiKSmzBy3bRg6q2zW4uvUUZu38FqV+Mm6Kb+n35WNRomMJNg/6oNhIFBbjaqVPHu p/clybLQ2FsNRioYtKCcgg653zxepHOKzDPNbkh2yTYbtGuXNPr2qrZprV8WZqxI 58EiEsG8kvYanv5osVfrpQ3i+yYPJFdBvjyUNWofxb3ZkAXcHfTrOCx/p8zoBv1A wkOm0Iq2XNb8rUJ52Io4URfcLeSjvVvqVldO0Wam+wqfsy6arGhJL1+aTwxRaE3I r9obYqoXcuKiRCk3oRNV+Pgoj9UNF62tbD64p1mDToop0ro/hTNVVAoiKpBCOlH6 AajApraw9Q01Ynsvlkg8ZglHomm/dWkP8L9nJWp7u4wzPDgrn+PLTBB/GvA78hLX zjAUzAcnxG9cKr0W2oXqIyk4G+a44crcjgFcLdoHH4uHVjHlvM/3vfaeEv+lAR8E LVC1+xyLcDdQV2C0lFfVaKFKEGugRfK530ylb3amTVBbL6Q5By0= =KguB -----END PGP SIGNATURE----- --Y6ZtPu+EtCMfpZHD--