[dpdk-dev] [PATCH 6/7] net/hns3: fix configuring illeagl VLAN pvid

Wei Hu (Xavier) huwei013 at chinasoftinc.com
Tue Mar 17 10:12:05 CET 2020


From: "Min Hu (Connor)" <humin29 at huawei.com>

The VLAN pvid ranges from 0 to 4095. The hns3 PMD driver does not support
this situation that the VLAN pvid is larger than Maximum VLAN ID(4095).

Fixes: 411d23b9eafb ("net/hns3: support VLAN")
Cc: stable at dpdk.org

Signed-off-by: Min Hu (Connor) <humin29 at huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei at huawei.com>
---
 drivers/net/hns3/hns3_ethdev.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 15ef03cfe..0d0f5ebb7 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -873,6 +873,12 @@ hns3_vlan_pvid_set(struct rte_eth_dev *dev, uint16_t pvid, int on)
 	struct hns3_hw *hw = &hns->hw;
 	int ret;
 
+	if (pvid > RTE_ETHER_MAX_VLAN_ID) {
+		hns3_err(hw, "Invalid vlan_id = %u > %d", pvid,
+			 RTE_ETHER_MAX_VLAN_ID);
+		return -EINVAL;
+	}
+
 	rte_spinlock_lock(&hw->lock);
 	ret = hns3_vlan_pvid_configure(hns, pvid, on);
 	rte_spinlock_unlock(&hw->lock);
-- 
2.23.0



More information about the dev mailing list