From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6136741D52 for ; Thu, 23 Feb 2023 16:08:12 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 43FD14329B; Thu, 23 Feb 2023 16:08:10 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 1F08B4328C for ; Thu, 23 Feb 2023 16:08:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677164888; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=olXWlW6fV7hp0wCF22OJTbmjglom0EF9iMFt25+8qeQ=; b=Wm7RFcLO4NH9qU6J+p+XE6//91STcFKDtWFZ7YFKuOYolr4D3gDTDRnVuRv2qH8xNbMOpG mtcJTnXYEI6lYBhYRBR/kdyrSD/O4LRHYcmd3ogNipbwnU14XTCuGlEWoYct7DU3L/ZfSf UtKFSoSyKlc6n+qFiE/qNvLueUcGlC0= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-265-mQ8XjO-_PcqiRfMQhw0ydg-1; Thu, 23 Feb 2023 10:08:07 -0500 X-MC-Unique: mQ8XjO-_PcqiRfMQhw0ydg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D184E38149CE; Thu, 23 Feb 2023 15:08:04 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.192.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DB792166B29; Thu, 23 Feb 2023 15:08:03 +0000 (UTC) From: Kevin Traynor To: Huisong Li Cc: Dongdong Liu , dpdk stable Subject: patch 'net/hns3: fix duplicate RSS rule check' has been queued to stable release 21.11.4 Date: Thu, 23 Feb 2023 15:05:55 +0000 Message-Id: <20230223150631.723699-64-ktraynor@redhat.com> In-Reply-To: <20230223150631.723699-1-ktraynor@redhat.com> References: <20230223150631.723699-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 21.11.4 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/28/23. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/f6c50b6c5070dadf72b90ebaf2ebd28cbea01c3b Thanks. Kevin --- >From f6c50b6c5070dadf72b90ebaf2ebd28cbea01c3b Mon Sep 17 00:00:00 2001 From: Huisong Li Date: Tue, 31 Jan 2023 21:03:00 +0800 Subject: [PATCH] net/hns3: fix duplicate RSS rule check [ upstream commit 150fd8f839e332d68aa7b60646c2033084544cb7 ] 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") Signed-off-by: Huisong Li Signed-off-by: Dongdong Liu --- 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 8ed1e405c0..582bf383c9 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -1226,26 +1226,57 @@ 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); } -- 2.39.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-02-23 14:46:25.355708123 +0000 +++ 0064-net-hns3-fix-duplicate-RSS-rule-check.patch 2023-02-23 14:46:23.814236119 +0000 @@ -1 +1 @@ -From 150fd8f839e332d68aa7b60646c2033084544cb7 Mon Sep 17 00:00:00 2001 +From f6c50b6c5070dadf72b90ebaf2ebd28cbea01c3b Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 150fd8f839e332d68aa7b60646c2033084544cb7 ] + @@ -16 +17,0 @@ -Cc: stable@dpdk.org @@ -25 +26 @@ -index dd762c02cb..881d70613c 100644 +index 8ed1e405c0..582bf383c9 100644 @@ -28 +29 @@ -@@ -1273,26 +1273,57 @@ hns3_filterlist_flush(struct rte_eth_dev *dev) +@@ -1226,26 +1226,57 @@ hns3_filterlist_flush(struct rte_eth_dev *dev)