[3/5] net/nfp: modify the logic of set MAC address

Message ID 20231213032416.1988817-4-chaoyong.he@corigine.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series unify the usage of capacity and control |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chaoyong He Dec. 13, 2023, 3:24 a.m. UTC
  Modify the logic of set MAC address, add the check logic of MAC address.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
---
 drivers/net/nfp/nfp_net_common.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Patch

diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 12b62c1958..99e2fc54e0 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -417,6 +417,11 @@  nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 		return -EBUSY;
 	}
 
+	if (rte_is_valid_assigned_ether_addr(mac_addr) == 0) {
+		PMD_DRV_LOG(ERR, "Invalid MAC address");
+		return -EINVAL;
+	}
+
 	/* Writing new MAC to the specific port BAR address */
 	nfp_write_mac(hw, (uint8_t *)mac_addr);