[v1] net/mlx5: fix secondary process resource leakage
Checks
Commit Message
When running testpmd with an mlx5 device and then executing at testpmd
prompt in a raw: "port start all" followed by "port stop all"
a new file named /var/tmp/net_mlx5_<socket num> is created as a result
of creating a new unix domain socket (used for communication between
the primary and secondary processes).
When the new unix socket file is created the old unix socket file should
have been removed. This commit fixes it by closing the old unix socket
just before creating the new one in function mlx5_socket_init()
Fixes: f8b9a3bad467 ("net/mlx5: install a socket to exchange a file descriptor")
Cc: stable@dpdk.org
Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
---
drivers/net/mlx5/mlx5_socket.c | 6 ++++++
1 file changed, 6 insertions(+)
Comments
Hi Ophir,
Wednesday, August 1, 2018 1:38 AM, Ophir Munk:
> Subject: [dpdk-dev] [PATCH v1] net/mlx5: fix secondary process resource
> leakage
>
> When running testpmd with an mlx5 device and then executing at testpmd
> prompt in a raw: "port start all" followed by "port stop all"
> a new file named /var/tmp/net_mlx5_<socket num> is created as a result of
> creating a new unix domain socket (used for communication between the
> primary and secondary processes).
> When the new unix socket file is created the old unix socket file should have
> been removed. This commit fixes it by closing the old unix socket just before
> creating the new one in function mlx5_socket_init()
>
> Fixes: f8b9a3bad467 ("net/mlx5: install a socket to exchange a file
> descriptor")
> Cc: stable@dpdk.org
>
> Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
> ---
> drivers/net/mlx5/mlx5_socket.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/net/mlx5/mlx5_socket.c
> b/drivers/net/mlx5/mlx5_socket.c index 99297d5..a3a5229 100644
> --- a/drivers/net/mlx5/mlx5_socket.c
> +++ b/drivers/net/mlx5/mlx5_socket.c
> @@ -36,6 +36,12 @@
> int flags;
>
> /*
> + * Close the last socket that was used to communicate
> + * with the secondary process
> + */
> + if (priv->primary_socket)
> + mlx5_socket_uninit(dev);
On the current code the primary socket is created on port start and removed on port close (this is the bug you address).
Wouldn't it be better to just create it on probe?
This way the primary sets up its socket when the ethdev is created and removes it when it is destroyed. The handling of the socket event still happen only when the primary ports start because only then the interrupt handler is installed.
> + /*
> * Initialise the socket to communicate with the secondary
> * process.
> */
> --
> 1.8.3.1
Wednesday, August 1, 2018 11:01 AM, Shahaf Shuler:
> Subject: RE: [dpdk-dev] [PATCH v1] net/mlx5: fix secondary process resource
> leakage
>
> Hi Ophir,
>
> Wednesday, August 1, 2018 1:38 AM, Ophir Munk:
> > Subject: [dpdk-dev] [PATCH v1] net/mlx5: fix secondary process
> > resource leakage
> >
> > When running testpmd with an mlx5 device and then executing at testpmd
> > prompt in a raw: "port start all" followed by "port stop all"
> > a new file named /var/tmp/net_mlx5_<socket num> is created as a result
> > of creating a new unix domain socket (used for communication between
> > the primary and secondary processes).
> > When the new unix socket file is created the old unix socket file
> > should have been removed. This commit fixes it by closing the old unix
> > socket just before creating the new one in function mlx5_socket_init()
> >
> > Fixes: f8b9a3bad467 ("net/mlx5: install a socket to exchange a file
> > descriptor")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
> > ---
> > drivers/net/mlx5/mlx5_socket.c | 6 ++++++
> > 1 file changed, 6 insertions(+)
> >
> > diff --git a/drivers/net/mlx5/mlx5_socket.c
> > b/drivers/net/mlx5/mlx5_socket.c index 99297d5..a3a5229 100644
> > --- a/drivers/net/mlx5/mlx5_socket.c
> > +++ b/drivers/net/mlx5/mlx5_socket.c
> > @@ -36,6 +36,12 @@
> > int flags;
> >
> > /*
> > + * Close the last socket that was used to communicate
> > + * with the secondary process
> > + */
> > + if (priv->primary_socket)
> > + mlx5_socket_uninit(dev);
>
> On the current code the primary socket is created on port start and removed
> on port close (this is the bug you address).
> Wouldn't it be better to just create it on probe?
> This way the primary sets up its socket when the ethdev is created and
> removes it when it is destroyed. The handling of the socket event still
> happen only when the primary ports start because only then the interrupt
> handler is installed.
After internal discussion w/ Ophir we decided to take this patch as is considering we are very late on this release and this fix has a low risk to break something else.
We need to address this one on the next release in a better way.
Applied to next-net-mlx, thanks.
>
> > + /*
> > * Initialise the socket to communicate with the secondary
> > * process.
> > */
> > --
> > 1.8.3.1
@@ -36,6 +36,12 @@
int flags;
/*
+ * Close the last socket that was used to communicate
+ * with the secondary process
+ */
+ if (priv->primary_socket)
+ mlx5_socket_uninit(dev);
+ /*
* Initialise the socket to communicate with the secondary
* process.
*/