From patchwork Sat Sep 18 20:43:45 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 65137 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 19D32B70CE for ; Sun, 19 Sep 2010 06:45:06 +1000 (EST) Received: from localhost ([127.0.0.1]:37110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ox4HP-0000ln-4M for incoming@patchwork.ozlabs.org; Sat, 18 Sep 2010 16:45:03 -0400 Received: from [140.186.70.92] (port=42917 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ox4Gl-0000Y8-VT for qemu-devel@nongnu.org; Sat, 18 Sep 2010 16:44:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ox4GH-0003YB-1E for qemu-devel@nongnu.org; Sat, 18 Sep 2010 16:43:54 -0400 Received: from mtagate7.de.ibm.com ([195.212.17.167]:47394) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ox4GG-0003XU-Q0 for qemu-devel@nongnu.org; Sat, 18 Sep 2010 16:43:53 -0400 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate7.de.ibm.com (8.13.1/8.13.1) with ESMTP id o8IKhmZX027048 for ; Sat, 18 Sep 2010 20:43:48 GMT Received: from d12av03.megacenter.de.ibm.com (d12av03.megacenter.de.ibm.com [9.149.165.213]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o8IKhmaD2478086 for ; Sat, 18 Sep 2010 22:43:48 +0200 Received: from d12av03.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av03.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o8IKhlnV032113 for ; Sat, 18 Sep 2010 22:43:48 +0200 Received: from stefan-thinkpad.ibm.com (sig-9-145-178-254.de.ibm.com [9.145.178.254]) by d12av03.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id o8IKhlG8032108; Sat, 18 Sep 2010 22:43:47 +0200 From: Stefan Hajnoczi To: Date: Sat, 18 Sep 2010 21:43:45 +0100 Message-Id: <1284842625-13920-1-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: 638955@bugs.launchpad.net, Stefan Hajnoczi , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH] e1000: Pad short frames to minimum size (60 bytes) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The OpenIndiana (Solaris) e1000g driver drops frames that are too long or too short. It expects to receive frames of at least the Ethernet minimum size. ARP requests in particular are small and will be dropped if they are not padded appropriately, preventing a Solaris VM from becoming visible on the network. Signed-off-by: Stefan Hajnoczi --- hw/e1000.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/hw/e1000.c b/hw/e1000.c index 7d7d140..bc983f9 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -55,6 +55,7 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL); #define IOPORT_SIZE 0x40 #define PNPMMIO_SIZE 0x20000 +#define MIN_BUF_SIZE 60 /* * HW models: @@ -635,10 +636,19 @@ e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size) uint32_t rdh_start; uint16_t vlan_special = 0; uint8_t vlan_status = 0, vlan_offset = 0; + uint8_t min_buf[MIN_BUF_SIZE]; if (!(s->mac_reg[RCTL] & E1000_RCTL_EN)) return -1; + /* Pad to minimum Ethernet frame length */ + if (size < sizeof(min_buf)) { + memcpy(min_buf, buf, size); + memset(&min_buf[size], 0, sizeof(min_buf) - size); + buf = min_buf; + size = sizeof(min_buf); + } + if (size > s->rxbuf_size) { DBGOUT(RX, "packet too large for buffers (%lu > %d)\n", (unsigned long)size, s->rxbuf_size);