From: Stefan Hajnoczi <stefanha@redhat.com>
To: Thomas Huth <thuth@redhat.com>
Cc: Stefan Hajnoczi <stefanha@gmail.com>,
Jason Wang <jasowang@redhat.com>,
qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 4/5] net/dump: Add dump option for netdev devices
Date: Wed, 1 Jul 2015 09:36:53 +0100 [thread overview]
Message-ID: <20150701083653.GA13991@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <20150630123746.5e8626df@thh440s>
[-- Attachment #1: Type: text/plain, Size: 1990 bytes --]
On Tue, Jun 30, 2015 at 12:37:46PM +0200, Thomas Huth wrote:
> On Fri, 26 Jun 2015 10:44:59 +0100
> Stefan Hajnoczi <stefanha@gmail.com> wrote:
>
> > On Wed, Jun 24, 2015 at 05:56:20PM +0200, Thomas Huth wrote:
> > > diff --git a/net/net.c b/net/net.c
> > > index cc36c7b..8871b77 100644
> > > --- a/net/net.c
> > > +++ b/net/net.c
> > > @@ -568,6 +568,12 @@ ssize_t qemu_deliver_packet(NetClientState *sender,
> > > return 0;
> > > }
> > >
> > > + if (nc->netdev_dump_enabled) {
> > > + net_dump_receive(nc, data, size);
> > > + } else if (sender->netdev_dump_enabled) {
> > > + net_dump_receive(sender, data, size);
> > > + }
> ...
> > Perhaps dumping should happen after ->receive() has returned size. If
> > ->receive() returns -1 the packet is discarded, and if it returns 0 the
> > packet is queued (not delivered yet).
> >
> > If you dump unconditionally before ->receive() you will see queued
> > packets dumped multiple times (each time the queue gets flushed).
>
> I've now tried this, but then I suddenly get the packets in the wrong
> order in the dump file (when using slirp networking), e.g.:
>
> 1 0.000000 10.0.2.2 -> 255.255.255.255 DHCP 590 DHCP Offer
> 2 0.000012 0.0.0.0 -> 255.255.255.255 DHCP 342 DHCP Discover
>
> instead of:
>
> 1 0.000000 0.0.0.0 -> 255.255.255.255 DHCP 342 DHCP Discover
> 2 0.000035 10.0.2.2 -> 255.255.255.255 DHCP 590 DHCP Offer
>
> Looks like with slirp, the answer is already sent before the initial
> receive() function returns?
>
> Any idea how to avoid that issue? If not, I think I'll simply keep the
> dump hooks before calling the receive functions.
I see. So either way the packet capture will be misleading.
Please leave add a comment to the code mentioning that either queued
packets are duplicated or slirp traffic is out-of-order. That way we
won't forget why the code is the way it is.
Stefan
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2015-07-01 8:37 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-24 15:56 [Qemu-devel] [PATCH 0/5] Network traffic dumping for -netdev, second try Thomas Huth
2015-06-24 15:56 ` [Qemu-devel] [PATCH 1/5] net/dump: Add support for receive_iov function Thomas Huth
2015-06-26 6:38 ` Jason Wang
2015-06-26 7:06 ` Thomas Huth
2015-07-03 11:06 ` Markus Armbruster
2015-07-10 18:09 ` Thomas Huth
2015-06-24 15:56 ` [Qemu-devel] [PATCH 2/5] net/dump: Move DumpState into NetClientState Thomas Huth
2015-06-24 15:56 ` [Qemu-devel] [PATCH 3/5] net/dump: Rework net-dump init functions Thomas Huth
2015-07-03 11:19 ` Markus Armbruster
2015-06-24 15:56 ` [Qemu-devel] [PATCH 4/5] net/dump: Add dump option for netdev devices Thomas Huth
2015-06-26 6:50 ` Jason Wang
2015-06-26 9:44 ` Stefan Hajnoczi
2015-06-29 9:57 ` Thomas Huth
2015-06-30 15:12 ` Stefan Hajnoczi
2015-06-30 10:37 ` Thomas Huth
2015-07-01 8:36 ` Stefan Hajnoczi [this message]
2015-07-03 11:28 ` Markus Armbruster
2015-07-10 18:27 ` Thomas Huth
2015-06-24 15:56 ` [Qemu-devel] [PATCH 5/5] qemu options: Add information about dumpfile to help text Thomas Huth
2015-07-03 11:30 ` Markus Armbruster
2015-06-26 9:41 ` [Qemu-devel] [PATCH 0/5] Network traffic dumping for -netdev, second try Stefan Hajnoczi
2015-07-03 11:30 ` Markus Armbruster
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=20150701083653.GA13991@stefanha-thinkpad.redhat.com \
--to=stefanha@redhat.com \
--cc=armbru@redhat.com \
--cc=jasowang@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
--cc=thuth@redhat.com \
/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.
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 NNTP newsgroup(s).