From: Dongdong Liu <liudongdong3@huawei.com>
To: <dev@dpdk.org>, <ferruh.yigit@amd.com>, <thomas@monjalon.net>,
<andrew.rybchenko@oktetlabs.ru>
Cc: <stable@dpdk.org>, <yisen.zhuang@huawei.com>,
<liudongdong3@huawei.com>, <lihuisong@huawei.com>
Subject: [PATCH V2 10/10] net/hns3: fix incorrect check for duplicate RSS rule
Date: Mon, 30 Jan 2023 17:31:29 +0800 [thread overview]
Message-ID: <20230130093129.18529-11-liudongdong3@huawei.com> (raw)
In-Reply-To: <20230130093129.18529-1-liudongdong3@huawei.com>
From: Huisong Li <lihuisong@huawei.com>
Currently, the interface for verifying duplicate RSS rules has
some problems:
1) If the value of 'func' in configuring RSS rule is default
value, this rule is mistakenly considered as a duplicate rule.
2) If key length is zero or 'key' is NULL in configuring RSS rule
this rule is also mistakenly considered as a duplicate rule.
3) If 'key' or 'queue' in struct rte_flow_action_rss being NULL
is used to memcpy, which may cause segment fault.
Fixes: c37ca66f2b27 ("net/hns3: support RSS")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_flow.c | 63 +++++++++++++++++++++++++++---------
1 file changed, 47 insertions(+), 16 deletions(-)
diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index 307aba75a7..8ff9d4ae66 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -1272,28 +1272,59 @@ hns3_filterlist_flush(struct rte_eth_dev *dev)
}
}
+static bool
+hns3_flow_rule_key_same(const struct rte_flow_action_rss *comp,
+ const struct rte_flow_action_rss *with)
+{
+ if (comp->key_len != with->key_len)
+ return false;
+
+ if (with->key_len == 0)
+ return true;
+
+ if (comp->key == NULL && with->key == NULL)
+ return true;
+
+ if (!(comp->key != NULL && with->key != NULL))
+ return false;
+
+ return !memcmp(comp->key, with->key, with->key_len);
+}
+
+static bool
+hns3_flow_rule_queues_same(const struct rte_flow_action_rss *comp,
+ const struct rte_flow_action_rss *with)
+{
+ if (comp->queue_num != with->queue_num)
+ return false;
+
+ if (with->queue_num == 0)
+ return true;
+
+ if (comp->queue == NULL && with->queue == NULL)
+ return true;
+
+ if (!(comp->queue != NULL && with->queue != NULL))
+ return false;
+
+ return !memcmp(comp->queue, with->queue, with->queue_num);
+}
+
static bool
hns3_action_rss_same(const struct rte_flow_action_rss *comp,
const struct rte_flow_action_rss *with)
{
- bool rss_key_is_same;
- bool func_is_same;
+ bool same_level;
+ bool same_types;
+ bool same_func;
- func_is_same = (with->func != RTE_ETH_HASH_FUNCTION_DEFAULT) ?
- (comp->func == with->func) : true;
+ same_level = (comp->level == with->level);
+ same_types = (comp->types == with->types);
+ same_func = (comp->func == with->func);
- if (with->key_len == 0 || with->key == NULL)
- rss_key_is_same = 1;
- else
- rss_key_is_same = comp->key_len == with->key_len &&
- !memcmp(comp->key, with->key, with->key_len);
-
- return (func_is_same && rss_key_is_same &&
- comp->types == with->types &&
- comp->level == with->level &&
- comp->queue_num == with->queue_num &&
- !memcmp(comp->queue, with->queue,
- sizeof(*with->queue) * with->queue_num));
+ return same_level && same_types && same_func &&
+ hns3_flow_rule_key_same(comp, with) &&
+ hns3_flow_rule_queues_same(comp, with);
}
static bool
--
2.22.0
next prev parent reply other threads:[~2023-01-30 9:33 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-29 10:51 [PATCH 00/10] net/hns3: some bugfixes for rss Dongdong Liu
2023-01-29 10:51 ` [PATCH 01/10] net/hns3: fix error log about indirection table size Dongdong Liu
2023-01-29 10:51 ` [PATCH 02/10] net/hns3: extract common API to query device Dongdong Liu
2023-01-29 10:51 ` [PATCH 03/10] net/hns3: refactor set RSS hash algorithm and key interface Dongdong Liu
2023-01-29 10:51 ` [PATCH 04/10] net/hns3: fix fixed RSS key size to be more compatibility Dongdong Liu
2023-01-29 10:51 ` [PATCH 05/10] net/hns3: fix misclearing RSS configuration Dongdong Liu
2023-01-29 10:51 ` [PATCH 06/10] net/hns3: using RSS filter list to check duplicated rule Dongdong Liu
2023-01-29 10:51 ` [PATCH 07/10] net/hns3: remove useless code when destroy valid RSS rule Dongdong Liu
2023-01-29 10:51 ` [PATCH 08/10] net/hns3: fix useless warning when flush or destroy rule Dongdong Liu
2023-01-29 10:51 ` [PATCH 09/10] net/hns3: fix bad memory structure conversion Dongdong Liu
2023-01-29 10:51 ` [PATCH 10/10] net/hns3: fix incorrect check for duplicate RSS rule Dongdong Liu
2023-01-30 9:31 ` [PATCH V2 00/10] net/hns3: some bugfixes for rss Dongdong Liu
2023-01-30 9:31 ` [PATCH V2 01/10] net/hns3: fix error log about indirection table size Dongdong Liu
2023-01-30 9:31 ` [PATCH V2 02/10] net/hns3: extract common API to query device Dongdong Liu
2023-01-30 9:31 ` [PATCH V2 03/10] net/hns3: refactor set RSS hash algorithm and key interface Dongdong Liu
2023-01-30 9:31 ` [PATCH V2 04/10] net/hns3: fix fixed RSS key size to be more compatibility Dongdong Liu
2023-01-30 9:31 ` [PATCH V2 05/10] net/hns3: fix misclearing RSS configuration Dongdong Liu
2023-01-30 9:31 ` [PATCH V2 06/10] net/hns3: using RSS filter list to check duplicated rule Dongdong Liu
2023-01-30 9:31 ` [PATCH V2 07/10] net/hns3: remove useless code when destroy valid RSS rule Dongdong Liu
2023-01-30 9:31 ` [PATCH V2 08/10] net/hns3: fix useless warning when flush or destroy rule Dongdong Liu
2023-01-30 9:31 ` [PATCH V2 09/10] net/hns3: fix bad memory structure conversion Dongdong Liu
2023-01-31 9:34 ` Dongdong Liu
2023-01-30 9:31 ` Dongdong Liu [this message]
2023-01-31 13:02 ` [PATCH V3 00/10] net/hns3: some bugfixes for rss Dongdong Liu
2023-01-31 13:02 ` [PATCH V3 01/10] net/hns3: fix error log about indirection table size Dongdong Liu
2023-01-31 13:02 ` [PATCH V3 02/10] net/hns3: extract common API to query device Dongdong Liu
2023-01-31 13:02 ` [PATCH V3 03/10] net/hns3: refactor set RSS hash algorithm and key interface Dongdong Liu
2023-01-31 13:02 ` [PATCH V3 04/10] net/hns3: fix fixed RSS key size to be more compatibility Dongdong Liu
2023-01-31 13:02 ` [PATCH V3 05/10] net/hns3: fix misclearing RSS configuration Dongdong Liu
2023-01-31 13:02 ` [PATCH V3 06/10] net/hns3: using RSS filter list to check duplicated rule Dongdong Liu
2023-01-31 13:02 ` [PATCH V3 07/10] net/hns3: remove useless code when destroy valid RSS rule Dongdong Liu
2023-01-31 13:02 ` [PATCH V3 08/10] net/hns3: fix useless warning when flush or destroy rule Dongdong Liu
2023-01-31 13:02 ` [PATCH V3 09/10] net/hns3: fix bad memory structure conversion Dongdong Liu
2023-01-31 13:03 ` [PATCH V3 10/10] net/hns3: fix incorrect check for duplicate RSS rule Dongdong Liu
2023-02-08 17:46 ` [PATCH V3 00/10] net/hns3: some bugfixes for rss Ferruh Yigit
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=20230130093129.18529-11-liudongdong3@huawei.com \
--to=liudongdong3@huawei.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=lihuisong@huawei.com \
--cc=stable@dpdk.org \
--cc=thomas@monjalon.net \
--cc=yisen.zhuang@huawei.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).