From: Jason Wang <jasowang@redhat.com>
To: peter.maydell@linaro.org, qemu-devel@nongnu.org
Cc: Yuri Benditovich <yuri.benditovich@daynix.com>,
Jason Wang <jasowang@redhat.com>
Subject: [PULL 3/5] net: purge queued rx packets on queue deletion
Date: Tue, 24 Nov 2020 10:44:21 +0800 [thread overview]
Message-ID: <1606185863-25996-4-git-send-email-jasowang@redhat.com> (raw)
In-Reply-To: <1606185863-25996-1-git-send-email-jasowang@redhat.com>
From: Yuri Benditovich <yuri.benditovich@daynix.com>
https://bugzilla.redhat.com/show_bug.cgi?id=1829272
When deleting queue pair, purge pending RX packets if any.
Example of problematic flow:
1. Bring up q35 VM with tap (vhost off) and virtio-net or e1000e
2. Run ping flood to the VM NIC ( 1 ms interval)
3. Hot unplug the NIC device (device_del)
During unplug process one or more packets come, the NIC
can't receive, tap disables read_poll
4. Hot plug the device (device_add) with the same netdev
The tap stays with read_poll disabled and does not receive
any packets anymore (tap_send never triggered)
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
net/net.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/net/net.c b/net/net.c
index 6362d30..6a2c3d9 100644
--- a/net/net.c
+++ b/net/net.c
@@ -412,10 +412,14 @@ void qemu_del_nic(NICState *nic)
qemu_macaddr_set_free(&nic->conf->macaddr);
- /* If this is a peer NIC and peer has already been deleted, free it now. */
- if (nic->peer_deleted) {
- for (i = 0; i < queues; i++) {
- qemu_free_net_client(qemu_get_subqueue(nic, i)->peer);
+ for (i = 0; i < queues; i++) {
+ NetClientState *nc = qemu_get_subqueue(nic, i);
+ /* If this is a peer NIC and peer has already been deleted, free it now. */
+ if (nic->peer_deleted) {
+ qemu_free_net_client(nc->peer);
+ } else if (nc->peer) {
+ /* if there are RX packets pending, complete them */
+ qemu_purge_queued_packets(nc->peer);
}
}
--
2.7.4
next prev parent reply other threads:[~2020-11-24 2:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-24 2:44 [PULL 0/5] Net patches Jason Wang
2020-11-24 2:44 ` [PULL 1/5] hw/net/e1000e: advance desc_offset in case of null descriptor Jason Wang
2020-11-24 2:44 ` [PULL 2/5] net: do not exit on "netdev_add help" monitor command Jason Wang
2020-11-24 2:44 ` Jason Wang [this message]
2020-11-24 2:44 ` [PULL 4/5] tap: fix a memory leak Jason Wang
2020-11-24 2:44 ` [PULL 5/5] net: Use correct default-path macro for downscript Jason Wang
2020-11-24 13:33 ` [PULL 0/5] Net patches Peter Maydell
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=1606185863-25996-4-git-send-email-jasowang@redhat.com \
--to=jasowang@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=yuri.benditovich@daynix.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.