From patchwork Mon Feb 4 10:40:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 217965 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BB80C2C02B3 for ; Tue, 5 Feb 2013 02:18:34 +1100 (EST) Received: from localhost ([::1]:43319 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U2Jam-00032A-2R for incoming@patchwork.ozlabs.org; Mon, 04 Feb 2013 05:48:04 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52047) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U2JaE-0001ue-3h for qemu-devel@nongnu.org; Mon, 04 Feb 2013 05:47:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U2Ja9-0002U5-Eo for qemu-devel@nongnu.org; Mon, 04 Feb 2013 05:47:30 -0500 Received: from isrv.corpit.ru ([86.62.121.231]:56150) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U2Ja9-0002Tm-5Z; Mon, 04 Feb 2013 05:47:25 -0500 Received: from gandalf.tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by isrv.corpit.ru (Postfix) with ESMTP id 5269BA03F5; Mon, 4 Feb 2013 14:47:24 +0400 (MSK) Received: by gandalf.tls.msk.ru (Postfix, from userid 1000) id 2F69A542; Mon, 4 Feb 2013 14:41:29 +0400 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Date: Mon, 4 Feb 2013 14:40:56 +0400 Message-Id: <1359974470-17044-47-git-send-email-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1359974470-17044-1-git-send-email-mjt@msgid.tls.msk.ru> References: <1359974470-17044-1-git-send-email-mjt@msgid.tls.msk.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 86.62.121.231 Cc: Michael Contreras , Michael Tokarev , qemu-stable@nongnu.org, Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 46/60] e1000: Discard oversized packets based on SBP|LPE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Michael Contreras Discard packets longer than 16384 when !SBP to match the hardware behavior. Signed-off-by: Michael Contreras Signed-off-by: Stefan Hajnoczi (cherry picked from commit 2c0331f4f7d241995452b99afaf0aab00493334a) Signed-off-by: Michael Tokarev --- hw/e1000.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/e1000.c b/hw/e1000.c index e22ba3d..87c798b 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -61,6 +61,8 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL); /* this is the size past which hardware will drop packets when setting LPE=0 */ #define MAXIMUM_ETHERNET_VLAN_SIZE 1522 +/* this is the size past which hardware will drop packets when setting LPE=1 */ +#define MAXIMUM_ETHERNET_LPE_SIZE 16384 /* * HW models: @@ -799,8 +801,9 @@ e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size) } /* Discard oversized packets if !LPE and !SBP. */ - if (size > MAXIMUM_ETHERNET_VLAN_SIZE - && !(s->mac_reg[RCTL] & E1000_RCTL_LPE) + if ((size > MAXIMUM_ETHERNET_LPE_SIZE || + (size > MAXIMUM_ETHERNET_VLAN_SIZE + && !(s->mac_reg[RCTL] & E1000_RCTL_LPE))) && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) { return size; }