patch 'app/testpmd: fix multicast address pool leak' has been queued to stable release 20.11.6

Xueming Li xuemingl at nvidia.com
Tue Jun 21 10:02:55 CEST 2022


Hi,

FYI, your patch has been queued to stable release 20.11.6

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 06/23/22. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/steevenlee/dpdk

This queued commit can be viewed at:
https://github.com/steevenlee/dpdk/commit/59d08006aa2a9596efd300fb54e033f07167b65a

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From 59d08006aa2a9596efd300fb54e033f07167b65a Mon Sep 17 00:00:00 2001
From: Ke Zhang <ke1x.zhang at intel.com>
Date: Fri, 25 Mar 2022 08:35:55 +0000
Subject: [PATCH] app/testpmd: fix multicast address pool leak
Cc: Xueming Li <xuemingl at nvidia.com>

[ 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")

Signed-off-by: Ke Zhang <ke1x.zhang at intel.com>
Acked-by: Yuying Zhang <yuying.zhang at intel.com>
Acked-by: Ferruh Yigit <ferruh.yigit at 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 ee2f560b61..d24fb7763e 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -5088,6 +5088,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 6ecb032c81..ae7a7ddd3e 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2834,6 +2834,7 @@ close_port(portid_t pid)
 			continue;
 		}
 
+		mcast_addr_pool_destroy(pi);
 		port_flow_flush(pi);
 		rte_eth_dev_close(pi);
 	}
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 5fa898eb96..6ccdff43f1 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -838,6 +838,7 @@ int port_flow_create(portid_t port_id,
 int port_shared_action_query(portid_t port_id, uint32_t id);
 void update_age_action_context(const struct rte_flow_action *actions,
 		     struct port_flow *pf);
+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_dump(portid_t port_id, const char *file_name);
-- 
2.35.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-06-21 15:37:54.061779618 +0800
+++ 0109-app-testpmd-fix-multicast-address-pool-leak.patch	2022-06-21 15:37:49.234451950 +0800
@@ -1 +1 @@
-From 68629be3a622ee53cd5b40c8447ae9b083ff3f6c Mon Sep 17 00:00:00 2001
+From 59d08006aa2a9596efd300fb54e033f07167b65a Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 68629be3a622ee53cd5b40c8447ae9b083ff3f6c ]
@@ -28 +30,0 @@
-Cc: stable at dpdk.org
@@ -40 +42 @@
-index 72d2606d19..d6caa1f0b2 100644
+index ee2f560b61..d24fb7763e 100644
@@ -43 +45 @@
-@@ -6070,6 +6070,25 @@ mcast_addr_pool_remove(struct rte_port *port, uint32_t addr_idx)
+@@ -5088,6 +5088,25 @@ mcast_addr_pool_remove(struct rte_port *port, uint32_t addr_idx)
@@ -70 +72 @@
-index 4d51eb9576..9d6175e9a7 100644
+index 6ecb032c81..ae7a7ddd3e 100644
@@ -73 +75,2 @@
-@@ -3237,6 +3237,7 @@ close_port(portid_t pid)
+@@ -2834,6 +2834,7 @@ close_port(portid_t pid)
+ 			continue;
@@ -76,5 +79,4 @@
- 		if (is_proc_primary()) {
-+			mcast_addr_pool_destroy(pi);
- 			port_flow_flush(pi);
- 			port_flex_item_flush(pi);
- 			port_action_handle_flush(pi);
++		mcast_addr_pool_destroy(pi);
+ 		port_flow_flush(pi);
+ 		rte_eth_dev_close(pi);
+ 	}
@@ -82 +84 @@
-index 6693813dda..dd34b025e6 100644
+index 5fa898eb96..6ccdff43f1 100644
@@ -85,2 +87,2 @@
-@@ -991,6 +991,7 @@ int port_flow_create(portid_t port_id,
- int port_action_handle_query(portid_t port_id, uint32_t id);
+@@ -838,6 +838,7 @@ int port_flow_create(portid_t port_id,
+ int port_shared_action_query(portid_t port_id, uint32_t id);
@@ -92 +94 @@
- int port_flow_dump(portid_t port_id, bool dump_all,
+ int port_flow_dump(portid_t port_id, const char *file_name);


More information about the stable mailing list