From 3774237baadb1647f91b3c24a99b9d3cd4904159 Mon Sep 17 00:00:00 2001
Message-Id: <3774237baadb1647f91b3c24a99b9d3cd4904159.1361183855.git.minovotn@redhat.com>
In-Reply-To: <8a5181c3fa0b1efb69153485808afcb612d0aa60.1361183855.git.minovotn@redhat.com>
References: <8a5181c3fa0b1efb69153485808afcb612d0aa60.1361183855.git.minovotn@redhat.com>
From: Vlad Yasevich <vyasevic@redhat.com>
Date: Thu, 14 Feb 2013 22:48:26 +0100
Subject: [PATCH 5/5] e1000: Discard oversized packets based on SBP|LPE

RH-Author: Vlad Yasevich <vyasevic@redhat.com>
Message-id: <1360882106-11660-3-git-send-email-vyasevic@redhat.com>
Patchwork-id: 48530
O-Subject: [RHEL-6.5 kvm PATCH 2/2] e1000: Discard oversized packets based on SBP|LPE
Bugzilla: 910842
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Amos Kong <akong@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Petr Matousek <pmatouse@redhat.com>

From: Michael Contreras <michael@inetric.com>

Discard packets longer than 16384 when !SBP to match the hardware behavior.

Signed-off-by: Michael Contreras <michael@inetric.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>

(cherry-picked from 2c0331f4f7d241995452b99afaf0aab00493334a)

Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
---
 hw/e1000.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 hw/e1000.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/hw/e1000.c b/hw/e1000.c
index e9ed1aa..f1665a4 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -57,6 +57,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:
@@ -778,8 +780,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;
     }
-- 
1.7.11.7

