]> git.droids-corp.org - dpdk.git/commitdiff
app/testpmd: cleanup port resources after implicit close
authorDmitry Kozlyuk <dkozlyuk@nvidia.com>
Wed, 15 Jun 2022 23:12:12 +0000 (02:12 +0300)
committerAndrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Thu, 23 Jun 2022 11:12:50 +0000 (13:12 +0200)
When a port is closed implicitly by the PMD, for example,
if it is a representor port and its master port is detached,
flow indirect actions could remain with their handles no longer valid.
If a newly attached device is 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>
app/test-pmd/testpmd.c

index e6321bdedbd663ec2b1b642a632239090b061f81..addcbcac851e06f50123be1fa1c8973aff16d5c3 100644 (file)
@@ -3206,6 +3206,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);
+}
+
 static void
 clear_bonding_slave_device(portid_t *slave_pids, uint16_t num_slaves)
 {
@@ -3270,10 +3279,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);
 #ifdef RTE_NET_BOND
                        if (port->bond_flag == 1)
                                num_slaves = rte_eth_bond_slaves_get(pi,
@@ -3430,7 +3436,7 @@ detach_device(struct rte_device *dev)
                                        sibling);
                                return;
                        }
-                       port_flow_flush(sibling);
+                       flush_port_owned_resources(sibling);
                }
        }
 
@@ -3497,7 +3503,7 @@ detach_devargs(char *identifier)
                                rte_devargs_reset(&da);
                                return;
                        }
-                       port_flow_flush(port_id);
+                       flush_port_owned_resources(port_id);
                }
        }