public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare•com>
To: "Alex G." <mr.nuke.me@gmail•com>
Cc: netdev@vger•kernel.org, Roger Luethi <rl@hellgate•ch>,
	"David S. Miller" <davem@davemloft•net>
Subject: Re: [PATCH] via-rhine: do not freak out due to invalid MAC address
Date: Sun, 17 Apr 2011 01:08:21 +0100	[thread overview]
Message-ID: <1302998901.5282.866.camel@localhost> (raw)
In-Reply-To: <4DAA12C0.7030106@gmail.com>

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.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


  reply	other threads:[~2011-04-17  0:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-16 22:05 [PATCH] via-rhine: do not freak out due to invalid MAC address Alex G.
2011-04-17  0:08 ` Ben Hutchings [this message]
2011-04-17  0:11 ` David Miller
2011-04-17  0:15 ` [PATCH 0/2] via-rhine: Logging cleanups and use random " Joe Perches
2011-04-17  0:15   ` [PATCH 1/2] via_rhine: Use netdev_<level> and pr_<level> Joe Perches
2011-04-18  0:56     ` David Miller
2011-04-17  0:15   ` [PATCH 2/2] via-rhine: Assign random MAC address if necessary Joe Perches
2011-04-18  0:57     ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1302998901.5282.866.camel@localhost \
    --to=bhutchings@solarflare$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=mr.nuke.me@gmail$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=rl@hellgate$(echo .)ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox