[2/3] net/ice: fix flow action validation

Message ID 1563413923-404004-3-git-send-email-ying.a.wang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Qi Zhang
Headers
Series [1/3] net/ice: fix flow get inputset check |

Checks

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

Commit Message

Ying Wang July 18, 2019, 1:38 a.m. UTC
  Action is a list. We should check each element of the action
rather than the first one.
This patch fixes this issue.

Fixes: d76116a4678f ("net/ice: add generic flow API")
Cc: stable@dpdk.org

Signed-off-by: Wang Ying A <ying.a.wang@intel.com>
---
 drivers/net/ice/ice_generic_flow.c | 39 ++++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 18 deletions(-)
  

Comments

Qiming Yang July 18, 2019, 2:40 a.m. UTC | #1
Hi, Ying
For the action check reorganization, please according to Beilei's comments, use array  to stand the action element list.
And as we discussed before, it's better to change in the next release.

Qiming
-----Original Message-----
From: Wang, Ying A 
Sent: Thursday, July 18, 2019 9:39 AM
To: Zhang, Qi Z <qi.z.zhang@intel.com>
Cc: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org; Wang, Ying A <ying.a.wang@intel.com>; stable@dpdk.org
Subject: [PATCH 2/3] net/ice: fix flow action validation

Action is a list. We should check each element of the action rather than the first one.
This patch fixes this issue.

Fixes: d76116a4678f ("net/ice: add generic flow API")
Cc: stable@dpdk.org

Signed-off-by: Wang Ying A <ying.a.wang@intel.com>
---
 drivers/net/ice/ice_generic_flow.c | 39 ++++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c
index 464f6ec..2c57276 100644
--- a/drivers/net/ice/ice_generic_flow.c
+++ b/drivers/net/ice/ice_generic_flow.c
@@ -517,28 +517,31 @@ static int ice_flow_valid_action(struct rte_eth_dev *dev,  {
 	const struct rte_flow_action_queue *act_q;
 	uint16_t queue;
-
-	switch (actions->type) {
-	case RTE_FLOW_ACTION_TYPE_QUEUE:
-		act_q = actions->conf;
-		queue = act_q->index;
-		if (queue >= dev->data->nb_rx_queues) {
+	const struct rte_flow_action *action;
+	for (action = actions; action->type !=
+			RTE_FLOW_ACTION_TYPE_END; action++) {
+		switch (action->type) {
+		case RTE_FLOW_ACTION_TYPE_QUEUE:
+			act_q = action->conf;
+			queue = act_q->index;
+			if (queue >= dev->data->nb_rx_queues) {
+				rte_flow_error_set(error, EINVAL,
+						RTE_FLOW_ERROR_TYPE_ACTION,
+						actions, "Invalid queue ID for"
+						" switch filter.");
+				return -rte_errno;
+			}
+			break;
+		case RTE_FLOW_ACTION_TYPE_DROP:
+		case RTE_FLOW_ACTION_TYPE_VOID:
+			break;
+		default:
 			rte_flow_error_set(error, EINVAL,
-					   RTE_FLOW_ERROR_TYPE_ACTION,
-					   actions, "Invalid queue ID for"
-					   " switch filter.");
+					   RTE_FLOW_ERROR_TYPE_ACTION, actions,
+					   "Invalid action.");
 			return -rte_errno;
 		}
-		break;
-	case RTE_FLOW_ACTION_TYPE_DROP:
-		break;
-	default:
-		rte_flow_error_set(error, EINVAL,
-				   RTE_FLOW_ERROR_TYPE_ACTION, actions,
-				   "Invalid action.");
-		return -rte_errno;
 	}
-
 	return 0;
 }
 
--
1.8.3.1
  
Qiming Yang July 18, 2019, 3:06 a.m. UTC | #2
-----Original Message-----
From: Wang, Ying A 
Sent: Thursday, July 18, 2019 9:39 AM
To: Zhang, Qi Z <qi.z.zhang@intel.com>
Cc: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org; Wang, Ying A <ying.a.wang@intel.com>; stable@dpdk.org
Subject: [PATCH 2/3] net/ice: fix flow action validation

Action is a list. We should check each element of the action rather than the first one.
This patch fixes this issue.

Fixes: d76116a4678f ("net/ice: add generic flow API")
Cc: stable@dpdk.org

Signed-off-by: Wang Ying A <ying.a.wang@intel.com>
---
 drivers/net/ice/ice_generic_flow.c | 39 ++++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c
index 464f6ec..2c57276 100644
--- a/drivers/net/ice/ice_generic_flow.c
+++ b/drivers/net/ice/ice_generic_flow.c
@@ -517,28 +517,31 @@ static int ice_flow_valid_action(struct rte_eth_dev *dev,  {
 	const struct rte_flow_action_queue *act_q;
 	uint16_t queue;
-
-	switch (actions->type) {
-	case RTE_FLOW_ACTION_TYPE_QUEUE:
-		act_q = actions->conf;
-		queue = act_q->index;
-		if (queue >= dev->data->nb_rx_queues) {
+	const struct rte_flow_action *action;
+	for (action = actions; action->type !=
+			RTE_FLOW_ACTION_TYPE_END; action++) {
+		switch (action->type) {
+		case RTE_FLOW_ACTION_TYPE_QUEUE:
+			act_q = action->conf;
+			queue = act_q->index;
+			if (queue >= dev->data->nb_rx_queues) {
+				rte_flow_error_set(error, EINVAL,
+						RTE_FLOW_ERROR_TYPE_ACTION,
+						actions, "Invalid queue ID for"
+						" switch filter.");
+				return -rte_errno;
+			}
+			break;
+		case RTE_FLOW_ACTION_TYPE_DROP:
+		case RTE_FLOW_ACTION_TYPE_VOID:
+			break;
+		default:
 			rte_flow_error_set(error, EINVAL,
-					   RTE_FLOW_ERROR_TYPE_ACTION,
-					   actions, "Invalid queue ID for"
-					   " switch filter.");
+					   RTE_FLOW_ERROR_TYPE_ACTION, actions,
+					   "Invalid action.");
 			return -rte_errno;
 		}
-		break;
-	case RTE_FLOW_ACTION_TYPE_DROP:
-		break;
-	default:
-		rte_flow_error_set(error, EINVAL,
-				   RTE_FLOW_ERROR_TYPE_ACTION, actions,
-				   "Invalid action.");
-		return -rte_errno;
 	}
-
 	return 0;
 }
 
--
1.8.3.1

Acked-by: Qiming Yang <qiming.yang@intel.com>
  
Xiaolong Ye July 18, 2019, 9:08 a.m. UTC | #3
On 07/18, Wang Ying A wrote:
>Action is a list. We should check each element of the action
>rather than the first one.
>This patch fixes this issue.
>
>Fixes: d76116a4678f ("net/ice: add generic flow API")
>Cc: stable@dpdk.org
>
>Signed-off-by: Wang Ying A <ying.a.wang@intel.com>
>---
> drivers/net/ice/ice_generic_flow.c | 39 ++++++++++++++++++++------------------
> 1 file changed, 21 insertions(+), 18 deletions(-)
>
>diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c
>index 464f6ec..2c57276 100644
>--- a/drivers/net/ice/ice_generic_flow.c
>+++ b/drivers/net/ice/ice_generic_flow.c
>@@ -517,28 +517,31 @@ static int ice_flow_valid_action(struct rte_eth_dev *dev,
> {
> 	const struct rte_flow_action_queue *act_q;
> 	uint16_t queue;
>-
>-	switch (actions->type) {
>-	case RTE_FLOW_ACTION_TYPE_QUEUE:
>-		act_q = actions->conf;
>-		queue = act_q->index;
>-		if (queue >= dev->data->nb_rx_queues) {
>+	const struct rte_flow_action *action;
>+	for (action = actions; action->type !=
>+			RTE_FLOW_ACTION_TYPE_END; action++) {
>+		switch (action->type) {
>+		case RTE_FLOW_ACTION_TYPE_QUEUE:
>+			act_q = action->conf;
>+			queue = act_q->index;
>+			if (queue >= dev->data->nb_rx_queues) {
>+				rte_flow_error_set(error, EINVAL,
>+						RTE_FLOW_ERROR_TYPE_ACTION,
>+						actions, "Invalid queue ID for"
>+						" switch filter.");
>+				return -rte_errno;
>+			}
>+			break;
>+		case RTE_FLOW_ACTION_TYPE_DROP:
>+		case RTE_FLOW_ACTION_TYPE_VOID:
>+			break;
>+		default:
> 			rte_flow_error_set(error, EINVAL,
>-					   RTE_FLOW_ERROR_TYPE_ACTION,
>-					   actions, "Invalid queue ID for"
>-					   " switch filter.");
>+					   RTE_FLOW_ERROR_TYPE_ACTION, actions,
>+					   "Invalid action.");
> 			return -rte_errno;
> 		}
>-		break;
>-	case RTE_FLOW_ACTION_TYPE_DROP:
>-		break;
>-	default:
>-		rte_flow_error_set(error, EINVAL,
>-				   RTE_FLOW_ERROR_TYPE_ACTION, actions,
>-				   "Invalid action.");
>-		return -rte_errno;
> 	}
>-
> 	return 0;
> }
> 
>-- 
>1.8.3.1
>

Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
  
Qi Zhang July 19, 2019, 12:34 a.m. UTC | #4
> -----Original Message-----
> From: Yang, Qiming
> Sent: Thursday, July 18, 2019 11:07 AM
> To: Wang, Ying A <ying.a.wang@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>
> Cc: dev@dpdk.org; stable@dpdk.org
> Subject: RE: [PATCH 2/3] net/ice: fix flow action validation
> 
> 
> 
> -----Original Message-----
> From: Wang, Ying A
> Sent: Thursday, July 18, 2019 9:39 AM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>
> Cc: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org; Wang, Ying A
> <ying.a.wang@intel.com>; stable@dpdk.org
> Subject: [PATCH 2/3] net/ice: fix flow action validation
> 
> Action is a list. We should check each element of the action rather than the
> first one.
> This patch fixes this issue.
> 
> Fixes: d76116a4678f ("net/ice: add generic flow API")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Wang Ying A <ying.a.wang@intel.com>
> ---
> Acked-by: Qiming Yang <qiming.yang@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi
  

Patch

diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c
index 464f6ec..2c57276 100644
--- a/drivers/net/ice/ice_generic_flow.c
+++ b/drivers/net/ice/ice_generic_flow.c
@@ -517,28 +517,31 @@  static int ice_flow_valid_action(struct rte_eth_dev *dev,
 {
 	const struct rte_flow_action_queue *act_q;
 	uint16_t queue;
-
-	switch (actions->type) {
-	case RTE_FLOW_ACTION_TYPE_QUEUE:
-		act_q = actions->conf;
-		queue = act_q->index;
-		if (queue >= dev->data->nb_rx_queues) {
+	const struct rte_flow_action *action;
+	for (action = actions; action->type !=
+			RTE_FLOW_ACTION_TYPE_END; action++) {
+		switch (action->type) {
+		case RTE_FLOW_ACTION_TYPE_QUEUE:
+			act_q = action->conf;
+			queue = act_q->index;
+			if (queue >= dev->data->nb_rx_queues) {
+				rte_flow_error_set(error, EINVAL,
+						RTE_FLOW_ERROR_TYPE_ACTION,
+						actions, "Invalid queue ID for"
+						" switch filter.");
+				return -rte_errno;
+			}
+			break;
+		case RTE_FLOW_ACTION_TYPE_DROP:
+		case RTE_FLOW_ACTION_TYPE_VOID:
+			break;
+		default:
 			rte_flow_error_set(error, EINVAL,
-					   RTE_FLOW_ERROR_TYPE_ACTION,
-					   actions, "Invalid queue ID for"
-					   " switch filter.");
+					   RTE_FLOW_ERROR_TYPE_ACTION, actions,
+					   "Invalid action.");
 			return -rte_errno;
 		}
-		break;
-	case RTE_FLOW_ACTION_TYPE_DROP:
-		break;
-	default:
-		rte_flow_error_set(error, EINVAL,
-				   RTE_FLOW_ERROR_TYPE_ACTION, actions,
-				   "Invalid action.");
-		return -rte_errno;
 	}
-
 	return 0;
 }