[dpdk-dev] [PATCH] net/vhost: fix unix socket not removed as closing
Yuanhan Liu
yuanhan.liu at linux.intel.com
Mon Jan 30 14:21:52 CET 2017
On Tue, Jan 24, 2017 at 08:37:38AM +0000, Jianfeng Tan wrote:
> The commit aed0b12930b ("net/vhost: fix socket file deleted on stop")
> moves rte_vhost_driver_register and rte_vhost_driver_unregister from
> dev_start() and dev_stop() into driver's probe() and remove().
>
> Apps, like testpmd, using vhost pmd in server mode, usually calls
> dev_stop() and dev_close() as quitting, instead of driver-specific
> remove(). Then those unix socket files have no chance to get removed.
>
> Semantically, device-specific things should be put into device-specific
> APIs. Fix this issue by moving rte_vhost_driver_unregister, plus other
> structure free into dev_close().
>
> Fixes: aed0b12930b3 ("net/vhost: fix socket file deleted on stop")
The original commit will be cherry-picked to v16.11 stable release,
as a fix commit of it, this commit should also be picked. So,
Cc: stable at dpdk.org
>
> Reported-by: Lei Yao <lei.a.yao at intel.com>
> Signed-off-by: Jianfeng Tan <jianfeng.tan at intel.com>
> ---
> drivers/net/vhost/rte_eth_vhost.c | 48 +++++++++++++++++++++++----------------
> 1 file changed, 28 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
> index 848a3da..93b8a52 100644
> --- a/drivers/net/vhost/rte_eth_vhost.c
> +++ b/drivers/net/vhost/rte_eth_vhost.c
> @@ -801,6 +801,32 @@ eth_dev_stop(struct rte_eth_dev *dev)
> update_queuing_status(dev);
> }
>
> +static void
> +eth_dev_close(struct rte_eth_dev *dev)
> +{
> + struct pmd_internal *internal;
> + struct internal_list *list;
> +
> + internal = dev->data->dev_private;
> + if (!internal)
> + return;
> +
> + list = find_internal_resource(internal->iface_name);
> + if (!list)
> + return;
> +
> + pthread_mutex_lock(&internal_list_lock);
> + TAILQ_REMOVE(&internal_list, list, next);
> + pthread_mutex_unlock(&internal_list_lock);
> + rte_free(list);
> +
> + rte_vhost_driver_unregister(internal->iface_name);
Note that you should invoke rte_vhost_driver_unregister() before
removing "internal" from the list, otherwise you might get an error
like following from destory_device() callback (which will try to
find the "internal" again).
PMD: Invalid interface name: /tmp/vhost-net
Fixed and applied to dpdk-next-virtio.
--yliu
More information about the dev
mailing list