From 4c5b16999074a8b4d61a2564220147548afe959a Mon Sep 17 00:00:00 2001 From: "Min Hu (Connor)" Date: Fri, 22 Nov 2019 20:06:24 +0800 Subject: [PATCH] net/hns3: fix duplicated VLAN entry When setting vlan, hns3 driver will add vlan entry to vlan linked list each time, and this is unreasonable. This patch adds a check whether the VLAN to be added already exists in the linked list and prevents adding duplicated 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 3435bce26e..72315718a8 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.20.1