From 246855f9ad1fbe1db4097dd3a8421250040a2be8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?N=C3=A9lio=20Laranjeiro?= Date: Mon, 3 Apr 2017 13:25:15 +0200 Subject: [PATCH] net/mlx5: fix RSS flow rule with non existing queues RSS flow rule validation accepts any queue even non existing ones which causes a segmentation fault at creation time. Fixes: 3d821d6fea40 ("net/mlx5: support RSS action flow rule") Signed-off-by: Nelio Laranjeiro Acked-by: Adrien Mazarguil Acked-by: Yongseok Koh --- drivers/net/mlx5/mlx5_flow.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index b34be556eb..3691e95e09 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -488,16 +488,18 @@ priv_flow_validate(struct priv *priv, break; } } - if (action->queues_n && !found) { + if (action->queues_n > 1 && !found) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, actions, "queue action not in RSS queues"); return -rte_errno; } - action->queue = 1; - action->queues_n = 1; - action->queues[0] = queue->index; + if (!found) { + action->queue = 1; + action->queues_n = 1; + action->queues[0] = queue->index; + } } else if (actions->type == RTE_FLOW_ACTION_TYPE_RSS) { const struct rte_flow_action_rss *rss = (const struct rte_flow_action_rss *) @@ -524,6 +526,16 @@ priv_flow_validate(struct priv *priv, return -rte_errno; } } + for (n = 0; n < rss->num; ++n) { + if (rss->queue[n] >= priv->rxqs_n) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "queue id > number of" + " queues"); + return -rte_errno; + } + } action->queue = 1; for (n = 0; n < rss->num; ++n) action->queues[n] = rss->queue[n]; -- 2.20.1