From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0E1BAA2F18 for ; Thu, 3 Oct 2019 01:27:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A8A601BFE0; Thu, 3 Oct 2019 01:26:35 +0200 (CEST) Received: from rnd-relay.smtp.broadcom.com (unknown [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 1480891 for ; Thu, 3 Oct 2019 01:26:11 +0200 (CEST) Received: from mail-irv-17.broadcom.com (mail-irv-17.lvn.broadcom.net [10.75.242.48]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id 2B82F30C2B6; Wed, 2 Oct 2019 16:24:57 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com 2B82F30C2B6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1570058697; bh=ZHc8MmC8e7wryyX8K076F/rj+mBGeK8/ps3mQrScRzg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LOAPPW74OZsrBZQ6sNF1vpcUTPzDBIy5ErH/mgSLILXQ4nnRaeMndGIFK/URDV6bi LeKFFqNon7oImNBzyptEWLNSkxWsYq32zJ+eA4blenQTHlhVmkjqLtnGoqw2KSgGZv 0zn3doQr0ji7zqmC5xLBEA4W8hWriSwGywKNA76A= Received: from localhost.localdomain (unknown [10.230.30.225]) by mail-irv-17.broadcom.com (Postfix) with ESMTP id 8C05B14008F; Wed, 2 Oct 2019 16:26:09 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Venkat Duvvuru , Somnath Kotur , Rahul Gupta , Santoshkumar Karanappa Rastapur , Kalesh Anakkur Purayil Date: Wed, 2 Oct 2019 16:25:55 -0700 Message-Id: <20191002232601.22715-15-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20191002232601.22715-1-ajit.khaparde@broadcom.com> References: <20191002232601.22715-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 14/20] net/bnxt: validate RSS hash key length X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Venkat Duvvuru In bnxt_rss_hash_update_op, driver is proceeding with bnxt_hwrm_vnic_rss_cfg even though RSS hashkey length is invalid. This patch fixes the problem by returning -EINVAL when RSS hashkey length is invalid. Signed-off-by: Venkat Duvvuru Reviewed-by: Somnath Kotur Reviewed-by: Rahul Gupta Reviewed-by: Santoshkumar Karanappa Rastapur Reviewed-by: Kalesh Anakkur Purayil Reviewed-by: Ajit Khaparde Signed-off-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_ethdev.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 2c9eaaa2ef..354fa4c630 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -1373,14 +1373,20 @@ static int bnxt_rss_hash_update_op(struct rte_eth_dev *eth_dev, vnic->hash_type = bnxt_rte_to_hwrm_hash_types(rss_conf->rss_hf); /* - * Use the supplied key if the key length is - * acceptable and the rss_key is not NULL + * If hashkey is not specified, use the previously configured + * hashkey */ - if (rss_conf->rss_key && rss_conf->rss_key_len <= HW_HASH_KEY_SIZE) - memcpy(vnic->rss_hash_key, - rss_conf->rss_key, - rss_conf->rss_key_len); + if (!rss_conf->rss_key) + goto rss_config; + if (rss_conf->rss_key_len != HW_HASH_KEY_SIZE) { + PMD_DRV_LOG(ERR, + "Invalid hashkey length, should be 16 bytes\n"); + return -EINVAL; + } + memcpy(vnic->rss_hash_key, rss_conf->rss_key, rss_conf->rss_key_len); + +rss_config: bnxt_hwrm_vnic_rss_cfg(bp, vnic); return 0; } -- 2.20.1 (Apple Git-117)