[OpenWrt-Devel] [PATCH] ralink: check ethernet MAC address whether it is valid

wengbj fl.service at t-firefly.com
Wed Jan 28 01:24:21 EST 2015


From: wengbj <linux.c at foxmail.com>

The mac address usually write in factory block. but sometime user erase this block , the mac address will change to ff:ff:ff:ff:ff:ff.
This patch is purpose to fix this issue.
---
 .../drivers/net/ethernet/ralink/ralink_soc_eth.c   |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/ralink_soc_eth.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/ralink_soc_eth.c
index d7d1e8e..9900a5e 100644
--- a/target/linux/ramips/files/drivers/net/ethernet/ralink/ralink_soc_eth.c
+++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/ralink_soc_eth.c
@@ -1220,8 +1220,10 @@ static int __init fe_init(struct net_device *dev)
 	if (priv->soc->switch_init)
 		priv->soc->switch_init(priv);
 
-	memcpy(dev->dev_addr, priv->soc->mac, ETH_ALEN);
 	of_get_mac_address_mtd(priv->device->of_node, dev->dev_addr);
+	/*If the mac address is invalid, use default mac address  */
+	if (!is_valid_ether_addr(dev->dev_addr))
+		memcpy(dev->dev_addr, priv->soc->mac, ETH_ALEN);
 
 	err = fe_mdio_init(priv);
 	if (err)
-- 
1.7.9.5
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list