From: Vladislav Yasevich <vyasevic@redhat.com>
To: qemu-devel@nongnu.org
Cc: Vladislav Yasevich <vyasevic@redhat.com>,
jasowang@redhat.com, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH v3 0/2] rtl8139: Fix buffer overflow in standard mode
Date: Fri, 28 Aug 2015 10:06:55 -0400 [thread overview]
Message-ID: <1440770817-20555-1-git-send-email-vyasevic@redhat.com> (raw)
When rtl8139 card is running in standard mode, it is very easy
to overlflow and the receive buffer and get into a siutation
where all packets are dropped. Simply reproduction case is
to ping the guest from the host with 6500 byte packets.
There are actually 2 problems here.
1) When the rtl8129 buffer is overflow, the card emulation
returns the size of the packet back to queue transmission.
This signals successful reception even though the packet
has been dropped. The proper solution is to return 0, so
that the packet is re-queued and will be resubmitted later.
2) When packets are sized such that the fragments end up completely
filling the receive buffer without overflow, the device thinks
that the buffer is actually empty (instead of full). This causes
next packet to over-write the existing packets. With the above
ping reproducer, ever ICMP packet fills the buffer and thus keeps
overwriting the previous packet and never waking up the guest.
The solution here is track the number of unread bytes separately
so we would know if we have anything in buffer to read or not.
V3: Fix the second patch to correctly track unread and available buffer
speace. Prior version used calculation for availble space to track
unread space which was wrong.
V2: instead of tracking buffer_full condition, changed the code, as
suggested by Stefan Hajnoczi, to track the number of unread bytes
instead. We initialize it to 0 at the start, adjust it on every
receive from the network and read from the guest and can set
the number of unread of bytes to full buffer size when the buffer
full.
Vladislav Yasevich (2):
rtl8139: Do not consume the packet during overflow in standard mode.
rtl8139: correctly track full receive buffer in standard mode
hw/net/rtl8139.c | 47 ++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 42 insertions(+), 5 deletions(-)
--
1.9.3
next reply other threads:[~2015-08-28 14:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-28 14:06 Vladislav Yasevich [this message]
2015-08-28 14:06 ` [Qemu-devel] [PATCH v3 1/2] rtl8139: Do not consume the packet during overflow in standard mode Vladislav Yasevich
2015-08-28 14:06 ` [Qemu-devel] [PATCH v3 2/2] rtl8139: correctly track full receive buffer " Vladislav Yasevich
2015-08-31 9:59 ` Jason Wang
2015-08-31 14:24 ` Vlad Yasevich
2015-09-01 3:15 ` Jason Wang
2015-09-01 11:29 ` Vlad Yasevich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1440770817-20555-1-git-send-email-vyasevic@redhat.com \
--to=vyasevic@redhat.com \
--cc=jasowang@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).