From 50a360699cbbe69a3b8c04c3383e8c82a7885dbf Mon Sep 17 00:00:00 2001 From: Vlad Yasevich Date: Tue, 1 Apr 2014 15:43:43 +0200 Subject: [PATCH 23/30] net: Update netdev peer on link change RH-Author: Vlad Yasevich Message-id: <1396367023-2433-1-git-send-email-vyasevic@redhat.com> Patchwork-id: 58322 O-Subject: [RHEL6.6 qemu-kvm PATCH] net: Update netdev peer on link change Bugzilla: 965396 RH-Acked-by: Xiao Wang RH-Acked-by: Amos Kong RH-Acked-by: Stefan Hajnoczi BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1000375 Brew: https://brewweb.devel.redhat.com/taskinfo?taskID=7284587 Upstream: 02d38fcb2caa4454cf4ed728d5908c3cc9ba47be When a link change occurs on a backend (like tap), we currently do not propage such change to the nic. As a result, when someone turns off a link on a tap device, for instance, then a guest doesn't see that change and continues to try to send traffic or run DHCP even though the lower-layer is disconnected. This is OK when the network is set up as a HUB since the the guest may be connected to other HUB ports too, but when it's set up as a netdev, it makes thinkgs worse. The patch addresses this by setting the peers link down only when the peer is not a HUBPORT device. With this patch, in the following config -netdev tap,id=net0 -device e1000,mac=XXXXX,netdev=net0 when net0 link is turned off, the guest e1000 shows lower-layer link down. This allows guests to boot much faster in such configurations. With windows guest, it also allows the network to recover properly since windows will not configure the link-local IPv4 address, and when the link is turned on, the proper address address is configured. Signed-off-by: Vlad Yasevich Signed-off-by: Stefan Hajnoczi Conflicts: net.c [context and different file] Signed-off-by: Vlad Yasevich --- net.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) Signed-off-by: Miroslav Rezanina --- net.c | 24 +++++++++++++++--------- 1 files changed, 15 insertions(+), 9 deletions(-) diff --git a/net.c b/net.c index 4fe974a..4ca648a 100644 --- a/net.c +++ b/net.c @@ -1335,15 +1335,21 @@ done: 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); + if (vc->peer) { + /* Change peer link only if the peer is NIC and then notify peer. + * If the peer is a HUBPORT or a backend, we do not change the + * link status. + * + * This behavior 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->info->type == NET_CLIENT_TYPE_NIC) { + vc->peer->link_down = !up; + } + if (vc->peer->info->link_status_changed) { + vc->peer->info->link_status_changed(vc->peer); + } } return 0; } -- 1.7.1