diff options
author | Michael Contreras <michael@inetric.com> | 2012-12-02 20:11:22 -0800 |
---|---|---|
committer | Doug Goldstein <cardoe@cardoe.com> | 2012-12-13 15:32:00 -0600 |
commit | 5853b4ffd6ae6057bd103174663e80c3fc96b440 (patch) | |
tree | d412324752689e2c2ece93ec17733cfcbc07aaef | |
parent | stream: fix ratelimit_set_speed (diff) | |
download | qemu-kvm-5853b4ffd6ae6057bd103174663e80c3fc96b440.tar.gz qemu-kvm-5853b4ffd6ae6057bd103174663e80c3fc96b440.tar.bz2 qemu-kvm-5853b4ffd6ae6057bd103174663e80c3fc96b440.zip |
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: Michael Contreras <michael@inetric.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit b0d9ffcd0251161c7c92f94804dcf599dfa3edeb)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
(cherry picked from commit e1a0ffb95728304f962ce36b27dcd3a16f04a05d)
-rw-r--r-- | hw/e1000.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/hw/e1000.c b/hw/e1000.c index 4d4ac3201..b1d850888 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL); #define PNPMMIO_SIZE 0x20000 #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: * E1000_DEV_ID_82540EM works with Windows and Linux @@ -795,6 +798,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size) 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)) return size; |