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 7774FA04C3; Fri, 22 Nov 2019 15:16:01 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 690C52BA2; Fri, 22 Nov 2019 15:15:54 +0100 (CET) Received: from smtp.tom.com (smtprz15.163.net [106.3.154.248]) by dpdk.org (Postfix) with ESMTP id 415161DBC for ; Fri, 22 Nov 2019 13:06:35 +0100 (CET) Received: from my-app01.tom.com (my-app01.tom.com [127.0.0.1]) by freemail01.tom.com (Postfix) with ESMTP id D799F1C81A30 for ; Fri, 22 Nov 2019 20:06:38 +0800 (CST) Received: from my-app01.tom.com (HELO smtp.tom.com) ([127.0.0.1]) by my-app01 (TOM SMTP Server) with SMTP ID 800360812 for ; Fri, 22 Nov 2019 20:06:38 +0800 (CST) Received: from antispam1.tom.com (unknown [172.25.16.55]) by freemail01.tom.com (Postfix) with ESMTP id CE79D1C81A11 for ; Fri, 22 Nov 2019 20:06:38 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tom.com; s=201807; t=1574424398; bh=pvTT+4RTUS2gkOkoyJl31nZDpvGhWmlddBxcNTeH6zI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=3qUm19s4r/OEb7zhbxxdBgjfx5jvX6qXK+RSBLgqQImFcNR20gn4v7UfHkoy+Otml WJXfgln8/X3wymB/2yEkJXuhIBvrTNCh3BQk9Vz9yhlIWT5255xHKUN2uTPxemUnG4 EagKUETS5zKXNQ9DtMff7QjjgoSzBuwyWIQwNSqs= Received: from antispam1.tom.com (antispam1.tom.com [127.0.0.1]) by antispam1.tom.com (Postfix) with ESMTP id D2F9A10017BC for ; Fri, 22 Nov 2019 20:06:09 +0800 (CST) X-Virus-Scanned: Debian amavisd-new at antispam1.tom.com Received: from antispam1.tom.com ([127.0.0.1]) by antispam1.tom.com (antispam1.tom.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Rrs7USbp1C5W for ; Fri, 22 Nov 2019 20:06:09 +0800 (CST) Received: from localhost.localdomain (unknown [203.160.91.226]) by antispam1.tom.com (Postfix) with ESMTPA id 381DD10014BB; Fri, 22 Nov 2019 20:06:09 +0800 (CST) From: "Wei Hu (Xavier)" To: dev@dpdk.org, stable@dpdk.org Cc: xavier_huwei@163.com, xavier.huwei@tom.com, huwei87@hisilicon.com Date: Fri, 22 Nov 2019 20:06:24 +0800 Message-Id: <20191122120624.4963-7-xavier.huwei@tom.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191122120624.4963-1-xavier.huwei@tom.com> References: <20191122120624.4963-1-xavier.huwei@tom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Fri, 22 Nov 2019 15:15:52 +0100 Subject: [dpdk-dev] [PATCH 6/6] net/hns3: fix duplicate VLAN 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: "Min Hu (Connor)" When setting duplicate vlan, hns3 driver will also add vlan entry to vlan linked list, and this is unreasonable. This patch adds checking whether the VLAN to be added already exists in the linked list and preventing adding duplicate vlan. Fixes: 411d23b9eafb ("net/hns3: support VLAN") Cc: stable@dpdk.org Signed-off-by: Min Hu (Connor) Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 3435bce26..72315718a 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -282,6 +282,11 @@ hns3_add_dev_vlan_table(struct hns3_adapter *hns, uint16_t vlan_id, struct hns3_hw *hw = &hns->hw; struct hns3_pf *pf = &hns->pf; + LIST_FOREACH(vlan_entry, &pf->vlan_list, next) { + if (vlan_entry->vlan_id == vlan_id) + return; + } + vlan_entry = rte_zmalloc("hns3_vlan_tbl", sizeof(*vlan_entry), 0); if (vlan_entry == NULL) { hns3_err(hw, "Failed to malloc hns3 vlan table"); -- 2.23.0