Skip to content

Commit

Permalink
net/mlx5: fix Verbs FD leak in secondary process
Browse files Browse the repository at this point in the history
[ upstream commit bc5d8fd ]

FDs passed from rte_mp_msg are duplicated to the secondary process and
need to be closed.

Fixes: 9a8ab29 ("net/mlx5: replace IPC socket with EAL API")

Signed-off-by: Long Li <longli@microsoft.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
  • Loading branch information
longlimsft authored and kevintraynor committed Oct 11, 2022
1 parent 43ebf47 commit 879ebb7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion drivers/net/mlx5/linux/mlx5_mp_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,18 @@ struct rte_mp_msg mp_res;
mlx5_tx_uar_uninit_secondary(dev);
mlx5_proc_priv_uninit(dev);
ret = mlx5_proc_priv_init(dev);
if (ret)
if (ret) {
close(mp_msg->fds[0]);
return -rte_errno;
}
ret = mlx5_tx_uar_init_secondary(dev, mp_msg->fds[0]);
if (ret) {
close(mp_msg->fds[0]);
mlx5_proc_priv_uninit(dev);
return -rte_errno;
}
}
close(mp_msg->fds[0]);
rte_mb();
mp_init_msg(&priv->mp_id, &mp_res, param->type);
res->result = 0;
Expand Down
8 changes: 5 additions & 3 deletions drivers/net/mlx5/linux/mlx5_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
DRV_LOG(DEBUG, "naming Ethernet device \"%s\"", name);
if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
struct mlx5_mp_id mp_id;
int fd;

eth_dev = rte_eth_dev_attach_secondary(name);
if (eth_dev == NULL) {
Expand All @@ -949,11 +950,12 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
return NULL;
mlx5_mp_id_init(&mp_id, eth_dev->data->port_id);
/* Receive command fd from primary process */
err = mlx5_mp_req_verbs_cmd_fd(&mp_id);
if (err < 0)
fd = mlx5_mp_req_verbs_cmd_fd(&mp_id);
if (fd < 0)
goto err_secondary;
/* Remap UAR for Tx queues. */
err = mlx5_tx_uar_init_secondary(eth_dev, err);
err = mlx5_tx_uar_init_secondary(eth_dev, fd);
close(fd);
if (err)
goto err_secondary;
/*
Expand Down

0 comments on commit 879ebb7

Please sign in to comment.