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=bdatpQEq; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 7BB2B5A0619 for ; Mon, 02 Mar 2026 01:13:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1772410422; bh=8yMMIZCn6TxRFFVObAV1XMshwAlKpSYVt93Db9aGI30=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bdatpQEq2LQ9phmDdpIsMmE/ZsXI+ZO4JfK9ePRh2G2Ote5+nXTuidHUUfO7mr6oM d6GYurrUL0EeARketTw3GECDc7ApQ6HbHmYVq/2BB/1rLlqifIpGvNMX66hpG85d38 kAQ7JejaQVlSTco/w0impe58or4/EP1zs1xL8pVvSL4mZf9AD/h5K8cJ9J5y4+i7RN Jj1iPUMA1dRzpnJH3O86AqLi1K+EpK/Y59eXQ4AzoP8Ip7dMErBoaMzxgZRa/wK0un Ar7rl8BtXZSK6WS4hDZkFMaDBuTXmWranux1KGF7Ot6lWyaiG4rYL1nG2dzccNh1rt pQKr4+2T7GOpg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4fPKCp4ZS7z4wCX; Mon, 02 Mar 2026 11:13:42 +1100 (AEDT) Date: Mon, 2 Mar 2026 11:08:45 +1100 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH 05/12] iov: Add IOV_PUT_HEADER() to write header data back to iov_tail Message-ID: References: <20260227140330.2216753-1-lvivier@redhat.com> <20260227140330.2216753-6-lvivier@redhat.com> MIME-Version: 1.0 In-Reply-To: <20260227140330.2216753-6-lvivier@redhat.com> 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 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="07jdKpwFws8yonxM" Content-Disposition: inline Message-ID-Hash: AONLCMPCWVG5PTOK24AZM2ZH67ZRJE5Q X-Message-ID-Hash: AONLCMPCWVG5PTOK24AZM2ZH67ZRJE5Q 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: --07jdKpwFws8yonxM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Feb 27, 2026 at 03:03:23PM +0100, Laurent Vivier wrote: > Add a counterpart to IOV_PEEK_HEADER() that writes header data back > to an iov_tail after modification. If the header pointer matches the > original iov buffer location, it only advances the offset. Otherwise, > it copies the data using iov_from_buf(). >=20 > Signed-off-by: Laurent Vivier Concept looks good to me. > --- > iov.c | 22 ++++++++++++++++++++++ > iov.h | 14 +++++++++++++- > 2 files changed, 35 insertions(+), 1 deletion(-) >=20 > diff --git a/iov.c b/iov.c > index 8836305fb701..2cf23d284e4a 100644 > --- a/iov.c > +++ b/iov.c > @@ -296,6 +296,28 @@ void *iov_peek_header_(struct iov_tail *tail, void *= v, size_t len, size_t align) > =09return v; > } > =20 > +/** > + * iov_put_header_() - Write header back to an IOV tail > + * @tail:=09IOV tail to write header to > + * @v:=09=09Pointer to header data to write > + * @len:=09Length of header to write, in bytes > + * > + * Return: number of bytes written > + */ > +/* cppcheck-suppress unusedFunction */ > +size_t iov_put_header_(struct iov_tail *tail, const void *v, size_t len) > +{ > +=09size_t l =3D len; > + > +=09/* iov_peek_header_() already called iov_check_header() */ > +=09if ((char *)tail->iov[0].iov_base + tail->off !=3D v) > +=09=09l =3D iov_from_buf(tail->iov, tail->cnt, tail->off, v, len); IIUC, there's a strong requirement that this only be called after a matching iov_peek_header_(), yes? If that's the case then (l !=3D len) would mean something has already gone badly wrong - so should it be an ASSERT()? > +=09tail->off +=3D l; > + > +=09return l; > +} > + > /** > * iov_remove_header_() - Remove a header from an IOV tail > * @tail:=09IOV tail to remove header from (modified) > diff --git a/iov.h b/iov.h > index a7b873d58134..08cf60639358 100644 > --- a/iov.h > +++ b/iov.h > @@ -86,6 +86,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_put_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, > =09=09 struct iov_tail *tail); > @@ -110,6 +111,16 @@ void iov_tail_zero_end(struct iov_tail *tail, size_t= size); > =09=09=09=09=09 sizeof(var_),=09=09\ > =09=09=09=09=09 __alignof__(var_)))) > =20 > +/** > + * IOV_PUT_HEADER() - Write header back to an IOV tail > + * @tail_:=09IOV tail to write header to > + * @var_:=09Pointer to a variable containing the header data to write > + * > + * Return: number of bytes written > + */ > +#define IOV_PUT_HEADER(tail_, var_)=09=09=09=09=09\ > +=09(iov_put_header_((tail_), (var_), sizeof(*var_))) > + > /** > * IOV_REMOVE_HEADER() - Remove and return typed header from an IOV tail > * @tail_:=09IOV tail to remove header from (modified) > @@ -128,7 +139,8 @@ void iov_tail_zero_end(struct iov_tail *tail, size_t = size); > =09((__typeof__(var_) *)(iov_remove_header_((tail_), &(var_),=09\ > =09=09=09=09 sizeof(var_), __alignof__(var_)))) > =20 > -/** IOV_DROP_HEADER() - Remove a typed header from an IOV tail > +/** > + * IOV_DROP_HEADER() - Remove a typed header from an IOV tail > * @tail_:=09IOV tail to remove header from (modified) > * @type_:=09Data type of the header to remove > * > --=20 > 2.53.0 >=20 --=20 David Gibson (he or they)=09| I'll have my music baroque, and my code david AT gibson.dropbear.id.au=09| minimalist, thank you, not the other way =09=09=09=09| around. http://www.ozlabs.org/~dgibson --07jdKpwFws8yonxM Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmmk1QwACgkQzQJF27ox 2Geixg/+Oh4symmfW2a2jSZyB7SI06z1H9MqQ8E7KfRRDp2h/egCwO8YgyWFV1x8 uNdBiUElJPEvlLnzbHSrG7LIBAC1LEoR02Rqpl0mYkHxJAOuEtKzxkXIYBr+BEuR byEz8odN2bsJUh9pnPRyyhNhTSOytVsAvnwYDk8Qzsz9wHxBEbabw3t+CdmAF4A/ Su3CwJz5Y1PuYEyFSeJM0rjTHu9YdzorZa1MOyZvDkcDYnNG08GoArugGD9LI+DL WRB9ID/SV67MxftVmywh5wmlON/mllPVOWcRsoRB2a5OI1vRI7TC9H0Ub7d6ft6F TSfv5Fu0mXFieefkg9xrqhgrYH3BS0EyOv0lC/0ukQEhUS6L1vcF9LC7I+oFYCPq PpjqxDidLb3HxRS7PiruHzXfidJJmE+K0PlLucwS/tAM+wdLF3w96ghF6bXppH2j q7zUj0NGfJqEKaIneV6IwGDmnGlRBpayrl5sZCl/D1MOdreSARb0A0CEHQLjZl+0 ZQz7/U6AkHLkds0MCb8xk218LIaOoOryMYMqeIC/lD7Nfe/36DztmOu/Ck6hlPm7 ROKyJSHpmIdQ/Ik7cgA0/K9hNIMjghVp5wFm3UG03ZVzkeMWUo9Y0riw0hOrPJo1 EZzrmO7+cVGfjtSsr5E5JahNJRdRSFsOy0LQc7BlRLCh900THXw= =VE/l -----END PGP SIGNATURE----- --07jdKpwFws8yonxM--