patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Dekel Peled <dekelp@mellanox.com>
To: matan@mellanox.com, viacheslavo@mellanox.com, rasland@mellanox.com
Cc: dev@dpdk.org, stable@dpdk.org
Subject: [dpdk-stable] [PATCH] ethdev: fix RSS flow expansion in case of mismatch
Date: Mon, 27 Jul 2020 15:57:40 +0300	[thread overview]
Message-ID: <c1c305615ed5d286a885b554c8c821f0adffacef.1595854661.git.dekelp@mellanox.com> (raw)

Function rte_flow_expand_rss() is used to expand a flow rule with
partial pattern into several rules, to ensure all relevant packets
are matched.
It uses utility function rte_flow_expand_rss_item_complete(), to check
if the last valid item in the flow rule pattern needs to be completed.
For example the pattern "eth / ipv4 proto is 17 / end" will be completed
with a "udp" item.
This function returns "void" item in two cases:
1) The last item has empty spec, for example "eth / ipv4 / end".
2) The last itme has spec that can't be expanded for RSS.
   For example the pattern "eth / ipv4 proto is 47 / end" ends with IPv4
   item that has next protocol GRE.

In both cases the flow rule may be expanded, but in the second case such
expansion may create rules with invalid pattern.
For example "eth / ipv4 proto is 47 / udp / end".
In such a case the flow rule should not be expanded.

This patch updates function rte_flow_expand_rss_item_complete().
Return value RTE_FLOW_ITEM_TYPE_END is used to indicate the flow rule
should not be expanded.
In such a case, rte_flow_expand_rss() will return with the original flow
rule only, without any expansion.

Fixes: fc2dd8dd492f ("ethdev: fix expand RSS flows")
Cc: stable@dpdk.org

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Xiaoyu Min <jackmin@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
---
 lib/librte_ethdev/rte_flow.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index f8fdd68..59a386d 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -247,6 +247,8 @@ struct rte_flow_desc_data {
 			ret = RTE_FLOW_ITEM_TYPE_IPV6;
 		else if (rte_be_to_cpu_16(ether_type) == RTE_ETHER_TYPE_VLAN)
 			ret = RTE_FLOW_ITEM_TYPE_VLAN;
+		else
+			ret = RTE_FLOW_ITEM_TYPE_END;
 		break;
 	case RTE_FLOW_ITEM_TYPE_VLAN:
 		if (item->mask)
@@ -264,6 +266,8 @@ struct rte_flow_desc_data {
 			ret = RTE_FLOW_ITEM_TYPE_IPV6;
 		else if (rte_be_to_cpu_16(ether_type) == RTE_ETHER_TYPE_VLAN)
 			ret = RTE_FLOW_ITEM_TYPE_VLAN;
+		else
+			ret = RTE_FLOW_ITEM_TYPE_END;
 		break;
 	case RTE_FLOW_ITEM_TYPE_IPV4:
 		if (item->mask)
@@ -284,6 +288,8 @@ struct rte_flow_desc_data {
 			ret = RTE_FLOW_ITEM_TYPE_IPV4;
 		else if (ip_next_proto == IPPROTO_IPV6)
 			ret = RTE_FLOW_ITEM_TYPE_IPV6;
+		else
+			ret = RTE_FLOW_ITEM_TYPE_END;
 		break;
 	case RTE_FLOW_ITEM_TYPE_IPV6:
 		if (item->mask)
@@ -304,6 +310,8 @@ struct rte_flow_desc_data {
 			ret = RTE_FLOW_ITEM_TYPE_IPV4;
 		else if (ip_next_proto == IPPROTO_IPV6)
 			ret = RTE_FLOW_ITEM_TYPE_IPV6;
+		else
+			ret = RTE_FLOW_ITEM_TYPE_END;
 		break;
 	default:
 		ret = RTE_FLOW_ITEM_TYPE_VOID;
@@ -1110,10 +1118,14 @@ enum rte_flow_conv_item_spec_type {
 	memset(flow_items, 0, sizeof(flow_items));
 	user_pattern_size -= sizeof(*item);
 	/*
-	 * Check if the last valid item has spec set
-	 * and need complete pattern.
+	 * Check if the last valid item has spec set, need complete pattern,
+	 * and the pattern can be used for expansion.
 	 */
 	missed_item.type = rte_flow_expand_rss_item_complete(last_item);
+	if (missed_item.type == RTE_FLOW_ITEM_TYPE_END) {
+		/* Item type END indicates expansion is not required. */
+		return lsize;
+	}
 	if (missed_item.type != RTE_FLOW_ITEM_TYPE_VOID) {
 		next = NULL;
 		missed = 1;
-- 
1.8.3.1


             reply	other threads:[~2020-07-27 12:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-27 12:57 Dekel Peled [this message]
2020-07-27 13:25 ` Dekel Peled
2020-07-27 16:21   ` Ori Kam
2020-07-28  9:14     ` Dekel Peled
2020-08-17  8:16       ` Ori Kam
2020-09-02 17:09 ` [dpdk-stable] [dpdk-dev] " Ferruh Yigit
     [not found] ` <cover.1600958661.git.dekelp@nvidia.com>
2020-09-24 14:52   ` [dpdk-stable] [PATCH v2 1/2] " Dekel Peled

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=c1c305615ed5d286a885b554c8c821f0adffacef.1595854661.git.dekelp@mellanox.com \
    --to=dekelp@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=matan@mellanox.com \
    --cc=rasland@mellanox.com \
    --cc=stable@dpdk.org \
    --cc=viacheslavo@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).