patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH 19.11] app/testpmd: fix multicast address pool leak
@ 2022-07-20  3:05 Ke Zhang
  2022-08-03 10:09 ` Christian Ehrhardt
  0 siblings, 1 reply; 2+ messages in thread
From: Ke Zhang @ 2022-07-20  3:05 UTC (permalink / raw)
  To: stable; +Cc: Ke Zhang, Yuying Zhang, Ferruh Yigit

[ upstream commit "68629be3a622ee53cd5b40c8447ae9b083ff3f6c" ]

A multicast address pool is allocated for a port when
using mcast_addr testpmd commands.

When closing a port or stopping testpmd, this pool was
not freed, resulting in a leak.
This issue has been caught using ASan.

Free this pool when closing the port.

Error info as following:
ERROR: LeakSanitizer: detected memory leaksDirect leak of
       192 byte(s)
0 0x7f6a2e0aeffe in __interceptor_realloc
        (/lib/x86_64-linux-gnu/libasan.so.5+0x10dffe)
1 0x565361eb340f in mcast_addr_pool_extend
        ../app/test-pmd/config.c:5162
2 0x565361eb3556 in mcast_addr_pool_append
        ../app/test-pmd/config.c:5180
3 0x565361eb3aae in mcast_addr_add
        ../app/test-pmd/config.c:5243

Fixes: 8fff667578a7 ("app/testpmd: new command to add/remove multicast MAC addresses")
Cc: stable@dpdk.org

Signed-off-by: Ke Zhang <ke1x.zhang@intel.com>
Acked-by: Yuying Zhang <yuying.zhang@intel.com>
Acked-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
---
 app/test-pmd/config.c  | 19 +++++++++++++++++++
 app/test-pmd/testpmd.c |  1 +
 app/test-pmd/testpmd.h |  1 +
 3 files changed, 21 insertions(+)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 3eefc90bf..995fd3b38 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -3996,6 +3996,25 @@ mcast_addr_pool_remove(struct rte_port *port, uint32_t addr_idx)
 		sizeof(struct rte_ether_addr) * (port->mc_addr_nb - addr_idx));
 }
 
+int
+mcast_addr_pool_destroy(portid_t port_id)
+{
+	struct rte_port *port;
+
+	if (port_id_is_invalid(port_id, ENABLED_WARN) ||
+	    port_id == (portid_t)RTE_PORT_ALL)
+		return -EINVAL;
+	port = &ports[port_id];
+
+	if (port->mc_addr_nb != 0) {
+		/* free the pool of multicast addresses. */
+		free(port->mc_addr_pool);
+		port->mc_addr_pool = NULL;
+		port->mc_addr_nb = 0;
+	}
+	return 0;
+}
+
 static int
 eth_port_multicast_addr_list_set(portid_t port_id)
 {
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index cb59c85c8..523f48c97 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2612,6 +2612,7 @@ close_port(portid_t pid)
 
 		if (port->flow_list)
 			port_flow_flush(pi);
+		mcast_addr_pool_destroy(pi);
 		rte_eth_dev_close(pi);
 
 		remove_invalid_ports();
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 244b0c710..ac18bc394 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -733,6 +733,7 @@ int port_flow_create(portid_t port_id,
 		     const struct rte_flow_attr *attr,
 		     const struct rte_flow_item *pattern,
 		     const struct rte_flow_action *actions);
+int mcast_addr_pool_destroy(portid_t port_id);
 int port_flow_destroy(portid_t port_id, uint32_t n, const uint32_t *rule);
 int port_flow_flush(portid_t port_id);
 int port_flow_query(portid_t port_id, uint32_t rule,
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 19.11] app/testpmd: fix multicast address pool leak
  2022-07-20  3:05 [PATCH 19.11] app/testpmd: fix multicast address pool leak Ke Zhang
@ 2022-08-03 10:09 ` Christian Ehrhardt
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Ehrhardt @ 2022-08-03 10:09 UTC (permalink / raw)
  To: Ke Zhang; +Cc: stable, Yuying Zhang, Ferruh Yigit

On Wed, Jul 20, 2022 at 5:13 AM Ke Zhang <ke1x.zhang@intel.com> wrote:
>
> [ upstream commit "68629be3a622ee53cd5b40c8447ae9b083ff3f6c" ]

Thank you,
your patch was too late in regard to my original deadline and I was
then unavailable for a while.
In the meantime more patches came in and I do not want to waste any of
them just because they were late.

Sadly your patch didn't apply due to others landing as well.
But the only conflict it had seemed easy and I have resolved it,
please consider having a look at
https://github.com/cpaelzer/dpdk-stable-queue/tree/19.11 if you agree.

> A multicast address pool is allocated for a port when
> using mcast_addr testpmd commands.
>
> When closing a port or stopping testpmd, this pool was
> not freed, resulting in a leak.
> This issue has been caught using ASan.
>
> Free this pool when closing the port.
>
> Error info as following:
> ERROR: LeakSanitizer: detected memory leaksDirect leak of
>        192 byte(s)
> 0 0x7f6a2e0aeffe in __interceptor_realloc
>         (/lib/x86_64-linux-gnu/libasan.so.5+0x10dffe)
> 1 0x565361eb340f in mcast_addr_pool_extend
>         ../app/test-pmd/config.c:5162
> 2 0x565361eb3556 in mcast_addr_pool_append
>         ../app/test-pmd/config.c:5180
> 3 0x565361eb3aae in mcast_addr_add
>         ../app/test-pmd/config.c:5243
>
> Fixes: 8fff667578a7 ("app/testpmd: new command to add/remove multicast MAC addresses")
> Cc: stable@dpdk.org
>
> Signed-off-by: Ke Zhang <ke1x.zhang@intel.com>
> Acked-by: Yuying Zhang <yuying.zhang@intel.com>
> Acked-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
> ---
>  app/test-pmd/config.c  | 19 +++++++++++++++++++
>  app/test-pmd/testpmd.c |  1 +
>  app/test-pmd/testpmd.h |  1 +
>  3 files changed, 21 insertions(+)
>
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
> index 3eefc90bf..995fd3b38 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -3996,6 +3996,25 @@ mcast_addr_pool_remove(struct rte_port *port, uint32_t addr_idx)
>                 sizeof(struct rte_ether_addr) * (port->mc_addr_nb - addr_idx));
>  }
>
> +int
> +mcast_addr_pool_destroy(portid_t port_id)
> +{
> +       struct rte_port *port;
> +
> +       if (port_id_is_invalid(port_id, ENABLED_WARN) ||
> +           port_id == (portid_t)RTE_PORT_ALL)
> +               return -EINVAL;
> +       port = &ports[port_id];
> +
> +       if (port->mc_addr_nb != 0) {
> +               /* free the pool of multicast addresses. */
> +               free(port->mc_addr_pool);
> +               port->mc_addr_pool = NULL;
> +               port->mc_addr_nb = 0;
> +       }
> +       return 0;
> +}
> +
>  static int
>  eth_port_multicast_addr_list_set(portid_t port_id)
>  {
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
> index cb59c85c8..523f48c97 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -2612,6 +2612,7 @@ close_port(portid_t pid)
>
>                 if (port->flow_list)
>                         port_flow_flush(pi);
> +               mcast_addr_pool_destroy(pi);
>                 rte_eth_dev_close(pi);
>
>                 remove_invalid_ports();
> diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
> index 244b0c710..ac18bc394 100644
> --- a/app/test-pmd/testpmd.h
> +++ b/app/test-pmd/testpmd.h
> @@ -733,6 +733,7 @@ int port_flow_create(portid_t port_id,
>                      const struct rte_flow_attr *attr,
>                      const struct rte_flow_item *pattern,
>                      const struct rte_flow_action *actions);
> +int mcast_addr_pool_destroy(portid_t port_id);
>  int port_flow_destroy(portid_t port_id, uint32_t n, const uint32_t *rule);
>  int port_flow_flush(portid_t port_id);
>  int port_flow_query(portid_t port_id, uint32_t rule,
> --
> 2.25.1
>


-- 
Christian Ehrhardt
Senior Staff Engineer, Ubuntu Server
Canonical Ltd

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-03 10:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-20  3:05 [PATCH 19.11] app/testpmd: fix multicast address pool leak Ke Zhang
2022-08-03 10:09 ` Christian Ehrhardt

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).