From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38806) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z8QC4-00076I-N7 for qemu-devel@nongnu.org; Fri, 26 Jun 2015 05:45:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z8QBy-0007MF-V1 for qemu-devel@nongnu.org; Fri, 26 Jun 2015 05:45:08 -0400 Received: from mail-wg0-x236.google.com ([2a00:1450:400c:c00::236]:35534) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z8QBy-0007LX-Pa for qemu-devel@nongnu.org; Fri, 26 Jun 2015 05:45:02 -0400 Received: by wgjx7 with SMTP id x7so10565210wgj.2 for ; Fri, 26 Jun 2015 02:45:02 -0700 (PDT) Date: Fri, 26 Jun 2015 10:44:59 +0100 From: Stefan Hajnoczi Message-ID: <20150626094459.GG15457@stefanha-thinkpad.redhat.com> References: <1435161381-31521-1-git-send-email-thuth@redhat.com> <1435161381-31521-5-git-send-email-thuth@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="L+ofChggJdETEG3Y" Content-Disposition: inline In-Reply-To: <1435161381-31521-5-git-send-email-thuth@redhat.com> Subject: Re: [Qemu-devel] [PATCH 4/5] net/dump: Add dump option for netdev devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Thomas Huth Cc: Jason Wang , qemu-devel@nongnu.org, Stefan Hajnoczi , Markus Armbruster --L+ofChggJdETEG3Y Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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; > } > =20 > + if (nc->netdev_dump_enabled) { > + net_dump_receive(nc, data, size); > + } else if (sender->netdev_dump_enabled) { > + net_dump_receive(sender, data, size); > + } Why "else if"? If two interfaces have packet capture enabled then both should get the full traffic log: if (nc->netdev_dump_enabled) { net_dump_receive(nc, data, size); } 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). --L+ofChggJdETEG3Y Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJVjR8bAAoJEJykq7OBq3PI8Z4H/jgRTvpjHBlBR1qzjbNxUK4F VsORMoI180Xi0WNo3ixarUnGXWm7YAR+ZN42P6hMgDEPbb/avYMUVyJ8vvdh5pxv +9gsIfWDgDFxRnWtmddQsnYAjsvUuBO8ToUdwii22kwwi3GFArrTzJCYLJw1RuJC xe3rcigFGpZ9tWYAYCHXDxJ/lQJ0Ey1oZomnk/IsZpUpsite5VNzjV6XGSQo9ROg a/e5+OKFl+5HAjXcKhZu5B/88+hNlVY5mFiJnhHYcBevI/ggY+JRYVj4j7b+ejdr 9sEnwL0XHzfEEaxEl3Vd+RzFEanm1PVODB0WRlFgOcUAt72LBC1Y6f/S+R/r5q8= =9Z7m -----END PGP SIGNATURE----- --L+ofChggJdETEG3Y--