public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: passt-dev@passt.top
Subject: Re: [PATCH 1/4] tap: Don't pcap frames that didn't get sent
Date: Thu, 16 Feb 2023 08:43:00 +0100	[thread overview]
Message-ID: <20230216084300.0c73da63@elisabeth> (raw)
In-Reply-To: <Y+29LEiZBbq8wDtN@yekko>

On Thu, 16 Feb 2023 16:20:44 +1100
David Gibson <david@gibson.dropbear.id.au> wrote:

> On Wed, Feb 15, 2023 at 01:17:25PM +0100, Stefano Brivio wrote:
> > On Fri, 27 Jan 2023 16:11:07 +1100
> > David Gibson <david@gibson.dropbear.id.au> wrote:
> >   
> > > 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.
> > > 
> > > We do give a debug message in this case, but it's misleading to add frames
> > > that we know weren't sent to the capture file.  Rework to avoid this.  
> > 
> > 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.

Actually, I was thinking of the passt case too: the send() in
tap_send_remainder() might fail -- but then, contrary to what I wrote,
there's nothing to truncate, because the socket back-end in QEMU
doesn't deliver partial frames either. So this patch is actually
correct in that regard.

Unrelated: given that QEMU is going to have a "reconnect" option:
  http://patchwork.ozlabs.org/project/qemu-devel/patch/20230119101645.2001683-1-lvivier@redhat.com/

perhaps, if tap_send_remainder() fails, we should now close the socket
to give the guest the best chances to recover? Compared to terminating
the process, this has the advantage of keeping the whole state.

-- 
Stefano


  reply	other threads:[~2023-02-16  7:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-27  5:11 [PATCH 0/4] RFC: Some cleanups to tap and tcp David Gibson
2023-01-27  5:11 ` [PATCH 1/4] tap: Don't pcap frames that didn't get sent David Gibson
2023-02-15 12:17   ` Stefano Brivio
2023-02-16  5:20     ` David Gibson
2023-02-16  7:43       ` Stefano Brivio [this message]
2023-01-27  5:11 ` [PATCH 2/4] tap: Eliminate goto from tap_handler() David Gibson
2023-01-27  5:11 ` [PATCH 3/4] tcp: Remove 'recvmsg' goto from tcp_data_from_sock David Gibson
2023-02-15 12:17   ` Stefano Brivio
2023-02-16  0:28     ` David Gibson
2023-01-27  5:11 ` [PATCH 4/4] tcp: Remove 'zero_len' " David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230216084300.0c73da63@elisabeth \
    --to=sbrivio@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).