Skip to content

Commit

Permalink
net/tap: do not overwrite flow API errors
Browse files Browse the repository at this point in the history
[ upstream commit 11b90b53c6716ca9bc713bab6cfba039fe8e38cb ]

All flow errors were ending up being reported as not supported,
even when the error path was previously setting a valid and
better error message.

Example, asking for a non-existent queue in flow.

Before:
testpmd> flow create 0 ingress pattern eth src is 06:05:04:03:02:01 \
  / end actions queue index 12 / end
port_flow_complain(): Caught PMD error type 16 (specific action):
cause: 0x7fffc46c1e18, action not supported: Operation not supported

After:
testpmd> flow create 0 ingress pattern eth src is 06:05:04:03:02:01 \
  / end actions queue index 12 / end
port_flow_complain(): Caught PMD error type 16 (specific action):
cause: 0x7fffa54e1d88, queue index out of range: Numerical result
       out of range

Fixes: f46900d ("net/tap: fix flow and port commands")
Fixes: de96fe6 ("net/tap: add basic flow API patterns and actions")

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
  • Loading branch information
shemminger authored and bluca committed Mar 13, 2024
1 parent 1b8a6de commit 337a1fa
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions drivers/net/tap/tap_flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -1082,8 +1082,11 @@ priv_flow_process(struct pmd_internals *pmd,
}
/* use flower filter type */
tap_nlattr_add(&flow->msg.nh, TCA_KIND, sizeof("flower"), "flower");
if (tap_nlattr_nested_start(&flow->msg, TCA_OPTIONS) < 0)
goto exit_item_not_supported;
if (tap_nlattr_nested_start(&flow->msg, TCA_OPTIONS) < 0) {
rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_ACTION,
actions, "could not allocated netlink msg");
goto exit_return_error;
}
}
for (; items->type != RTE_FLOW_ITEM_TYPE_END; ++items) {
const struct tap_flow_items *token = NULL;
Expand Down Expand Up @@ -1199,9 +1202,12 @@ priv_flow_process(struct pmd_internals *pmd,
if (action)
goto exit_action_not_supported;
action = 1;
if (!queue ||
(queue->index > pmd->dev->data->nb_rx_queues - 1))
goto exit_action_not_supported;
if (queue->index >= pmd->dev->data->nb_rx_queues) {
rte_flow_error_set(error, ERANGE,
RTE_FLOW_ERROR_TYPE_ACTION, actions,
"queue index out of range");
goto exit_return_error;
}
if (flow) {
struct action_data adata = {
.id = "skbedit",
Expand All @@ -1227,15 +1233,15 @@ priv_flow_process(struct pmd_internals *pmd,
if (!pmd->rss_enabled) {
err = rss_enable(pmd, attr, error);
if (err)
goto exit_action_not_supported;
goto exit_return_error;
}
if (flow)
err = rss_add_actions(flow, pmd, rss, error);
} else {
goto exit_action_not_supported;
}
if (err)
goto exit_action_not_supported;
goto exit_return_error;
}
/* When fate is unknown, drop traffic. */
if (!action) {
Expand All @@ -1258,6 +1264,7 @@ priv_flow_process(struct pmd_internals *pmd,
exit_action_not_supported:
rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION,
actions, "action not supported");
exit_return_error:
return -rte_errno;
}

Expand Down

0 comments on commit 337a1fa

Please sign in to comment.