get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2514/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2514,
    "url": "https://patches.dpdk.org/api/patches/2514/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1422242440-28948-15-git-send-email-huawei.xie@intel.com/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<1422242440-28948-15-git-send-email-huawei.xie@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1422242440-28948-15-git-send-email-huawei.xie@intel.com",
    "date": "2015-01-26T03:20:40",
    "name": "[dpdk-dev,RFC,v2,14/14] vhost user ifr_name support",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "7e8b0a1a473fffe234ccbbc63d5807f76bd22a40",
    "submitter": {
        "id": 16,
        "url": "https://patches.dpdk.org/api/people/16/?format=api",
        "name": "Huawei Xie",
        "email": "huawei.xie@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1422242440-28948-15-git-send-email-huawei.xie@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/2514/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/2514/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id CDA105A7F;\n\tMon, 26 Jan 2015 04:21:54 +0100 (CET)",
            "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n\tby dpdk.org (Postfix) with ESMTP id 54EA15ACD\n\tfor <dev@dpdk.org>; Mon, 26 Jan 2015 04:21:51 +0100 (CET)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby fmsmga101.fm.intel.com with ESMTP; 25 Jan 2015 19:21:49 -0800",
            "from shvmail01.sh.intel.com ([10.239.29.42])\n\tby fmsmga002.fm.intel.com with ESMTP; 25 Jan 2015 19:21:48 -0800",
            "from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com\n\t[10.239.29.90])\n\tby shvmail01.sh.intel.com with ESMTP id t0Q3Lj67015824;\n\tMon, 26 Jan 2015 11:21:45 +0800",
            "from shecgisg003.sh.intel.com (localhost [127.0.0.1])\n\tby shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP\n\tid t0Q3LhZq029081; Mon, 26 Jan 2015 11:21:45 +0800",
            "(from hxie5@localhost)\n\tby shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t0Q3Lh9h029077; \n\tMon, 26 Jan 2015 11:21:43 +0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.09,466,1418112000\"; d=\"scan'208\";a=\"667415838\"",
        "From": "Huawei Xie <huawei.xie@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Mon, 26 Jan 2015 11:20:40 +0800",
        "Message-Id": "<1422242440-28948-15-git-send-email-huawei.xie@intel.com>",
        "X-Mailer": "git-send-email 1.7.4.1",
        "In-Reply-To": "<1422242440-28948-1-git-send-email-huawei.xie@intel.com>",
        "References": "<1422242440-28948-1-git-send-email-huawei.xie@intel.com>",
        "Subject": "[dpdk-dev] [RFC PATCH v2 14/14] vhost user ifr_name support",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Signed-off-by: Huawei Xie <huawei.xie@intel.com>\n---\n lib/librte_vhost/Makefile                     |  2 +-\n lib/librte_vhost/rte_virtio_net.h             |  3 +-\n lib/librte_vhost/vhost-net.h                  |  3 +\n lib/librte_vhost/vhost_cuse/eventfd_copy.c    | 89 +++++++++++++++++++++++++++\n lib/librte_vhost/vhost_cuse/eventfd_copy.h    | 40 ++++++++++++\n lib/librte_vhost/vhost_cuse/vhost-net-cdev.c  | 51 ++-------------\n lib/librte_vhost/vhost_cuse/virtio-net-cdev.c | 53 ++++++++++++++++\n lib/librte_vhost/vhost_cuse/virtio-net-cdev.h |  3 +\n lib/librte_vhost/vhost_user/vhost-net-user.c  |  7 +++\n lib/librte_vhost/virtio-net.c                 | 63 ++++++-------------\n 10 files changed, 223 insertions(+), 91 deletions(-)\n create mode 100644 lib/librte_vhost/vhost_cuse/eventfd_copy.c\n create mode 100644 lib/librte_vhost/vhost_cuse/eventfd_copy.h",
    "diff": "diff --git a/lib/librte_vhost/Makefile b/lib/librte_vhost/Makefile\nindex b2f14a0..c9017d5 100644\n--- a/lib/librte_vhost/Makefile\n+++ b/lib/librte_vhost/Makefile\n@@ -37,7 +37,7 @@ LIB = librte_vhost.a\n CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -I vhost_cuse -I vhost_user -O3 -D_FILE_OFFSET_BITS=64 -lfuse\n LDFLAGS += -lfuse\n # all source are stored in SRCS-y\n-#SRCS-$(CONFIG_RTE_LIBRTE_VHOST) := vhost_cuse/vhost-net-cdev.c vhost_cuse/virtio-net-cdev.c virtio-net.c vhost_rxtx.c\n+#SRCS-$(CONFIG_RTE_LIBRTE_VHOST) := vhost_cuse/vhost-net-cdev.c vhost_cuse/virtio-net-cdev.c vhost_cuse/eventfd_copy.c virtio-net.c vhost_rxtx.c\n SRCS-$(CONFIG_RTE_LIBRTE_VHOST) := vhost_user/vhost-net-user.c vhost_user/virtio-net-user.c vhost_user/fd_man.c virtio-net.c vhost_rxtx.c\n \n # install includes\ndiff --git a/lib/librte_vhost/rte_virtio_net.h b/lib/librte_vhost/rte_virtio_net.h\nindex 46c2072..611a3d4 100644\n--- a/lib/librte_vhost/rte_virtio_net.h\n+++ b/lib/librte_vhost/rte_virtio_net.h\n@@ -100,7 +100,8 @@ struct virtio_net {\n \tuint64_t\t\tfeatures;\t/**< Negotiated feature set. */\n \tuint64_t\t\tdevice_fh;\t/**< device identifier. */\n \tuint32_t\t\tflags;\t\t/**< Device flags. Only used to check if device is running on data core. */\n-\tchar\t\t\tifname[IFNAMSIZ];\t/**< Name of the tap device. */\n+#define IF_NAME_SZ (PATH_MAX > IFNAMSIZ ? PATH_MAX : IFNAMSIZ)\n+\tchar\t\t\tifname[IF_NAME_SZ];\t/**< Name of the tap device or socket path. */\n \tvoid\t\t\t*priv;\t\t/**< private context */\n } __rte_cache_aligned;\n \ndiff --git a/lib/librte_vhost/vhost-net.h b/lib/librte_vhost/vhost-net.h\nindex 94b359f..d125a05 100644\n--- a/lib/librte_vhost/vhost-net.h\n+++ b/lib/librte_vhost/vhost-net.h\n@@ -93,6 +93,9 @@ struct vhost_net_device_ops {\n \tint (*new_device)(struct vhost_device_ctx);\n \tvoid (*destroy_device)(struct vhost_device_ctx);\n \n+\tvoid (*set_ifname)(struct vhost_device_ctx,\n+\t\tconst char *if_name, unsigned int if_len);\n+\n \tint (*get_features)(struct vhost_device_ctx, uint64_t *);\n \tint (*set_features)(struct vhost_device_ctx, uint64_t *);\n \ndiff --git a/lib/librte_vhost/vhost_cuse/eventfd_copy.c b/lib/librte_vhost/vhost_cuse/eventfd_copy.c\nnew file mode 100644\nindex 0000000..f2ed04e\n--- /dev/null\n+++ b/lib/librte_vhost/vhost_cuse/eventfd_copy.c\n@@ -0,0 +1,89 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n+ *   All rights reserved.\n+ *\n+ *   Redistribution and use in source and binary forms, with or without\n+ *   modification, are permitted provided that the following conditions\n+ *   are met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ *       notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above copyright\n+ *       notice, this list of conditions and the following disclaimer in\n+ *       the documentation and/or other materials provided with the\n+ *       distribution.\n+ *     * Neither the name of Intel Corporation nor the names of its\n+ *       contributors may be used to endorse or promote products derived\n+ *       from this software without specific prior written permission.\n+ *\n+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#include <unistd.h>\n+#include <sys/eventfd.h>\n+#include <sys/ioctl.h>\n+#include <sys/types.h>\n+#include <sys/stat.h>\n+#include <fcntl.h>\n+\n+#include <rte_log.h>\n+\n+#include \"eventfd_link/eventfd_link.h\"\n+#include \"eventfd_copy.h\"\n+#include \"vhost-net.h\"\n+\n+static const char eventfd_cdev[] = \"/dev/eventfd-link\";\n+\n+/*\n+ * This function uses the eventfd_link kernel module to copy an eventfd file\n+ * descriptor provided by QEMU in to our process space.\n+ */\n+int\n+eventfd_copy(int target_fd, int target_pid)\n+{\n+\tint eventfd_link, ret;\n+\tstruct eventfd_copy eventfd_copy;\n+\tint fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);\n+\n+\tif (fd == -1)\n+\t\treturn -1;\n+\n+\t/* Open the character device to the kernel module. */\n+\t/* TODO: check this earlier rather than fail until VM boots! */\n+\teventfd_link = open(eventfd_cdev, O_RDWR);\n+\tif (eventfd_link < 0) {\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"eventfd_link module is not loaded\\n\");\n+\t\tclose(fd);\n+\t\treturn -1;\n+\t}\n+\n+\teventfd_copy.source_fd = fd;\n+\teventfd_copy.target_fd = target_fd;\n+\teventfd_copy.target_pid = target_pid;\n+\t/* Call the IOCTL to copy the eventfd. */\n+\tret = ioctl(eventfd_link, EVENTFD_COPY, &eventfd_copy);\n+\tclose(eventfd_link);\n+\n+\tif (ret < 0) {\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"EVENTFD_COPY ioctl failed\\n\");\n+\t\tclose(fd);\n+\t\treturn -1;\n+\t}\n+\n+\treturn fd;\n+}\n+\ndiff --git a/lib/librte_vhost/vhost_cuse/eventfd_copy.h b/lib/librte_vhost/vhost_cuse/eventfd_copy.h\nnew file mode 100644\nindex 0000000..5f7307c\n--- /dev/null\n+++ b/lib/librte_vhost/vhost_cuse/eventfd_copy.h\n@@ -0,0 +1,40 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n+ *   All rights reserved.\n+ *\n+ *   Redistribution and use in source and binary forms, with or without\n+ *   modification, are permitted provided that the following conditions\n+ *   are met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ *       notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above copyright\n+ *       notice, this list of conditions and the following disclaimer in\n+ *       the documentation and/or other materials provided with the\n+ *       distribution.\n+ *     * Neither the name of Intel Corporation nor the names of its\n+ *       contributors may be used to endorse or promote products derived\n+ *       from this software without specific prior written permission.\n+ *\n+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+#ifndef _EVENTFD_H\n+#define _EVENTFD_H\n+\n+int\n+eventfd_copy(int target_fd, int target_pid);\n+\n+#endif\n+\ndiff --git a/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c b/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c\nindex 2ddd6e0..228da43 100644\n--- a/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c\n+++ b/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c\n@@ -38,8 +38,6 @@\n #include <stdint.h>\n #include <string.h>\n #include <unistd.h>\n-#include <sys/eventfd.h>\n-#include <sys/ioctl.h>\n \n #include <rte_ethdev.h>\n #include <rte_log.h>\n@@ -48,7 +46,7 @@\n \n #include \"virtio-net-cdev.h\"\n #include \"vhost-net.h\"\n-#include \"eventfd_link/eventfd_link.h\"\n+#include \"eventfd_copy.h\"\n \n #define FUSE_OPT_DUMMY \"\\0\\0\"\n #define FUSE_OPT_FORE  \"-f\\0\\0\"\n@@ -58,7 +56,7 @@ static const uint32_t default_major = 231;\n static const uint32_t default_minor = 1;\n static const char cuse_device_name[] = \"/dev/cuse\";\n static const char default_cdev[] = \"vhost-net\";\n-static const char eventfd_cdev[] = \"/dev/eventfd-link\";\n+\n \n static struct fuse_session *session;\n struct vhost_net_device_ops const *ops;\n@@ -178,47 +176,6 @@ vhost_net_release(fuse_req_t req, struct fuse_file_info *fi)\n } while (0)\n \n /*\n- * This function uses the eventfd_link kernel module to copy an eventfd file\n- * descriptor provided by QEMU in to our process space.\n- */\n-static int\n-eventfd_copy(int target_fd, int target_pid)\n-{\n-\tint eventfd_link, ret;\n-\tstruct eventfd_copy eventfd_copy;\n-\tint fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);\n-\n-\tif (fd == -1)\n-\t\treturn -1;\n-\n-\t/* Open the character device to the kernel module. */\n-\t/* TODO: check this earlier rather than fail until VM boots! */\n-\teventfd_link = open(eventfd_cdev, O_RDWR);\n-\tif (eventfd_link < 0) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG,\n-\t\t\t\"eventfd_link module is not loaded\\n\");\n-\t\tclose(fd);\n-\t\treturn -1;\n-\t}\n-\n-\teventfd_copy.source_fd = fd;\n-\teventfd_copy.target_fd = target_fd;\n-\teventfd_copy.target_pid = target_pid;\n-\t/* Call the IOCTL to copy the eventfd. */\n-\tret = ioctl(eventfd_link, EVENTFD_COPY, &eventfd_copy);\n-\tclose(eventfd_link);\n-\n-\tif (ret < 0) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG,\n-\t\t\t\"EVENTFD_COPY ioctl failed\\n\");\n-\t\tclose(fd);\n-\t\treturn -1;\n-\t}\n-\n-\treturn fd;\n-}\n-\n-/*\n  * The IOCTLs are handled using CUSE/FUSE in userspace. Depending on the type\n  * of IOCTL a buffer is requested to read or to write. This request is handled\n  * by FUSE and the buffer is then given to CUSE.\n@@ -240,7 +197,9 @@ vhost_net_ioctl(fuse_req_t req, int cmd, void *arg,\n \tcase VHOST_NET_SET_BACKEND:\n \t\tLOG_DEBUG(VHOST_CONFIG,\n \t\t\t\"(%\"PRIu64\") IOCTL: VHOST_NET_SET_BACKEND\\n\", ctx.fh);\n-\t\tVHOST_IOCTL_R(struct vhost_vring_file, file, ops->set_backend);\n+\t\tfile = *(const struct vhost_vring_file *)in_buf;\n+\t\tresult = cuse_set_backend(ctx, &file);\n+\t\tfuse_reply_ioctl(req, result, NULL, 0);\n \t\tbreak;\n \n \tcase VHOST_GET_FEATURES:\ndiff --git a/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c b/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c\nindex 1d2c403..6f7f4da 100644\n--- a/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c\n+++ b/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c\n@@ -43,6 +43,10 @@\n #include <sys/mman.h>\n #include <sys/types.h>\n #include <unistd.h>\n+#include <sys/ioctl.h>\n+#include <sys/socket.h>\n+#include <linux/if_tun.h>\n+#include <linux/if.h>\n #include <errno.h>\n \n #include <rte_log.h>\n@@ -51,6 +55,7 @@\n #include \"vhost-net.h\"\n #include \"virtio-net-cdev.h\"\n #include \"virtio-net.h\"\n+#include \"eventfd_copy.h\"\n \n /* Line size for reading maps file. */\n static const uint32_t BUFSIZE = PATH_MAX;\n@@ -346,3 +351,51 @@ cuse_set_mem_table(struct vhost_device_ctx ctx,\n \tops->set_mem_table(ctx, &regions[0], valid_regions);\n \treturn 0;\n }\n+\n+/*\n+ * Function to get the tap device name from the provided file descriptor and\n+ * save it in the device structure.\n+ */\n+static int\n+get_ifname(struct vhost_device_ctx ctx, struct virtio_net *dev, int tap_fd, int pid)\n+{\n+\tint fd_tap;\n+\tstruct ifreq ifr;\n+\tuint32_t ifr_size;\n+\tint ret;\n+\n+\tfd_tap = eventfd_copy(tap_fd, pid);\n+\tif (fd_tap < 0)\n+\t\treturn -1;\n+\n+\tret = ioctl(fd_tap, TUNGETIFF, &ifr);\n+\n+\tif (close(fd_tap) < 0)\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") fd close failed\\n\",\n+\t\t\tdev->device_fh);\n+\n+\tif (ret >= 0) {\n+\t\tifr_size = strnlen(ifr.ifr_name, sizeof(ifr.ifr_name));\n+\t\tops->set_ifname(ctx, ifr.ifr_name, ifr_size);\n+\t} else\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") TUNGETIFF ioctl failed\\n\",\n+\t\t\tdev->device_fh);\n+\n+\treturn 0;\n+}\n+\n+int cuse_set_backend(struct vhost_device_ctx ctx, struct vhost_vring_file *file)\n+{\n+\tstruct virtio_net *dev;\n+\n+\tdev = get_device(ctx);\n+\tif (dev == NULL)\n+\t\treturn -1;\n+\n+\tif (!(dev->flags & VIRTIO_DEV_RUNNING))\n+\t\tget_ifname(ctx, dev, file->fd, ctx.pid);\n+\n+\treturn ops->set_backend(ctx, file);\n+}\ndiff --git a/lib/librte_vhost/vhost_cuse/virtio-net-cdev.h b/lib/librte_vhost/vhost_cuse/virtio-net-cdev.h\nindex 5ee81b1..eb6b0ba 100644\n--- a/lib/librte_vhost/vhost_cuse/virtio-net-cdev.h\n+++ b/lib/librte_vhost/vhost_cuse/virtio-net-cdev.h\n@@ -42,4 +42,7 @@ int\n cuse_set_mem_table(struct vhost_device_ctx ctx,\n \tconst struct vhost_memory *mem_regions_addr, uint32_t nregions);\n \n+int\n+cuse_set_backend(struct vhost_device_ctx ctx, struct vhost_vring_file *);\n+\n #endif\ndiff --git a/lib/librte_vhost/vhost_user/vhost-net-user.c b/lib/librte_vhost/vhost_user/vhost-net-user.c\nindex 3a45a5e..38fef83 100644\n--- a/lib/librte_vhost/vhost_user/vhost-net-user.c\n+++ b/lib/librte_vhost/vhost_user/vhost-net-user.c\n@@ -265,6 +265,7 @@ vserver_new_vq_conn(int fd, void *dat)\n \tstruct connfd_ctx *ctx;\n \tint fh;\n \tstruct vhost_device_ctx vdev_ctx = { 0 };\n+\tunsigned int size;\n \n \tconn_fd = accept(fd, NULL, NULL);\n \tRTE_LOG(INFO, VHOST_CONFIG,\n@@ -284,6 +285,12 @@ vserver_new_vq_conn(int fd, void *dat)\n \t\tclose(conn_fd);\n \t\treturn;\n \t}\n+\n+\tvdev_ctx.fh = fh;\n+\tsize = strnlen(vserver->path, PATH_MAX);\n+\tops->set_ifname(vdev_ctx, vserver->path,\n+\t\tsize);\n+\n \tRTE_LOG(INFO, VHOST_CONFIG, \"new device, handle is %d\\n\", fh);\n \n \tctx->vserver = vserver;\ndiff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c\nindex c458ed9..c45bccc 100644\n--- a/lib/librte_vhost/virtio-net.c\n+++ b/lib/librte_vhost/virtio-net.c\n@@ -40,8 +40,6 @@\n #include <unistd.h>\n \n #include <sys/socket.h>\n-#include <linux/if_tun.h>\n-#include <linux/if.h>\n \n #include <rte_ethdev.h>\n #include <rte_log.h>\n@@ -354,6 +352,24 @@ destroy_device(struct vhost_device_ctx ctx)\n \t}\n }\n \n+static void\n+set_ifname(struct vhost_device_ctx ctx,\n+\tconst char *if_name, unsigned int if_len)\n+{\n+\tstruct virtio_net *dev;\n+\tunsigned int len;\n+\n+\tdev = get_device(ctx);\n+\tif (dev == NULL)\n+\t\treturn;\n+\n+\tlen = if_len > sizeof(dev->ifname) ?\n+\t\tsizeof(dev->ifname) : if_len;\n+\n+\tstrncpy(dev->ifname, if_name, len);\n+}\n+\n+\n /*\n  * Called from CUSE IOCTL: VHOST_SET_OWNER\n  * This function just returns success at the moment unless\n@@ -660,46 +676,6 @@ set_vring_kick(struct vhost_device_ctx ctx, struct vhost_vring_file *file)\n }\n \n /*\n- * Function to get the tap device name from the provided file descriptor and\n- * save it in the device structure.\n- */\n-static int\n-get_ifname(struct virtio_net *dev, int tap_fd, int pid)\n-{\n-\tstruct eventfd_copy fd_tap;\n-\tstruct ifreq ifr;\n-\tuint32_t size, ifr_size;\n-\tint ret;\n-\n-\tfd_tap.source_fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);\n-\tfd_tap.target_fd = tap_fd;\n-\tfd_tap.target_pid = pid;\n-\n-\tif (eventfd_copy(dev, &fd_tap))\n-\t\treturn -1;\n-\n-\tret = ioctl(fd_tap.source_fd, TUNGETIFF, &ifr);\n-\n-\tif (close(fd_tap.source_fd) < 0)\n-\t\tRTE_LOG(ERR, VHOST_CONFIG,\n-\t\t\t\"(%\"PRIu64\") fd close failed\\n\",\n-\t\t\tdev->device_fh);\n-\n-\tif (ret >= 0) {\n-\t\tifr_size = strnlen(ifr.ifr_name, sizeof(ifr.ifr_name));\n-\t\tsize = ifr_size > sizeof(dev->ifname) ?\n-\t\t\t\tsizeof(dev->ifname) : ifr_size;\n-\n-\t\tstrncpy(dev->ifname, ifr.ifr_name, size);\n-\t} else\n-\t\tRTE_LOG(ERR, VHOST_CONFIG,\n-\t\t\t\"(%\"PRIu64\") TUNGETIFF ioctl failed\\n\",\n-\t\t\tdev->device_fh);\n-\n-\treturn 0;\n-}\n-\n-/*\n  * Called from CUSE IOCTL: VHOST_NET_SET_BACKEND\n  * To complete device initialisation when the virtio driver is loaded,\n  * we are provided with a valid fd for a tap device (not used by us).\n@@ -727,7 +703,6 @@ set_backend(struct vhost_device_ctx ctx, struct vhost_vring_file *file)\n \tif (!(dev->flags & VIRTIO_DEV_RUNNING)) {\n \t\tif (((int)dev->virtqueue[VIRTIO_TXQ]->backend != VIRTIO_DEV_STOPPED) &&\n \t\t\t((int)dev->virtqueue[VIRTIO_RXQ]->backend != VIRTIO_DEV_STOPPED)) {\n-\t\t\tget_ifname(dev, file->fd, ctx.pid);\n \t\t\treturn notify_ops->new_device(dev);\n \t\t}\n \t/* Otherwise we remove it. */\n@@ -745,6 +720,8 @@ static const struct vhost_net_device_ops vhost_device_ops = {\n \t.new_device = new_device,\n \t.destroy_device = destroy_device,\n \n+\t.set_ifname = set_ifname,\n+\n \t.get_features = get_features,\n \t.set_features = set_features,\n \n",
    "prefixes": [
        "dpdk-dev",
        "RFC",
        "v2",
        "14/14"
    ]
}