Skip to contentSkip to conversation

e1000: Discard oversized packets based on SBP|LPE

PATCH Amos Kong 1 participant 2 messages Nov 27, 2013 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Amos Kong

author
#1 lore raw
Quoted 27 lines · Michael Tokarev

From: Michael Contreras <[email protected]>

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

(cherry picked from commit 2c0331f4f7d241995452b99afaf0aab00493334a)
---
 hw/e1000.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
hw/e1000.c +2 -0
index e22ba3d..87c798b 100644
@@ -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:

hw/e1000.c e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size) · line 808

Quoted 10 lines
hw/e1000.c +3 -2
@@ -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;

This change is correct. I have a related question to ask.

I enabled E1000_DEBUG in qemu, and try to change nic MTU to >1500 in Windows 7/ Windows 8 guest. I found RCTL register isn't changed.

It mean E1000_RCTL_LPE bit is 0, so I ping guest from host with > 1500 size packet, the request ICMP packets will be dropped.

It seems a e1000 driver bug of Windows?

Thanks, Amos

Quoted 3 lines
hw/e1000.c +0 -0
     }
Signature · 1 line
1.7.10.4
author
#2 lore raw
Quoted 42 lines · Amos Kong
Quoted 27 lines · Michael Tokarev

From: Michael Contreras <[email protected]>

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

(cherry picked from commit 2c0331f4f7d241995452b99afaf0aab00493334a)
---
 hw/e1000.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
hw/e1000.c +2 -0
index e22ba3d..87c798b 100644
@@ -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:

hw/e1000.c e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size) · line 808

Quoted 10 lines
hw/e1000.c +3 -2
@@ -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;

This change is correct. I have a related question to ask.

Quoted 7 lines

I enabled E1000_DEBUG in qemu, and try to change nic MTU to >1500 in Windows 7/ Windows 8 guest. I found RCTL register isn't changed.

It mean E1000_RCTL_LPE bit is 0, so I ping guest from host with > 1500 size packet, the request ICMP packets will be dropped.

It seems a e1000 driver bug of Windows?

In e1000 driver of Windows, there is a "Jumbo Packet" option, it's used to enable LPE, after enabled Jumbo packet, I can ping guest with large packet (>1500)