From 2344395df2e944683df87b1a47f8b64eea050d2b Mon Sep 17 00:00:00 2001 From: Ilya Maximets Date: Fri, 12 Apr 2019 11:32:28 +0300 Subject: [PATCH] vhost: fix passing destroyed device to destroy callback Application should be able to obtain information like 'ifname' from the 'vid' passed to 'destroy_connection' callback. Currently, all the API calls with passed 'vid' fails with 'device not found'. Fixes: efba12a78ddf ("vhost: add user callbacks for socket open/close") Cc: stable@dpdk.org Signed-off-by: Ilya Maximets Reviewed-by: Tiwei Bie --- lib/librte_vhost/socket.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c index c7a77a5d54..274988c4d7 100644 --- a/lib/librte_vhost/socket.c +++ b/lib/librte_vhost/socket.c @@ -297,13 +297,19 @@ vhost_user_read_cb(int connfd, void *dat, int *remove) ret = vhost_user_msg_handler(conn->vid, connfd); if (ret < 0) { + struct virtio_net *dev = get_device(conn->vid); + close(connfd); *remove = 1; - vhost_destroy_device(conn->vid); + + if (dev) + vhost_destroy_device_notify(dev); if (vsocket->notify_ops->destroy_connection) vsocket->notify_ops->destroy_connection(conn->vid); + vhost_destroy_device(conn->vid); + pthread_mutex_lock(&vsocket->conn_mutex); TAILQ_REMOVE(&vsocket->conn_list, conn, next); pthread_mutex_unlock(&vsocket->conn_mutex); -- 2.20.1