summaryrefslogtreecommitdiff
path: root/drivers/net/virtio
diff options
context:
space:
mode:
authorTiwei Bie <tiwei.bie@intel.com>2019-03-12 15:13:07 +0800
committerFerruh Yigit <ferruh.yigit@intel.com>2019-03-20 18:15:42 +0100
commitbad78b4b8b23412f6007efd034de04b35c663a6f (patch)
tree367b40b85bc0eee51ae791443542b0c4b5a916a6 /drivers/net/virtio
parent11d5253a3e93a38be14da65328dd19960fd8cb14 (diff)
downloaddpdk-next-eventdev-bad78b4b8b23412f6007efd034de04b35c663a6f.zip
dpdk-next-eventdev-bad78b4b8b23412f6007efd034de04b35c663a6f.tar.gz
dpdk-next-eventdev-bad78b4b8b23412f6007efd034de04b35c663a6f.tar.xz
net/virtio-user: fix multiqueue with vhost kernel
The multiqueue support in virtio-user with vhost kernel backend is broken when tap name isn't specified by users explicitly, because the tap name returned by ioctl(TUNSETIFF) isn't saved properly, and multiple tap interfaces will be created in this case. Fix this by saving the dynamically allocated tap name first before reusing the ifr structure. Besides, also make it possible to support the format string in tap name (e.g. foo%d) specified by users explicitly. Fixes: 791b43e08842 ("net/virtio-user: specify MAC of the tap") Cc: stable@dpdk.org Reported-by: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com> Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Diffstat (limited to 'drivers/net/virtio')
-rw-r--r--drivers/net/virtio/virtio_user/vhost_kernel_tap.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
index a3faf1d..fbd9e97 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;
}