Skip to content
Snippets Groups Projects
Commit e1a0ffb9 authored by Michael Contreras's avatar Michael Contreras Committed by Michael Roth
Browse files

e1000: Discard packets that are too long if !SBP and !LPE


The e1000_receive function for the e1000 needs to discard packets longer than
1522 bytes if the SBP and LPE flags are disabled. The linux driver assumes
this behavior and allocates memory based on this assumption.

Signed-off-by: default avatarMichael Contreras <michael@inetric.com>
Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit b0d9ffcd)

Signed-off-by: default avatarMichael Roth <mdroth@linux.vnet.ibm.com>
parent 178ef3a4
No related branches found
No related tags found
No related merge requests found
...@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL); ...@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
#define PNPMMIO_SIZE 0x20000 #define PNPMMIO_SIZE 0x20000
#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */ #define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */
/* this is the size past which hardware will drop packets when setting LPE=0 */
#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
/* /*
* HW models: * HW models:
* E1000_DEV_ID_82540EM works with Windows and Linux * E1000_DEV_ID_82540EM works with Windows and Linux
...@@ -795,6 +798,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size) ...@@ -795,6 +798,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
size = sizeof(min_buf); size = sizeof(min_buf);
} }
/* Discard oversized packets if !LPE and !SBP. */
if (size > MAXIMUM_ETHERNET_VLAN_SIZE
&& !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
&& !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
return size;
}
if (!receive_filter(s, buf, size)) if (!receive_filter(s, buf, size))
return size; return size;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment