aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/vhost
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2010-02-18 00:46:50 -0500
committerDavid S. Miller <davem@davemloft.net>2010-02-18 17:08:38 -0500
commit501c774cb13c3ef8fb7fc5f08fa19473f7d9a0db (patch)
tree65db25ce76a5c038d69c304d9b6456e4f68e9f47 /drivers/vhost
parent02df55d28c6001a3cdb7a997a34a0b01f01d015e (diff)
net/macvtap: add vhost support
This adds support for passing a macvtap file descriptor into vhost-net, much like we already do for tun/tap. Most of the new code is taken from the respective patch in the tun driver and may get consolidated in the future. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Sridhar Samudrala <sri@us.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/vhost')
-rw-r--r--drivers/vhost/Kconfig2
-rw-r--r--drivers/vhost/net.c8
2 files changed, 7 insertions, 3 deletions
diff --git a/drivers/vhost/Kconfig b/drivers/vhost/Kconfig
index 9e9355367bb3..e4e2fd1b5107 100644
--- a/drivers/vhost/Kconfig
+++ b/drivers/vhost/Kconfig
@@ -1,6 +1,6 @@
1config VHOST_NET 1config VHOST_NET
2 tristate "Host kernel accelerator for virtio net (EXPERIMENTAL)" 2 tristate "Host kernel accelerator for virtio net (EXPERIMENTAL)"
3 depends on NET && EVENTFD && (TUN || !TUN) && EXPERIMENTAL 3 depends on NET && EVENTFD && (TUN || !TUN) && (MACVTAP || !MACVTAP) && EXPERIMENTAL
4 ---help--- 4 ---help---
5 This kernel module can be loaded in host kernel to accelerate 5 This kernel module can be loaded in host kernel to accelerate
6 guest networking with virtio_net. Not to be confused with virtio_net 6 guest networking with virtio_net. Not to be confused with virtio_net
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 4c8928319e1d..91a324cc2298 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -22,6 +22,7 @@
22#include <linux/if_packet.h> 22#include <linux/if_packet.h>
23#include <linux/if_arp.h> 23#include <linux/if_arp.h>
24#include <linux/if_tun.h> 24#include <linux/if_tun.h>
25#include <linux/if_macvlan.h>
25 26
26#include <net/sock.h> 27#include <net/sock.h>
27 28
@@ -452,13 +453,16 @@ err:
452 return ERR_PTR(r); 453 return ERR_PTR(r);
453} 454}
454 455
455static struct socket *get_tun_socket(int fd) 456static struct socket *get_tap_socket(int fd)
456{ 457{
457 struct file *file = fget(fd); 458 struct file *file = fget(fd);
458 struct socket *sock; 459 struct socket *sock;
459 if (!file) 460 if (!file)
460 return ERR_PTR(-EBADF); 461 return ERR_PTR(-EBADF);
461 sock = tun_get_socket(file); 462 sock = tun_get_socket(file);
463 if (!IS_ERR(sock))
464 return sock;
465 sock = macvtap_get_socket(file);
462 if (IS_ERR(sock)) 466 if (IS_ERR(sock))
463 fput(file); 467 fput(file);
464 return sock; 468 return sock;
@@ -473,7 +477,7 @@ static struct socket *get_socket(int fd)
473 sock = get_raw_socket(fd); 477 sock = get_raw_socket(fd);
474 if (!IS_ERR(sock)) 478 if (!IS_ERR(sock))
475 return sock; 479 return sock;
476 sock = get_tun_socket(fd); 480 sock = get_tap_socket(fd);
477 if (!IS_ERR(sock)) 481 if (!IS_ERR(sock))
478 return sock; 482 return sock;
479 return ERR_PTR(-ENOTSOCK); 483 return ERR_PTR(-ENOTSOCK);