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=itG3rqqH; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id B25E15A0262 for ; Mon, 11 May 2026 03:42:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1778463758; bh=jkk4uNbQ56hDkzAnj04o23l4GPFIoZY/21tUSOQGfAc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=itG3rqqHXd61f46EryssSF+G1jofBndt3UgoPfd4ATwZWlft3cojHgJgSIvPva1mr qaJM5mWzsZE7/hIwhm3frXmsrSDPCbfztWhxiprkGZY+vJ6jjpgKe7GgL4nOk7XsxX 0P48ATsu0eKo0JW2+LEMvWIGRT8lqoq+tlahP+U9nd9sHNSrGDpWOKoTguVSpuU2T7 zhp+apDm4hiZcrKgRD+sREKqumFfGLTxnALeg5XtF5OxbQCN8Eu32G2w7xJURZAluq 0C0E8PLOdB4ytF6FOz4fMMHMP3rHQmPK18rPiSsYPBRWmqZ0gMXWUxm++npQ1Y2LTQ VgC36vgtP4ZUQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4gDMt651d7z4wJT; Mon, 11 May 2026 11:42:38 +1000 (AEST) Date: Mon, 11 May 2026 11:42:32 +1000 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH v3 07/10] pcap: Pass explicit L2 length to pcap_iov() Message-ID: References: <20260416155721.3807225-1-lvivier@redhat.com> <20260416155721.3807225-8-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="KdkFrM2oeUsl8Uj3" Content-Disposition: inline In-Reply-To: <20260416155721.3807225-8-lvivier@redhat.com> Message-ID-Hash: WDQMIQB6PPLJFFCOB5S3VOGO2IMOQ2NR X-Message-ID-Hash: WDQMIQB6PPLJFFCOB5S3VOGO2IMOQ2NR 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: --KdkFrM2oeUsl8Uj3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 16, 2026 at 05:57:18PM +0200, Laurent Vivier wrote: > With vhost-user multibuffer frames, the iov can be larger than the > actual L2 frame. The previous approach of computing L2 length as > iov_size() - offset would overcount and write extra bytes into the > pcap file. >=20 > Pass the L2 frame length explicitly to pcap_frame() and pcap_iov(), > and write exactly that many bytes instead of the full iov remainder. >=20 > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson [snip] > @@ -500,7 +500,8 @@ static size_t tap_send_frames_passt(const struct ctx = *c, > /* Number of unsent or partially sent buffers for the frame */ > size_t rembufs =3D bufs_per_frame - (i % bufs_per_frame); > =20 > - if (write_remainder(c->fd_tap, &iov[i], rembufs, buf_offset) < 0) { > + if (write_remainder(c->fd_tap, &iov[i], rembufs, buf_offset, > + SIZE_MAX) < 0) { > err_perror("tap: partial frame send"); > return i; [snip] > @@ -722,31 +722,54 @@ int do_clone(int (*fn)(void *), char *stack_area, s= ize_t stack_size, int flags, > * @iov: IO vector > * @iovcnt: Number of entries in @iov > * @skip: Number of bytes of the vector to skip writing > + * @length: Number of bytes of the vector to write Nit: This is the maximum number of bytes to write, not the exact number, which we rely on in tap_send_frames_passt() above. That makes the comment slightly misleading. --=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 --KdkFrM2oeUsl8Uj3 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmoBNAcACgkQzQJF27ox 2GeBig/9EmTvEzDpqiIvNq89AiJh0tFOUQmRpk+F2Zog5btl8YAm+BQXJPZ5kaXs edhpo1w2tvYbFHHGDI3plfAA0KOxSxVO3qGYwmvVOVW7g3EB5PcUwD6ZFzZHmlTa eolcreN7e3P1jQQYPzd2uck24smSyUJYLkNNfyhmFHahMFohBJk89P6Apxb3DAF7 9T6UYagRELn1av4HYb/nmbKqrgSTMxUbvrWKg+iH1DUgDM/hmVq7CwbaMlbHX647 NThECz3lpqdQAOynWqkijhaSGfdELp6SJGF1YQ3Hf0VgcD/Eu3seEuQYC5aDljLf Hz/O9b2Ibe7p3uy4zbBAYlPvBMfY1ZqMRXXUhkxu450+htWzkMY4mEAleqoo5rM2 C3H6nQX0vppmrk0BCCixaj0/RuMo0sFJI5BPVinj9ifqJUyXFWr8CjdCyjSqmHRA Nqf+8IBEQW1drq4IPq2m4Uq1Xsfb3ryTSDmIwL8NFrv6npzwf2pKXPMsH6Dfd5rv 5xRGfZ01U1IKFWNJG9DDvHd7moysC6XXu39tfQvs8PkH1B1I3t2GZY/LnbFRP5gB 5RG2Y/ekgxcdfe5G9twCW3d+tQquoHejp2f+QLxpwA4VHxJ3HpGkqrrVRmsfBeuz a3ukXCqx0o+wm9m1yYByh9lzLLP9M0OM2744OWDRqMMAD2CV6m4= =DOTI -----END PGP SIGNATURE----- --KdkFrM2oeUsl8Uj3--