From: Christian Ehrhardt <christian.ehrhardt@canonical.com>
To: longli@microsoft.com
Cc: stable@dpdk.org
Subject: Re: [PATCH 19.11] net/mlx5: fix Verbs FD leak in secondary process
Date: Thu, 17 Nov 2022 08:40:27 +0100 [thread overview]
Message-ID: <CAATJJ0+pSJ67cMFKYUm7P62dWr9VnoRe=aj9_gW=WHKmEO9NUg@mail.gmail.com> (raw)
In-Reply-To: <1668626738-30282-1-git-send-email-longli@microsoft.com>
On Wed, Nov 16, 2022 at 8:26 PM Long Li <longli@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@dpdk.org
>
> Signed-off-by: Long Li <longli@microsoft.com>
> Acked-by: Viacheslav Ovsiienko <viacheslavo@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
prev parent reply other threads:[~2022-11-17 7:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-16 19:25 Long Li
2022-11-17 7:40 ` Christian Ehrhardt [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAATJJ0+pSJ67cMFKYUm7P62dWr9VnoRe=aj9_gW=WHKmEO9NUg@mail.gmail.com' \
--to=christian.ehrhardt@canonical.com \
--cc=longli@microsoft.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).