patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Bing Zhao <bingz@nvidia.com>
To: <viacheslavo@nvidia.com>, <matan@nvidia.com>
Cc: <dev@dpdk.org>, <rasland@nvidia.com>, <stable@dpdk.org>
Subject: [dpdk-stable] [PATCH v2] net/mlx5: fix the RSS consistency check of meter policy
Date: Mon, 18 Oct 2021 17:43:07 +0300	[thread overview]
Message-ID: <20211018144307.148246-1-bingz@nvidia.com> (raw)
In-Reply-To: <20211018131612.145215-1-bingz@nvidia.com>

After yellow color actions in the metering policy were supported,
the RSS could be used for both green and yellow colors and only the
queues attribute could be different.

When specifying the attributes of a RSS, some fields can be ignored
and some default values will be used in PMD. For example, there is a
default RSS key in the PMD and it will be used to create the TIR if
nothing is provided by the application.

The default value cases were missed in the current implementation
and it would cause some false positives or crashes.

The comparison function should be adjusted to take all cases into
consideration when RSS is used for both green and yellow colors.

Fixes: 4b7bf3ffb473 ("net/mlx5: support yellow in meter policy validation")
Cc: stable@dpdk.org

Signed-off-by: Bing Zhao <bingz@nvidia.com>
---
v2: remove unnecessary parenthesis
---
 drivers/net/mlx5/mlx5_flow_dv.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 609ab43fb6..94b70bd10a 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -17412,12 +17412,22 @@ static inline int
 flow_dv_mtr_policy_rss_compare(const struct rte_flow_action_rss *r1,
 			       const struct rte_flow_action_rss *r2)
 {
-	if (!r1 || !r2)
+	if (r1 == NULL || r2 == NULL)
 		return 0;
-	if (r1->func != r2->func || r1->level != r2->level ||
-	    r1->types != r2->types || r1->key_len != r2->key_len ||
-	    memcmp(r1->key, r2->key, r1->key_len))
+	if (!(r1->level <= 1 && r2->level <= 1) &&
+	    !(r1->level > 1 && r2->level > 1))
 		return 1;
+	if (r1->types != r2->types &&
+	    !((r1->types == 0 || r1->types == ETH_RSS_IP) &&
+	      (r2->types == 0 || r2->types == ETH_RSS_IP)))
+		return 1;
+	if (r1->key || r2->key) {
+		const void *key1 = r1->key ? r1->key : rss_hash_default_key;
+		const void *key2 = r2->key ? r2->key : rss_hash_default_key;
+
+		if (memcmp(key1, key2, MLX5_RSS_HASH_KEY_LEN))
+			return 1;
+	}
 	return 0;
 }
 
-- 
2.27.0


  reply	other threads:[~2021-10-18 14:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18 13:16 [dpdk-stable] [PATCH] " Bing Zhao
2021-10-18 14:43 ` Bing Zhao [this message]
2021-11-04  8:56   ` [dpdk-stable] [PATCH v2] " Matan Azrad
2021-11-09  9:57   ` Raslan Darawsheh
2021-11-10 16:16   ` [dpdk-dev] " Ferruh Yigit
2021-10-20 19:35 ` [dpdk-stable] [PATCH] " Raslan Darawsheh

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=20211018144307.148246-1-bingz@nvidia.com \
    --to=bingz@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=stable@dpdk.org \
    --cc=viacheslavo@nvidia.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).