diff mbox

via-rhine: do not freak out due to invalid MAC address

Message ID 4DAA12C0.7030106@gmail.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Alex G. April 16, 2011, 10:05 p.m. UTC
via-rhine drops out of the init code if the hardware provides an invalid
MAC address. Roger Luethi has had several reports of Rhine NICs doing just
that. The hardware still works, though; assigning a random MAC address
allows the NIC to be used as usual. Tested as a standalone interface,
as carrier for ppp, and as bonding slave.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Ben Hutchings April 17, 2011, 12:08 a.m. UTC | #1
On Sun, 2011-04-17 at 01:05 +0300, Alex G. wrote:
> via-rhine drops out of the init code if the hardware provides an invalid
> MAC address. Roger Luethi has had several reports of Rhine NICs doing just
> that. The hardware still works, though; assigning a random MAC address
> allows the NIC to be used as usual. Tested as a standalone interface,
> as carrier for ppp, and as bonding slave.
> 
> Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
> 
> diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
> index 0422a79..e7e0fa9 100644
> --- a/drivers/net/via-rhine.c
> +++ b/drivers/net/via-rhine.c
> @@ -836,13 +836,18 @@ static int __devinit rhine_init_one(struct pci_dev *pdev,
>  
>      for (i = 0; i < 6; i++)
>          dev->dev_addr[i] = ioread8(ioaddr + StationAddr + i);
> -    memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
>  
> -    if (!is_valid_ether_addr(dev->perm_addr)) {
> -        rc = -EIO;
> -        printk(KERN_ERR "Invalid MAC address\n");
> -        goto err_out_unmap;
> +    if (!is_valid_ether_addr(dev->dev_addr)) {
> +        printk(KERN_ERR "via-rhine: Invalid MAC address: %pM. \n",
> +                dev->dev_addr);
> +        /* The device may still be used normally if a valid MAC is
> +         * configured
> +         */
> +        random_ether_addr(dev->dev_addr);
> +        printk(KERN_ERR "via-rhine: Using randomly generated address:"
> +                "%pM instead. \n", dev->dev_addr);
>      }
> +    memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);

I don't think you should hide the original address (presumably the
'permanent' address from EEPORM) in this way.  How about changing the
initial loop to initialise dev->perm_addr, then either copying that to
dev->dev_addr or generating a random address in dev->dev_addr?

Ben.
David Miller April 17, 2011, 12:11 a.m. UTC | #2
From: "Alex G." <mr.nuke.me@gmail.com>
Date: Sun, 17 Apr 2011 01:05:52 +0300

> via-rhine drops out of the init code if the hardware provides an invalid
> MAC address. Roger Luethi has had several reports of Rhine NICs doing just
> that. The hardware still works, though; assigning a random MAC address
> allows the NIC to be used as usual. Tested as a standalone interface,
> as carrier for ppp, and as bonding slave.
> 
> Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>

Your patch is corrupted, your email client turned tab characters
into spaces, which makes your patch unusable.

Please read Documentation/email-clients.txt to learn how to fix
this, try sending the patch to yourself and testing that you
can actually apply the patch as you receive it, and then make a
full, clean, resubmission of the fixed patch.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Joe Perches April 17, 2011, 12:15 a.m. UTC | #3
Alexandru's patch didn't apply so use the
current logging standards and fix the whitespace
in Alexandru's patch.

Joe Perches (2):
  via_rhine: Use netdev_<level> and pr_<level>
  via-rhine: Assign random MAC address if necessary

 drivers/net/via-rhine.c |  240 ++++++++++++++++++++++-------------------------
 1 files changed, 114 insertions(+), 126 deletions(-)
diff mbox

Patch

diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
index 0422a79..e7e0fa9 100644
--- a/drivers/net/via-rhine.c
+++ b/drivers/net/via-rhine.c
@@ -836,13 +836,18 @@  static int __devinit rhine_init_one(struct pci_dev *pdev,
 
     for (i = 0; i < 6; i++)
         dev->dev_addr[i] = ioread8(ioaddr + StationAddr + i);
-    memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
 
-    if (!is_valid_ether_addr(dev->perm_addr)) {
-        rc = -EIO;
-        printk(KERN_ERR "Invalid MAC address\n");
-        goto err_out_unmap;
+    if (!is_valid_ether_addr(dev->dev_addr)) {
+        printk(KERN_ERR "via-rhine: Invalid MAC address: %pM. \n",
+                dev->dev_addr);
+        /* The device may still be used normally if a valid MAC is
+         * configured
+         */
+        random_ether_addr(dev->dev_addr);
+        printk(KERN_ERR "via-rhine: Using randomly generated address:"
+                "%pM instead. \n", dev->dev_addr);
     }
+    memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
 
     /* For Rhine-I/II, phy_id is loaded from EEPROM */
     if (!phy_id)