Skip to content

Commit

Permalink
app/testpmd: fix use of indirect action after port close
Browse files Browse the repository at this point in the history
[ upstream commit f7352c1 ]

When a port was closed, 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.
Automatically flush indirect actions when a port is closed.

Fixes: 4b61b87 ("ethdev: introduce indirect flow action")

Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
Acked-by: Aman Singh <aman.deep.singh@intel.com>
  • Loading branch information
dkozlyuk authored and kevintraynor committed Jun 8, 2022
1 parent 79dd420 commit 057ebd4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
31 changes: 31 additions & 0 deletions app/test-pmd/config.c
Expand Up @@ -1757,6 +1757,37 @@ port_action_handle_destroy(portid_t port_id,
return ret;
}

int
port_action_handle_flush(portid_t port_id)
{
struct rte_port *port;
struct port_indirect_action **tmp;
int ret = 0;

if (port_id_is_invalid(port_id, ENABLED_WARN) ||
port_id == (portid_t)RTE_PORT_ALL)
return -EINVAL;
port = &ports[port_id];
tmp = &port->actions_list;
while (*tmp != NULL) {
struct rte_flow_error error;
struct port_indirect_action *pia = *tmp;

/* Poisoning to make sure PMDs update it in case of error. */
memset(&error, 0x44, sizeof(error));
if (pia->handle != NULL &&
rte_flow_action_handle_destroy
(port_id, pia->handle, &error) != 0) {
printf("Indirect action #%u not destroyed\n", pia->id);
ret = port_flow_complain(&error);
tmp = &pia->next;
} else {
*tmp = pia->next;
free(pia);
}
}
return ret;
}

/** Get indirect action by port + id */
struct rte_flow_action_handle *
Expand Down
1 change: 1 addition & 0 deletions app/test-pmd/testpmd.c
Expand Up @@ -3217,6 +3217,7 @@ close_port(portid_t pid)
if (is_proc_primary()) {
port_flow_flush(pi);
port_flex_item_flush(pi);
port_action_handle_flush(pi);
rte_eth_dev_close(pi);
}

Expand Down
1 change: 1 addition & 0 deletions app/test-pmd/testpmd.h
Expand Up @@ -884,6 +884,7 @@ int port_action_handle_create(portid_t port_id, uint32_t id,
const struct rte_flow_action *action);
int port_action_handle_destroy(portid_t port_id,
uint32_t n, const uint32_t *action);
int port_action_handle_flush(portid_t port_id);
struct rte_flow_action_handle *port_action_handle_get_by_id(portid_t port_id,
uint32_t id);
int port_action_handle_update(portid_t port_id, uint32_t id,
Expand Down

0 comments on commit 057ebd4

Please sign in to comment.