Skip to content

Commit

Permalink
vhost: fix passing destroyed device to destroy callback
Browse files Browse the repository at this point in the history
[ upstream commit 2344395 ]

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: efba12a ("vhost: add user callbacks for socket open/close")

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
  • Loading branch information
igsilya authored and kevintraynor committed May 7, 2019
1 parent cee8e7e commit 9fc9960
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/librte_vhost/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9fc9960

Please sign in to comment.