[dpdk-dev] net/mlx5: fix RSS flow rule with non existing queues

Message ID d7e05e546a151ea46541c9c019b6845ed5e7db89.1491218668.git.nelio.laranjeiro@6wind.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Nélio Laranjeiro April 3, 2017, 11:25 a.m. UTC
  RSS flow rule validation accepts any queue even non existing ones which
causes a segmentation fault at creation time.

Fixes: fb4db56ea074 ("net/mlx5: support RSS action flow rule")

Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Yongseok Koh <yskoh@mellanox.com>

---

To be integrated after DPDK 17.05-rc1

v2: split the patch-set in two distinct patches.
---
 drivers/net/mlx5/mlx5_flow.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
  

Comments

Ferruh Yigit April 3, 2017, 12:47 p.m. UTC | #1
On 4/3/2017 12:25 PM, Nelio Laranjeiro wrote:
> RSS flow rule validation accepts any queue even non existing ones which
> causes a segmentation fault at creation time.
> 
> Fixes: fb4db56ea074 ("net/mlx5: support RSS action flow rule")
> 
> Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
> Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Acked-by: Yongseok Koh <yskoh@mellanox.com>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index b34be55..3691e95 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];