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 C6F1FA2E1B for ; Tue, 3 Sep 2019 04:21:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 85AF61EB3F; Tue, 3 Sep 2019 04:19:35 +0200 (CEST) Received: from rnd-relay.smtp.broadcom.com (rnd-relay.smtp.broadcom.com [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 131192B94 for ; Tue, 3 Sep 2019 04:19:10 +0200 (CEST) Received: from nis-sj1-27.broadcom.com (nis-sj1-27.lvn.broadcom.net [10.75.144.136]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id D71B330C209; Mon, 2 Sep 2019 19:19:02 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com D71B330C209 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1567477142; bh=GeHO/rFgnhbPuBc1+j5Y+bzYQvW8F3N0q1eve5wLFEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NQqwJD/M+lMBzpLS5Zifh7UofjjefLQEnkOU9eQnNtZmZ6gfJ/wxKJtYenf4K+/5c KZfpMDWOgYWI0+FhwWoPXOQWJZlNoMyJ6XT779BufKYQiwBCT6SUN+fm9lzRGZeiMH sMNgCq6VCxrpw/M66/lGeg1+NG6TNGHQf91RIvc8= Received: from localhost.localdomain (unknown [10.230.30.225]) by nis-sj1-27.broadcom.com (Postfix) with ESMTP id D6748AC06AB; Mon, 2 Sep 2019 19:19:08 -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: Mon, 2 Sep 2019 19:18:58 -0700 Message-Id: <20190903021901.25895-15-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20190903021901.25895-1-ajit.khaparde@broadcom.com> References: <20190903021901.25895-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 14/17] 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 b72466467..5ef2ee0c4 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -1308,14 +1308,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)