Skip to content

Commit

Permalink
net: purge queued rx packets on queue deletion
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ybendito authored and jasowang committed Nov 24, 2020
1 parent ad6f932 commit d2abc56
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions net/net.c
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit d2abc56

Please sign in to comment.