From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=42470 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oxn1j-0004Az-S3 for qemu-devel@nongnu.org; Mon, 20 Sep 2010 16:31:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oxn1g-0000QP-KH for qemu-devel@nongnu.org; Mon, 20 Sep 2010 16:31:49 -0400 Received: from mail-gx0-f173.google.com ([209.85.161.173]:39304) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oxn1g-0000Q8-Hi for qemu-devel@nongnu.org; Mon, 20 Sep 2010 16:31:48 -0400 Received: by gxk22 with SMTP id 22so1910159gxk.4 for ; Mon, 20 Sep 2010 13:31:47 -0700 (PDT) Message-ID: <4C97C4A4.1030801@codemonkey.ws> Date: Mon, 20 Sep 2010 15:31:32 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] e1000: Pad short frames to minimum size (60 bytes) References: <1284842625-13920-1-git-send-email-stefanha@linux.vnet.ibm.com> <20100918212710.GB3981@laped.lan> <20100920104259.GA23898@redhat.com> In-Reply-To: <20100920104259.GA23898@redhat.com> Content-Type: multipart/mixed; boundary="------------040403000008080300000409" List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org, Stefan Hajnoczi , 638955@bugs.launchpad.net, Stefan Hajnoczi , "Edgar E. Iglesias" This is a multi-part message in MIME format. --------------040403000008080300000409 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 09/20/2010 05:42 AM, Michael S. Tsirkin wrote: > On Sun, Sep 19, 2010 at 07:36:51AM +0100, Stefan Hajnoczi wrote: > >> On Sat, Sep 18, 2010 at 10:27 PM, Edgar E. Iglesias >> wrote: >> >>> This doesn't look right. AFAIK, MAC's dont pad on receive. >>> >> I agree. NICs that do padding will do it on transmit, not receive. >> Anything coming in on the wire should already have the minimum length. >> > QEMU never gets access to the wire. > Our APIs do not really pass complete ethernet packets: > we forward packets without checksum and padding. > > I think it makes complete sense to keep this and > handle padding in devices because we > have devices that pass the frame to guest without padding and checksum. > It should be easy to replace padding code in devices that > need it with some kind of macro. > Would this not also address the problem? It sounds like the root cause is the tap code, not the devices.. Regards, Anthony Liguori > >> In QEMU that isn't true today and that's why rtl8139, pcnet, and >> ne2000 already do this same padding. This patch is the smallest >> change to cover e1000. >> >> >>> IMO this kind of padding should somehow be done by the bridge that forwards >>> packets into the qemu vlan (e.g slirp or the generic tap bridge). >>> >> That should work and we can then drop the padding code from existing >> NICs. I'll take a look. >> >> Stefan >> > --------------040403000008080300000409 Content-Type: text/x-patch; name="0001-tap-make-sure-packets-are-at-least-40-bytes-long.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-tap-make-sure-packets-are-at-least-40-bytes-long.patch" >>From f77c3143f3fbefdfa2f0cc873c2665b5aa78e8c9 Mon Sep 17 00:00:00 2001 From: Anthony Liguori Date: Mon, 20 Sep 2010 15:29:31 -0500 Subject: [PATCH] tap: make sure packets are at least 40 bytes long This is required by ethernet drivers but not enforced in the Linux tap code so we need to fix it up ourselves. Signed-off-by: Anthony Liguori diff --git a/net/tap.c b/net/tap.c index 4afb314..822241a 100644 --- a/net/tap.c +++ b/net/tap.c @@ -179,7 +179,13 @@ static int tap_can_send(void *opaque) #ifndef __sun__ ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen) { - return read(tapfd, buf, maxlen); + ssize_t len; + + len = read(tapfd, buf, maxlen); + if (len > 0) { + len = MAX(MIN(maxlen, 40), len); + } + return len; } #endif -- 1.7.0.4 --------------040403000008080300000409--