[6/6] net/hns3: fix duplicate VLAN

Message ID 20191122120624.4963-7-xavier.huwei@tom.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series Fixes for hns3 PMD driver |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/travis-robot success Travis build: passed
ci/Intel-compilation fail Compilation issues

Commit Message

Wei Hu (Xavier) Nov. 22, 2019, 12:06 p.m. UTC
  From: "Min Hu (Connor)" <humin29@huawei.com>

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) <humin29@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
---
 drivers/net/hns3/hns3_ethdev.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Patch

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");