aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2019-11-08 13:52:28 +0100
committerFlorin Coras <florin.coras@gmail.com>2019-11-08 18:11:24 +0000
commit39807d02c9a26d99f96a9669c49ba017bedfe510 (patch)
tree7593d8ee325d4b33873e6dce2b3807d0d924909c /src
parent0ba86cb1bdcc273ebc3d5a92f765639a64894a7a (diff)
tap: add check for vhost-net backend
Type: feature Change-Id: I402f4c88dee70fbb0b3b61dc4e0a4034d24d8b56 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vnet/devices/tap/tap.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/vnet/devices/tap/tap.c b/src/vnet/devices/tap/tap.c
index bc790adae75..a1d5981086c 100644
--- a/src/vnet/devices/tap/tap.c
+++ b/src/vnet/devices/tap/tap.c
@@ -94,6 +94,7 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args)
struct vhost_memory *vhost_mem = 0;
virtio_if_t *vif = 0;
clib_error_t *err = 0;
+ unsigned int tap_features;
int fd = -1;
char *host_if_name = 0;
@@ -173,6 +174,14 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args)
goto error;
}
+ _IOCTL (vif->tap_fd, TUNGETFEATURES, &tap_features);
+ if ((tap_features & IFF_VNET_HDR) == 0)
+ {
+ args->rv = VNET_API_ERROR_SYSCALL_ERROR_2;
+ args->error = clib_error_return (0, "vhost-net backend not available");
+ goto error;
+ }
+
ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_ONE_QUEUE | IFF_VNET_HDR;
_IOCTL (vif->tap_fd, TUNSETIFF, (void *) &ifr);
vif->ifindex = if_nametoindex (ifr.ifr_ifrn.ifrn_name);