diff options
author | Arnd Bergmann <arnd@arndb.de> | 2010-02-18 00:46:50 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-02-18 17:08:38 -0500 |
commit | 501c774cb13c3ef8fb7fc5f08fa19473f7d9a0db (patch) | |
tree | 65db25ce76a5c038d69c304d9b6456e4f68e9f47 /drivers/vhost/net.c | |
parent | 02df55d28c6001a3cdb7a997a34a0b01f01d015e (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/net.c')
-rw-r--r-- | drivers/vhost/net.c | 8 |
1 files changed, 6 insertions, 2 deletions
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 | ||
455 | static struct socket *get_tun_socket(int fd) | 456 | static 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); |