patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH] app/testpmd: cleanup port resources after implicit close
@ 2022-06-15 23:12 Dmitry Kozlyuk
  2022-06-23 11:17 ` Andrew Rybchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Kozlyuk @ 2022-06-15 23:12 UTC (permalink / raw)
  To: dev; +Cc: stable, Matan Azrad, Xiaoyun Li, Aman Singh, Yuying Zhang

When a port was closed implicitly closed by the PMD, for example,
if it was a representor port and its master port was detached,
flow indirect actions could remain with their handles no longer valid.
If a newly attached device was assigned the same ID as the closed port,
those indirect actions became accessible again.
Any attempt to use them resulted in an undefined behavior.
Flow flex items had no such issue on close, but had it on detach.

Introduce flush_port_owned_resources() function
for consistent cleanup and call it when a port is closed or detached.
Make it flush flow rules and multicast addresses too
because they logically belong to the port being removed.

Fixes: 55509e3a49fb ("app/testpmd: support shared flow action")
Fixes: 59f3a8acbcdb ("app/testpmd: add flex item commands")
Cc: stable@dpdk.org

Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 app/test-pmd/testpmd.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 04c39adc21..fe125e40e8 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3202,6 +3202,15 @@ remove_invalid_ports(void)
 	nb_cfg_ports = nb_fwd_ports;
 }
 
+static void
+flush_port_owned_resources(portid_t pi)
+{
+	mcast_addr_pool_destroy(pi);
+	port_flow_flush(pi);
+	port_flex_item_flush(pi);
+	port_action_handle_flush(pi);
+}
+
 void
 close_port(portid_t pid)
 {
@@ -3238,10 +3247,7 @@ close_port(portid_t pid)
 		}
 
 		if (is_proc_primary()) {
-			mcast_addr_pool_destroy(pi);
-			port_flow_flush(pi);
-			port_flex_item_flush(pi);
-			port_action_handle_flush(pi);
+			flush_port_owned_resources(pi);
 			rte_eth_dev_close(pi);
 		}
 
@@ -3386,7 +3392,7 @@ detach_device(struct rte_device *dev)
 					sibling);
 				return;
 			}
-			port_flow_flush(sibling);
+			flush_port_owned_resources(sibling);
 		}
 	}
 
@@ -3453,7 +3459,7 @@ detach_devargs(char *identifier)
 				rte_devargs_reset(&da);
 				return;
 			}
-			port_flow_flush(port_id);
+			flush_port_owned_resources(port_id);
 		}
 	}
 
-- 
2.25.1


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

* Re: [PATCH] app/testpmd: cleanup port resources after implicit close
  2022-06-15 23:12 [PATCH] app/testpmd: cleanup port resources after implicit close Dmitry Kozlyuk
@ 2022-06-23 11:17 ` Andrew Rybchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Rybchenko @ 2022-06-23 11:17 UTC (permalink / raw)
  To: Dmitry Kozlyuk, dev
  Cc: stable, Matan Azrad, Xiaoyun Li, Aman Singh, Yuying Zhang

On 6/16/22 02:12, Dmitry Kozlyuk wrote:
> When a port was closed implicitly closed by the PMD, for example,
> if it was a representor port and its master port was detached,
> flow indirect actions could remain with their handles no longer valid.
> If a newly attached device was assigned the same ID as the closed port,
> those indirect actions became accessible again.
> Any attempt to use them resulted in an undefined behavior.
> Flow flex items had no such issue on close, but had it on detach.
> 
> Introduce flush_port_owned_resources() function
> for consistent cleanup and call it when a port is closed or detached.
> Make it flush flow rules and multicast addresses too
> because they logically belong to the port being removed.
> 
> Fixes: 55509e3a49fb ("app/testpmd: support shared flow action")
> Fixes: 59f3a8acbcdb ("app/testpmd: add flex item commands")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
> Acked-by: Matan Azrad <matan@nvidia.com>

Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>

Resolved merge conflict on apply to dpdk-next-net/main,
applied, thanks.

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

end of thread, other threads:[~2022-06-23 11:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15 23:12 [PATCH] app/testpmd: cleanup port resources after implicit close Dmitry Kozlyuk
2022-06-23 11:17 ` Andrew Rybchenko

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