The commit
aed0b12930b3 ("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")
Cc: stable@dpdk.org
Reported-by: Lei Yao <lei.a.yao@intel.com>
Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
update_queuing_status(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;
+
+ rte_vhost_driver_unregister(internal->iface_name);
+
+ 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);
+
+ free(internal->dev_name);
+ free(internal->iface_name);
+ rte_free(internal);
+}
+
static int
eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
uint16_t nb_rx_desc __rte_unused,
static int
eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
uint16_t nb_rx_desc __rte_unused,
static const struct eth_dev_ops ops = {
.dev_start = eth_dev_start,
.dev_stop = eth_dev_stop,
static const struct eth_dev_ops ops = {
.dev_start = eth_dev_start,
.dev_stop = eth_dev_stop,
+ .dev_close = eth_dev_close,
.dev_configure = eth_dev_configure,
.dev_infos_get = eth_dev_info,
.rx_queue_setup = eth_rx_queue_setup,
.dev_configure = eth_dev_configure,
.dev_infos_get = eth_dev_info,
.rx_queue_setup = eth_rx_queue_setup,
rte_pmd_vhost_remove(const char *name)
{
struct rte_eth_dev *eth_dev = NULL;
rte_pmd_vhost_remove(const char *name)
{
struct rte_eth_dev *eth_dev = NULL;
- struct pmd_internal *internal;
- struct internal_list *list;
unsigned int i;
RTE_LOG(INFO, PMD, "Un-Initializing pmd_vhost for %s\n", name);
unsigned int i;
RTE_LOG(INFO, PMD, "Un-Initializing pmd_vhost for %s\n", name);
if (eth_dev == NULL)
return -ENODEV;
if (eth_dev == NULL)
return -ENODEV;
- internal = eth_dev->data->dev_private;
- if (internal == NULL)
- return -ENODEV;
-
- list = find_internal_resource(internal->iface_name);
- if (list == NULL)
- return -ENODEV;
-
- 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);
+ eth_dev_close(eth_dev);
if (rte_atomic16_sub_return(&nb_started_ports, 1) == 0)
vhost_driver_session_stop();
if (rte_atomic16_sub_return(&nb_started_ports, 1) == 0)
vhost_driver_session_stop();
rte_free(vring_states[eth_dev->data->port_id]);
vring_states[eth_dev->data->port_id] = NULL;
rte_free(vring_states[eth_dev->data->port_id]);
vring_states[eth_dev->data->port_id] = NULL;
- free(internal->dev_name);
- free(internal->iface_name);
-
for (i = 0; i < eth_dev->data->nb_rx_queues; i++)
rte_free(eth_dev->data->rx_queues[i]);
for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
for (i = 0; i < eth_dev->data->nb_rx_queues; i++)
rte_free(eth_dev->data->rx_queues[i]);
for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
rte_free(eth_dev->data->mac_addrs);
rte_free(eth_dev->data);
rte_free(eth_dev->data->mac_addrs);
rte_free(eth_dev->data);
rte_eth_dev_release_port(eth_dev);
rte_eth_dev_release_port(eth_dev);