patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Suanming Mou <suanmingm@mellanox.com>
To: luca.boccassi@gmail.com
Cc: stable@dpdk.org
Subject: [dpdk-stable] [PATCH 19.11 07/11] net/mlx5: fix layer type in header modify action
Date: Fri, 28 Feb 2020 11:33:51 +0800	[thread overview]
Message-ID: <1582860835-282594-8-git-send-email-suanmingm@mellanox.com> (raw)
In-Reply-To: <1582860835-282594-1-git-send-email-suanmingm@mellanox.com>

[ upstream commit 04233f36c712ea35fe0f1d02c5c6f323a28ec588 ]

Currently, for header modify actions after tunnel decapsulation, the
header modify actions will still select the old outermost layer type.
It will cause header modify actions get the wrong layer type.

Add the tunnel decap flag to indicate the layer type to get for header
modify actions.

Fixes: 4bb14c83df95 ("net/mlx5: support modify header using Direct Verbs")

Signed-off-by: Suanming Mou <suanmingm@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 68 ++++++++++++++++++++++++++++++++++-------
 1 file changed, 57 insertions(+), 11 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 3362873..4df0fc2 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -82,19 +82,55 @@
  *   Pointer to item specification.
  * @param[out] attr
  *   Pointer to flow attributes structure.
+ * @param[in] tunnel_decap
+ *   Whether action is after tunnel decapsulation.
  */
 static void
-flow_dv_attr_init(const struct rte_flow_item *item, union flow_dv_attr *attr)
+flow_dv_attr_init(const struct rte_flow_item *item, union flow_dv_attr *attr,
+		  bool tunnel_decap)
 {
 	for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
+		uint8_t next_protocol = 0xff;
+
 		switch (item->type) {
+		case RTE_FLOW_ITEM_TYPE_GRE:
+		case RTE_FLOW_ITEM_TYPE_NVGRE:
+		case RTE_FLOW_ITEM_TYPE_VXLAN:
+		case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
+		case RTE_FLOW_ITEM_TYPE_GENEVE:
+		case RTE_FLOW_ITEM_TYPE_MPLS:
+			if (tunnel_decap)
+				attr->attr = 0;
+			break;
 		case RTE_FLOW_ITEM_TYPE_IPV4:
 			if (!attr->ipv6)
 				attr->ipv4 = 1;
+			if (item->mask != NULL &&
+			    ((const struct rte_flow_item_ipv4 *)
+			    item->mask)->hdr.next_proto_id)
+				next_protocol =
+				    ((const struct rte_flow_item_ipv4 *)
+				      (item->spec))->hdr.next_proto_id &
+				    ((const struct rte_flow_item_ipv4 *)
+				      (item->mask))->hdr.next_proto_id;
+			if ((next_protocol == IPPROTO_IPIP ||
+			    next_protocol == IPPROTO_IPV6) && tunnel_decap)
+				attr->attr = 0;
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
 			if (!attr->ipv4)
 				attr->ipv6 = 1;
+			if (item->mask != NULL &&
+			    ((const struct rte_flow_item_ipv6 *)
+			    item->mask)->hdr.proto)
+				next_protocol =
+				    ((const struct rte_flow_item_ipv6 *)
+				      (item->spec))->hdr.proto &
+				    ((const struct rte_flow_item_ipv6 *)
+				      (item->mask))->hdr.proto;
+			if ((next_protocol == IPPROTO_IPIP ||
+			    next_protocol == IPPROTO_IPV6) && tunnel_decap)
+				attr->attr = 0;
 			break;
 		case RTE_FLOW_ITEM_TYPE_UDP:
 			if (!attr->tcp)
@@ -599,6 +635,8 @@ struct field_modify_info modify_tcp[] = {
  *   Pointer to rte_flow_item objects list.
  * @param[in] attr
  *   Pointer to flow attributes structure.
+ * @param[in] tunnel_decap
+ *   Whether action is after tunnel decapsulation.
  * @param[out] error
  *   Pointer to the error structure.
  *
@@ -610,7 +648,7 @@ struct field_modify_info modify_tcp[] = {
 			(struct mlx5_flow_dv_modify_hdr_resource *resource,
 			 const struct rte_flow_action *action,
 			 const struct rte_flow_item *items,
-			 union flow_dv_attr *attr,
+			 union flow_dv_attr *attr, bool tunnel_decap,
 			 struct rte_flow_error *error)
 {
 	const struct rte_flow_action_set_tp *conf =
@@ -623,7 +661,7 @@ struct field_modify_info modify_tcp[] = {
 	struct field_modify_info *field;
 
 	if (!attr->valid)
-		flow_dv_attr_init(items, attr);
+		flow_dv_attr_init(items, attr, tunnel_decap);
 	if (attr->udp) {
 		memset(&udp, 0, sizeof(udp));
 		memset(&udp_mask, 0, sizeof(udp_mask));
@@ -673,6 +711,8 @@ struct field_modify_info modify_tcp[] = {
  *   Pointer to rte_flow_item objects list.
  * @param[in] attr
  *   Pointer to flow attributes structure.
+ * @param[in] tunnel_decap
+ *   Whether action is after tunnel decapsulation.
  * @param[out] error
  *   Pointer to the error structure.
  *
@@ -684,7 +724,7 @@ struct field_modify_info modify_tcp[] = {
 			(struct mlx5_flow_dv_modify_hdr_resource *resource,
 			 const struct rte_flow_action *action,
 			 const struct rte_flow_item *items,
-			 union flow_dv_attr *attr,
+			 union flow_dv_attr *attr, bool tunnel_decap,
 			 struct rte_flow_error *error)
 {
 	const struct rte_flow_action_set_ttl *conf =
@@ -697,7 +737,7 @@ struct field_modify_info modify_tcp[] = {
 	struct field_modify_info *field;
 
 	if (!attr->valid)
-		flow_dv_attr_init(items, attr);
+		flow_dv_attr_init(items, attr, tunnel_decap);
 	if (attr->ipv4) {
 		memset(&ipv4, 0, sizeof(ipv4));
 		memset(&ipv4_mask, 0, sizeof(ipv4_mask));
@@ -733,6 +773,8 @@ struct field_modify_info modify_tcp[] = {
  *   Pointer to rte_flow_item objects list.
  * @param[in] attr
  *   Pointer to flow attributes structure.
+ * @param[in] tunnel_decap
+ *   Whether action is after tunnel decapsulation.
  * @param[out] error
  *   Pointer to the error structure.
  *
@@ -743,7 +785,7 @@ struct field_modify_info modify_tcp[] = {
 flow_dv_convert_action_modify_dec_ttl
 			(struct mlx5_flow_dv_modify_hdr_resource *resource,
 			 const struct rte_flow_item *items,
-			 union flow_dv_attr *attr,
+			 union flow_dv_attr *attr, bool tunnel_decap,
 			 struct rte_flow_error *error)
 {
 	struct rte_flow_item item;
@@ -754,7 +796,7 @@ struct field_modify_info modify_tcp[] = {
 	struct field_modify_info *field;
 
 	if (!attr->valid)
-		flow_dv_attr_init(items, attr);
+		flow_dv_attr_init(items, attr, tunnel_decap);
 	if (attr->ipv4) {
 		memset(&ipv4, 0, sizeof(ipv4));
 		memset(&ipv4_mask, 0, sizeof(ipv4_mask));
@@ -7130,7 +7172,8 @@ struct field_modify_info modify_tcp[] = {
 		case RTE_FLOW_ACTION_TYPE_SET_TP_DST:
 			if (flow_dv_convert_action_modify_tp
 					(mhdr_res, actions, items,
-					 &flow_attr, error))
+					 &flow_attr, !!(action_flags &
+					 MLX5_FLOW_ACTION_DECAP), error))
 				return -rte_errno;
 			action_flags |= actions->type ==
 					RTE_FLOW_ACTION_TYPE_SET_TP_SRC ?
@@ -7139,14 +7182,17 @@ struct field_modify_info modify_tcp[] = {
 			break;
 		case RTE_FLOW_ACTION_TYPE_DEC_TTL:
 			if (flow_dv_convert_action_modify_dec_ttl
-					(mhdr_res, items, &flow_attr, error))
+					(mhdr_res, items, &flow_attr,
+					 !!(action_flags &
+					 MLX5_FLOW_ACTION_DECAP), error))
 				return -rte_errno;
 			action_flags |= MLX5_FLOW_ACTION_DEC_TTL;
 			break;
 		case RTE_FLOW_ACTION_TYPE_SET_TTL:
 			if (flow_dv_convert_action_modify_ttl
-					(mhdr_res, actions, items,
-					 &flow_attr, error))
+					(mhdr_res, actions, items, &flow_attr,
+					 !!(action_flags &
+					 MLX5_FLOW_ACTION_DECAP), error))
 				return -rte_errno;
 			action_flags |= MLX5_FLOW_ACTION_SET_TTL;
 			break;
-- 
1.8.3.1


  parent reply	other threads:[~2020-02-28  3:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-28  3:33 [dpdk-stable] [PATCH 19.11 00/11] net/mlx5: fix patch backport Suanming Mou
2020-02-28  3:33 ` [dpdk-stable] [PATCH 19.11 01/11] net/mlx5: unify validation of drop action Suanming Mou
2020-02-28  3:33 ` [dpdk-stable] [PATCH 19.11 02/11] net/mlx5: update description of validation functions Suanming Mou
2020-02-28  3:33 ` [dpdk-stable] [PATCH 19.11 03/11] net/mlx5: support maximum flow id allocation Suanming Mou
2020-02-28  3:33 ` [dpdk-stable] [PATCH 19.11 04/11] net/mlx5: fix register usage in meter Suanming Mou
2020-02-28  3:33 ` [dpdk-stable] [PATCH 19.11 05/11] net/mlx5: fix encap/decap validation Suanming Mou
2020-02-28  3:33 ` [dpdk-stable] [PATCH 19.11 06/11] net/mlx5: fix layer validation with decapsulation Suanming Mou
2020-02-28  3:33 ` Suanming Mou [this message]
2020-02-28  3:33 ` [dpdk-stable] [PATCH 19.11 08/11] net/mlx5: fix layer flags missing in metadata Suanming Mou
2020-02-28  3:33 ` [dpdk-stable] [PATCH 19.11 09/11] net/mlx5: fix match information in meter Suanming Mou
2020-02-28  3:33 ` [dpdk-stable] [PATCH 19.11 10/11] net/mlx5: fix VLAN actions " Suanming Mou
2020-02-28  3:33 ` [dpdk-stable] [PATCH 19.11 11/11] net/mlx5: fix metadata split with encap action Suanming Mou
2020-02-28 11:17 ` [dpdk-stable] [PATCH 19.11 00/11] net/mlx5: fix patch backport Luca Boccassi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1582860835-282594-8-git-send-email-suanmingm@mellanox.com \
    --to=suanmingm@mellanox.com \
    --cc=luca.boccassi@gmail.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).