[PATCH 19.11] net/mlx5: fix Verbs FD leak in secondary process
Christian Ehrhardt
christian.ehrhardt at canonical.com
Thu Nov 17 08:40:27 CET 2022
On Wed, Nov 16, 2022 at 8:26 PM Long Li <longli at microsoft.com> wrote:
>
> [ upstream commit bc5d8fdb7008210e2698fa1f91e51d7dfba00f77 ]
Applied, thanks!
> FDs passed from rte_mp_msg are duplicated to the secondary process and
> need to be closed.
>
> Fixes: 9a8ab29b84 ("net/mlx5: replace IPC socket with EAL API")
> Cc: stable at dpdk.org
>
> Signed-off-by: Long Li <longli at microsoft.com>
> Acked-by: Viacheslav Ovsiienko <viacheslavo at nvidia.com>
> ---
> drivers/net/mlx5/mlx5.c | 9 ++++++---
> drivers/net/mlx5/mlx5_mp.c | 6 +++++-
> 2 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
> index dee018bbba..2d0f9625fb 100644
> --- a/drivers/net/mlx5/mlx5.c
> +++ b/drivers/net/mlx5/mlx5.c
> @@ -2291,6 +2291,8 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
> }
> DRV_LOG(DEBUG, "naming Ethernet device \"%s\"", name);
> if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
> + int fd;
> +
> eth_dev = rte_eth_dev_attach_secondary(name);
> if (eth_dev == NULL) {
> DRV_LOG(ERR, "can not attach rte ethdev");
> @@ -2303,11 +2305,12 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
> if (err)
> return NULL;
> /* Receive command fd from primary process */
> - err = mlx5_mp_req_verbs_cmd_fd(eth_dev);
> - if (err < 0)
> + fd = mlx5_mp_req_verbs_cmd_fd(eth_dev);
> + 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;
> /*
> diff --git a/drivers/net/mlx5/mlx5_mp.c b/drivers/net/mlx5/mlx5_mp.c
> index 6b7f5f3dcb..7e05217cda 100644
> --- a/drivers/net/mlx5/mlx5_mp.c
> +++ b/drivers/net/mlx5/mlx5_mp.c
> @@ -142,14 +142,18 @@ mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
> 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(dev, &mp_res, param->type);
> res->result = 0;
> --
> 2.17.1
>
--
Christian Ehrhardt
Senior Staff Engineer, Ubuntu Server
Canonical Ltd
More information about the stable
mailing list