From 58952137b0b3e1c9e3ce718ed952c1baf8832652 Mon Sep 17 00:00:00 2001 From: Vincenzo Maffione Date: Wed, 6 Nov 2013 11:44:06 +0100 Subject: net: Adding netmap network backend This patch adds support for a network backend based on netmap. netmap is a framework for high speed packet I/O. You can use it to build extremely fast traffic generators, monitors, software switches or network middleboxes. Its companion software switch VALE lets you interconnect virtual machines. netmap and VALE are implemented as a non-intrusive kernel module, support NICs from multiple vendors, are part of standard FreeBSD distributions and available in source format for Linux too. To compile QEMU with netmap support, use the following configure options: ./configure [...] --enable-netmap --extra-cflags=-I/path/to/netmap/sys where "/path/to/netmap" contains the netmap source code, available at http://info.iet.unipi.it/~luigi/netmap/ The same webpage contains more information about the netmap project (together with papers and presentations). Signed-off-by: Vincenzo Maffione Signed-off-by: Stefan Hajnoczi --- net/net.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'net/net.c') diff --git a/net/net.c b/net/net.c index 0a88e68253..ae8e5e5c35 100644 --- a/net/net.c +++ b/net/net.c @@ -725,6 +725,9 @@ static int (* const net_client_init_fun[NET_CLIENT_OPTIONS_KIND_MAX])( [NET_CLIENT_OPTIONS_KIND_SOCKET] = net_init_socket, #ifdef CONFIG_VDE [NET_CLIENT_OPTIONS_KIND_VDE] = net_init_vde, +#endif +#ifdef CONFIG_NETMAP + [NET_CLIENT_OPTIONS_KIND_NETMAP] = net_init_netmap, #endif [NET_CLIENT_OPTIONS_KIND_DUMP] = net_init_dump, #ifdef CONFIG_NET_BRIDGE @@ -757,6 +760,9 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp) #ifdef CONFIG_VDE case NET_CLIENT_OPTIONS_KIND_VDE: #endif +#ifdef CONFIG_NETMAP + case NET_CLIENT_OPTIONS_KIND_NETMAP: +#endif #ifdef CONFIG_NET_BRIDGE case NET_CLIENT_OPTIONS_KIND_BRIDGE: #endif -- cgit 1.4.1 From 02d38fcb2caa4454cf4ed728d5908c3cc9ba47be Mon Sep 17 00:00:00 2001 From: Vlad Yasevich Date: Thu, 21 Nov 2013 21:05:51 -0500 Subject: net: Update netdev peer on link change 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 --- net/net.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'net/net.c') diff --git a/net/net.c b/net/net.c index ae8e5e5c35..9db88cc0ee 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); + } } } -- cgit 1.4.1