DPDK patches and discussions
 help / color / mirror / Atom feed
From: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
To: dev@dpdk.org
Cc: shahafs@mellanox.com
Subject: [dpdk-dev] [PATCH] net/mlx5: fix ETH and VLAN items for E-Switch flows
Date: Fri, 25 Jan 2019 15:17:30 +0000	[thread overview]
Message-ID: <1548429450-27678-1-git-send-email-viacheslavo@mellanox.com> (raw)

This patch fixes two issues for E-Switch Flows

- RTE_FLOW_ITEM_TYPE_ETH and RTE_FLOW_ITEM_TYPE_VLAN with NULL
in spec field caused the asserts in debug version and segfault
in release, fixed, now empty items are allowed and treated in
correctl way

- empty RTE_FLOW_ITEM_TYPE_VLAN now sets the ethernet type to
ETH_P_802.1Q, in previous version empty VLAN item was ignored

Fixes: 3d14ad9be30e ("net/mlx5: support ethernet type for tunnels on E-Switch")

Signed-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow_tcf.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flow_tcf.c
index b8204df..916d3a0 100644
--- a/drivers/net/mlx5/mlx5_flow_tcf.c
+++ b/drivers/net/mlx5/mlx5_flow_tcf.c
@@ -2052,7 +2052,8 @@ struct pedit_parser {
 					 mask.eth,
 					 "no support for partial mask on"
 					 " \"type\" field");
-			assert(items->spec);
+			if (!items->spec)
+				break;
 			spec.eth = items->spec;
 			if (mask.eth->type &&
 			    (item_flags & MLX5_FLOW_LAYER_TUNNEL) &&
@@ -2123,7 +2124,8 @@ struct pedit_parser {
 					 "outer eth_type conflict,"
 					 " must be 802.1Q");
 			outer_etype = RTE_BE16(ETH_P_8021Q);
-			assert(items->spec);
+			if (!items->spec)
+				break;
 			spec.vlan = items->spec;
 			if (mask.vlan->inner_type &&
 			    vlan_etype != RTE_BE16(ETH_P_ALL) &&
@@ -2520,10 +2522,14 @@ struct pedit_parser {
 		case RTE_FLOW_ITEM_TYPE_PORT_ID:
 			break;
 		case RTE_FLOW_ITEM_TYPE_ETH:
+			if (!items->spec)
+				break;
 			size += SZ_NLATTR_DATA_OF(ETHER_ADDR_LEN) * 4;
 				/* dst/src MAC addr and mask. */
 			break;
 		case RTE_FLOW_ITEM_TYPE_VLAN:
+			if (!items->spec)
+				break;
 			size +=	SZ_NLATTR_TYPE_OF(uint16_t) +
 				/* VLAN Ether type. */
 				SZ_NLATTR_TYPE_OF(uint8_t) + /* VLAN prio. */
@@ -3319,6 +3325,8 @@ struct pedit_parser {
 			assert(mask.eth);
 			if (mask.eth == &flow_tcf_mask_empty.eth)
 				break;
+			if (!items->spec)
+				break;
 			spec.eth = items->spec;
 			if (mask.eth->type) {
 				if (item_flags & MLX5_FLOW_LAYER_TUNNEL)
@@ -3363,12 +3371,13 @@ struct pedit_parser {
 				 sizeof(flow_tcf_mask_supported.vlan),
 				 error);
 			assert(mask.vlan);
-			if (mask.vlan == &flow_tcf_mask_empty.vlan)
-				break;
-			spec.vlan = items->spec;
 			assert(outer_etype == RTE_BE16(ETH_P_ALL) ||
 			       outer_etype == RTE_BE16(ETH_P_8021Q));
 			outer_etype = RTE_BE16(ETH_P_8021Q);
+			if (mask.vlan == &flow_tcf_mask_empty.vlan)
+				break;
+			assert(items->spec);
+			spec.vlan = items->spec;
 			if (mask.vlan->inner_type)
 				vlan_etype = spec.vlan->inner_type;
 			if (mask.vlan->tci & RTE_BE16(0xe000))
-- 
1.8.3.1

             reply	other threads:[~2019-01-25 15:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-25 15:17 Viacheslav Ovsiienko [this message]
2019-01-27 11:19 ` Shahaf Shuler

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=1548429450-27678-1-git-send-email-viacheslavo@mellanox.com \
    --to=viacheslavo@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=shahafs@mellanox.com \
    /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).