[2/3] net/tap: do not overwrite rte_flow errors
Checks
Commit Message
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: f46900d03823 ("net/tap: fix flow and port commands")
Fixes: de96fe68ae95 ("net/tap: add basic flow API patterns and actions")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/tap/tap_flow.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
@@ -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;
@@ -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",
@@ -1227,7 +1233,7 @@ 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);
@@ -1235,7 +1241,7 @@ priv_flow_process(struct pmd_internals *pmd,
goto exit_action_not_supported;
}
if (err)
- goto exit_action_not_supported;
+ goto exit_return_error;
}
/* When fate is unknown, drop traffic. */
if (!action) {
@@ -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;
}