From 8d53e9f3c6001dcb2865f6e894da5b54e1418f88 Mon Sep 17 00:00:00 2001 From: Christian Ehrhardt Date: Thu, 4 Jul 2019 10:40:06 +0200 Subject: New upstream version 18.11.2 Change-Id: I23eb4f9179abf1f9c659891f8fddb27ee68ad26b Signed-off-by: Christian Ehrhardt --- drivers/net/virtio/virtio_user/vhost.h | 4 ++-- drivers/net/virtio/virtio_user/vhost_kernel_tap.c | 12 ++++++++++-- drivers/net/virtio/virtio_user/vhost_user.c | 5 ++++- drivers/net/virtio/virtio_user/virtio_user_dev.c | 3 ++- drivers/net/virtio/virtio_user/virtio_user_dev.h | 2 +- 5 files changed, 19 insertions(+), 7 deletions(-) (limited to 'drivers/net/virtio/virtio_user') diff --git a/drivers/net/virtio/virtio_user/vhost.h b/drivers/net/virtio/virtio_user/vhost.h index 83a85cc6..55f47036 100644 --- a/drivers/net/virtio/virtio_user/vhost.h +++ b/drivers/net/virtio/virtio_user/vhost.h @@ -2,8 +2,8 @@ * Copyright(c) 2010-2016 Intel Corporation */ -#ifndef _VHOST_NET_USER_H -#define _VHOST_NET_USER_H +#ifndef _VIRTIO_USER_VHOST_H +#define _VIRTIO_USER_VHOST_H #include #include diff --git a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c index a3faf1d0..fbd9e979 100644 --- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c +++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c @@ -62,6 +62,7 @@ vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq, const char *mac, uint64_t features) { unsigned int tap_features; + char *tap_name = NULL; int sndbuf = INT_MAX; struct ifreq ifr; int tapfd; @@ -112,6 +113,12 @@ vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq, goto error; } + tap_name = strdup(ifr.ifr_name); + if (!tap_name) { + PMD_DRV_LOG(ERR, "strdup ifname failed: %s", strerror(errno)); + goto error; + } + fcntl(tapfd, F_SETFL, O_NONBLOCK); if (ioctl(tapfd, TUNSETVNETHDRSZ, &hdr_size) < 0) { @@ -134,11 +141,12 @@ vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq, goto error; } - if (!(*p_ifname)) - *p_ifname = strdup(ifr.ifr_name); + free(*p_ifname); + *p_ifname = tap_name; return tapfd; error: + free(tap_name); close(tapfd); return -1; } diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c index 2c6eba0a..0a88d595 100644 --- a/drivers/net/virtio/virtio_user/vhost_user.c +++ b/drivers/net/virtio/virtio_user/vhost_user.c @@ -393,7 +393,10 @@ virtio_user_start_server(struct virtio_user_dev *dev, struct sockaddr_un *un) return -1; flag = fcntl(fd, F_GETFL); - fcntl(fd, F_SETFL, flag | O_NONBLOCK); + if (fcntl(fd, F_SETFL, flag | O_NONBLOCK) < 0) { + PMD_DRV_LOG(ERR, "fcntl failed, %s", strerror(errno)); + return -1; + } return 0; } diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index 9c8bcd2c..f0051f88 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -412,7 +412,7 @@ virtio_user_dev_setup(struct virtio_user_dev *dev) int virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues, int cq, int queue_size, const char *mac, char **ifname, - int mrg_rxbuf, int in_order) + int server, int mrg_rxbuf, int in_order) { pthread_mutex_init(&dev->mutex, NULL); snprintf(dev->path, PATH_MAX, "%s", path); @@ -420,6 +420,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues, dev->max_queue_pairs = queues; dev->queue_pairs = 1; /* mq disabled by default */ dev->queue_size = queue_size; + dev->is_server = server; dev->mac_specified = 0; dev->frontend_features = 0; dev->unsupported_features = ~VIRTIO_USER_SUPPORTED_FEATURES; diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h index c42ce5d4..3e3a7b78 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.h +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h @@ -50,7 +50,7 @@ int virtio_user_start_device(struct virtio_user_dev *dev); int virtio_user_stop_device(struct virtio_user_dev *dev); int virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues, int cq, int queue_size, const char *mac, char **ifname, - int mrg_rxbuf, int in_order); + int server, int mrg_rxbuf, int in_order); void virtio_user_dev_uninit(struct virtio_user_dev *dev); void virtio_user_handle_cq(struct virtio_user_dev *dev, uint16_t queue_idx); uint8_t virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t q_pairs); -- cgit 1.2.3-korg