From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Vlad Yasevich <vyasevic@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Anthony Liguori <aliguori@amazon.com>
Subject: [Qemu-devel] [PULL 4/4] net: Update netdev peer on link change
Date: Mon, 9 Dec 2013 14:11:32 +0100 [thread overview]
Message-ID: <1386594692-21278-5-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1386594692-21278-1-git-send-email-stefanha@redhat.com>
From: Vlad Yasevich <vyasevic@redhat.com>
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 <vyasevic@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
net/net.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/net/net.c b/net/net.c
index ae8e5e5..9db88cc 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1071,15 +1071,23 @@ void qmp_set_link(const char *name, bool up, Error **errp)
nc->info->link_status_changed(nc);
}
- /* 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 (nc->peer && nc->peer->info->link_status_changed) {
- nc->peer->info->link_status_changed(nc->peer);
+ if (nc->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 (nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
+ for (i = 0; i < queues; i++) {
+ ncs[i]->peer->link_down = !up;
+ }
+ }
+ if (nc->peer->info->link_status_changed) {
+ nc->peer->info->link_status_changed(nc->peer);
+ }
}
}
--
1.8.4.2
prev parent reply other threads:[~2013-12-09 13:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-09 13:11 [Qemu-devel] [PULL 0/4] Net patches Stefan Hajnoczi
2013-12-09 13:11 ` [Qemu-devel] [PULL 1/4] net: Adding netmap network backend Stefan Hajnoczi
2013-12-10 17:49 ` Eric Blake
2013-12-11 8:39 ` Stefan Hajnoczi
2013-12-11 9:04 ` Vincenzo Maffione
2013-12-11 9:18 ` Stefan Hajnoczi
2013-12-09 13:11 ` [Qemu-devel] [PULL 2/4] MAINTAINERS: Add netmap maintainers Stefan Hajnoczi
2013-12-09 13:11 ` [Qemu-devel] [PULL 3/4] virtio-net: don't update mac_table in error state Stefan Hajnoczi
2013-12-09 13:11 ` Stefan Hajnoczi [this message]
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=1386594692-21278-5-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=aliguori@amazon.com \
--cc=qemu-devel@nongnu.org \
--cc=vyasevic@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).