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 E015B5A026B for ; Thu, 16 Feb 2023 06:43:19 +0100 (CET) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4PHP4K5HYQz4x88; Thu, 16 Feb 2023 16:43:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1676526193; bh=CvEkocHxYVCa+TluOXR51bxIS9aHFZjMgzP/lI3Bkjs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ICafkJvA1TpF4l8//jyIoh/lIa/iW0rs31DWiJqCY1BT5EEuwaXuNxhnMOrxGLqzf vKamKKoC4oIC6SVM2vBHBZj0lTrAE0uaAnq5yVqk5WZ5LxjnAAlRjAk0hq+HIcw371 HEW3FrwOMV8/uaIDbsr2oVe3dZAPy0sp6HrcOn9g= Date: Thu, 16 Feb 2023 16:20:44 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 1/4] tap: Don't pcap frames that didn't get sent Message-ID: References: <20230127051110.2513363-1-david@gibson.dropbear.id.au> <20230127051110.2513363-2-david@gibson.dropbear.id.au> <20230215131725.02d3c6fd@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="k4i9uUu/aZ3GxKEB" Content-Disposition: inline In-Reply-To: <20230215131725.02d3c6fd@elisabeth> Message-ID-Hash: V464B4RJHXKMJBEFHLR4KQQXHXFSCECE X-Message-ID-Hash: V464B4RJHXKMJBEFHLR4KQQXHXFSCECE 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: --k4i9uUu/aZ3GxKEB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Feb 15, 2023 at 01:17:25PM +0100, Stefano Brivio wrote: > On Fri, 27 Jan 2023 16:11:07 +1100 > David Gibson wrote: >=20 > > In tap_send_frames() we send a number of frames to the tap device, then > > also write them to the pcap capture file (if configured). However the = tap > > send can partially fail (short write()s or similar), meaning that some > > of the requested frames weren't actually sent, but we still write those > > frames to the capture file. > >=20 > > We do give a debug message in this case, but it's misleading to add fra= mes > > that we know weren't sent to the capture file. Rework to avoid this. >=20 > To be really "correct", I guess we should also truncate messages in > captures if they were sent partially, by returning the number of bytes > sent from tap_send_frames_{pasta,passt}() and then modifying the > argument to pcap_frame() in the pcap_multiple() loop. True.. that only applies for the pasta case, though. For passt we always send a whole frame, or the stream would get out of sync. > This is relevant because, if a packet has a checksum, we could consider > it lost while checking captures. >=20 > Still, it's a vast improvement on the original, so I would apply this > even like it is -- except for two nits, below: >=20 > > Signed-off-by: David Gibson > > --- > > tap.c | 30 ++++++++++++++++++++---------- > > 1 file changed, 20 insertions(+), 10 deletions(-) > >=20 > > diff --git a/tap.c b/tap.c > > index af9bc15..dd22490 100644 > > --- a/tap.c > > +++ b/tap.c > > @@ -309,10 +309,12 @@ void tap_icmp6_send(const struct ctx *c, > > * @iov: Array of buffers, each containing one frame > > * @n: Number of buffers/frames in @iov > > * > > + * Returns: number of frames successfully sent >=20 > For consistency: "Return:" -- I see now that one slipped through in > pcap_frame(). I can "fix" this on merge or in a follow-up patch, too. >=20 > > + * > > * #syscalls:pasta write > > */ > > -static void tap_send_frames_pasta(struct ctx *c, > > - const struct iovec *iov, size_t n) > > +static size_t tap_send_frames_pasta(struct ctx *c, > > + const struct iovec *iov, size_t n) > > { > > size_t i; > > =20 > > @@ -324,6 +326,8 @@ static void tap_send_frames_pasta(struct ctx *c, > > i--; > > } > > } > > + > > + return n; > > } > > =20 > > /** > > @@ -356,10 +360,12 @@ static void tap_send_remainder(const struct ctx *= c, const struct iovec *iov, > > * @iov: Array of buffers, each containing one frame > > * @n: Number of buffers/frames in @iov > > * > > + * Returns: number of frames successfully sent >=20 > Same here. 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 --k4i9uUu/aZ3GxKEB Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmPtvSUACgkQzQJF27ox 2Gc85A//X9KvvQHzRQebTvCZkS0/N54HTds3K9MNh6ZwdmB008Wei8fDdKbA3bqa T3hGfSOJOmUzJPCC4uEpJK8k0KmRS06S+rZ1ZS+NRWbsnGe2eA/9MmB/xdTqUR6/ xbSj2lZrQi9GQIRprf5i5yWWPsgNqqGl2JMt3z8Hy4Kdpv+HUiUxkU4zJT9nS4JX 3/qvW4Lsn2lZnaFMhyO6+or8/zzHcHLmMUaFTiG24g/MFaEtMn+28gAYm3ED6Z27 X1XZ9h2EHwfr0WsB7Na7O0XgiC5ilVKSYcN71k2FVBLh7UO9ONjVsx4MfajRp9+6 8Y2nHhVuSIFxBHj2O1XtLwvWx/HDepMCUPycieVscbVb7F9GXCa9yhkko/7oUJcS YL3ruGCVKuD9f7P5X6i01jX+U7SBrL5kaa382ZGVTXMSwsqxW65IshOqYyYoFZ67 Eok2+CdwX7p46N6wx6v4C8CZdmXjbcKHNQYBMofCqEI9S5F/NQ//xJAQDYaGa0lD LAYjMAEzzZDEhJ8G8BLZ8NNyL4FKjaGwfPA9xlYt8aYpUp9HDMMhjEGzNjgIMakN Pzl82R5eFNmfvFJYK+DC87bfpQDWusXsjranBh1B/88ucLnrcW8Bd7cv94hTgOo7 8WpxdoIUhiVUTXCCIl9HlVbcp04m5eZReI3/tT9q4c5m0uMjaRs= =WCQL -----END PGP SIGNATURE----- --k4i9uUu/aZ3GxKEB--