vhost: fix tap link down
v3 cover vhost: fix tap link down
qemu makes it possible to disable link at tap which is not communicated to the guest but causes all packets to be dropped.
With vhost-net at the moment it just keeps going. Fix by communicating to virtio net and have that stop vhost-net.
Changes from v2:
comment tweaked
split to two patches
Changes from v1:
fix link down after guest link is up
Michael S. Tsirkin (2):
net: notify peer about link status change
vhost: disable on tap link down
hw/virtio-net.c | 3 ++- net.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletions(-)
Signature · 1 line
1.7.3.2.91.g446ac
PATCH v3 1/2 net: notify peer about link status change
qemu makes it possible to disable link at tap
which is not communicated to the guest but
causes all packets to be dropped.
This works for virtio userspace, as qemu
stops giving it packets, but not for
virtio-net connected to vhost-net
as that does not get notified about this change.
Notify peer when this happens, which will then be used by the follow-up patch to stop/start vhost-net.
Note: it might be a good idea to make peer link status match tap in this case, so the guest gets an event
and updates the carrier state. For now
stay bug for bug compatible with what we used to have in userspace.
--- net.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
net.c +11 -0
@@ -1324,6 +1324,17 @@ done:if (vc->info->link_status_changed) { vc->info->link_status_changed (vc); } + +/* Notify peer. Don't update peer link status: this makes it possible to +* disconnect from host network without notifying the guest. +* FIXME: is disconnected link status change operation useful? +* +* Current behaviour is compatible with qemu vlans where there could be +* multiple clients that can still communicate with each other in +* disconnected mode. For now maintain this compatibility. */ +if (vc->peer && vc->peer->info->link_status_changed) { + vc->peer->info->link_status_changed (vc->peer); + }return 0 ; }
Signature · 1 line
1.7.3.2.91.g446ac
PATCH v3 2/2 vhost: disable on tap link down
In reply to Michael S. Tsirkinqemu makes it possible to disable link at tap
which is not communicated to the guest but
causes all packets to be dropped.
When vhost-net is enabled, vhost needs to be aware of both the virtio link_down and the peer link_down. we switch to userspace emulation when either is down.
--- hw/virtio-net.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
hw/virtio-net.c +2 -1
@@ -115,7 +115,8 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)if (!tap_get_vhost_net (n->nic->nc.peer)) {return ; } -if (!!n->vhost_started ==virtio_net_started (n, status)) { +if (!!n->vhost_started ==virtio_net_started (n, status) && + !n->nic->nc.peer->link_down) {return ; }if (!n->vhost_started) {
Signature · 1 line
1.7.3.2.91.g446ac
Quoted 20 lines · Michael S. Tsirkin
qemu makes it possible to disable link at tap which is not communicated to the guest but causes all packets to be dropped.
With vhost-net at the moment it just keeps going. Fix by communicating to virtio net and have that stop vhost-net.
Signed-off-by Michael S. Tsirkin <[email protected]>Reported-by pradeep <[email protected]>Changes from v2:
comment tweaked
split to two patchesChanges from v1:
fix link down after guest link is up
Quoted 8 lines
Michael S. Tsirkin (2):
net: notify peer about link status change
vhost: disable on tap link downhw/virtio-net.c | 3 ++- net.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletions(-)
Thanks
v3 cover vhost: fix tap link down
In reply to Michael S. TsirkinQuoted 20 lines · Michael S. Tsirkin
qemu makes it possible to disable link at tap which is not communicated to the guest but causes all packets to be dropped.
With vhost-net at the moment it just keeps going. Fix by communicating to virtio net and have that stop vhost-net.
Signed-off-by Michael S. Tsirkin <[email protected]>Reported-by pradeep <[email protected]>Changes from v2:
comment tweaked
split to two patchesChanges from v1:
fix link down after guest link is up
Quoted 8 lines
Michael S. Tsirkin (2):
net: notify peer about link status change
vhost: disable on tap link downhw/virtio-net.c | 3 ++- net.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletions(-)
Quoted 3 lines
Signature · 1 line
1.7.3.2.91.g446ac
Quoted 20 lines · Michael S. Tsirkin
qemu makes it possible to disable link at tap which is not communicated to the guest but causes all packets to be dropped.
With vhost-net at the moment it just keeps going. Fix by communicating to virtio net and have that stop vhost-net.
Signed-off-by Michael S. Tsirkin <[email protected]>Reported-by pradeep <[email protected]>Changes from v2:
comment tweaked
split to two patchesChanges from v1:
fix link down after guest link is up
Quoted 8 lines
Michael S. Tsirkin (2):
net: notify peer about link status change
vhost: disable on tap link downhw/virtio-net.c | 3 ++- net.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletions(-)
Thanks, both applied.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net