netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] SIS900 show warning if bogus MAC address (take 2)
@ 2009-01-13 18:18 Daniele Venzano
  2009-01-13 19:06 ` Stephen Hemminger
  2009-01-13 23:44 ` Andrew Morton
  0 siblings, 2 replies; 4+ messages in thread
From: Daniele Venzano @ 2009-01-13 18:18 UTC (permalink / raw)
  To: netdev; +Cc: akpm, venza

[-- Attachment #1: Type: text/plain, Size: 677 bytes --]

The attached patch modifies the sis900 driver when the MAC address
read from the hardware is invalid. As suggested, the patch now
generates a random address so that the user can go on and use
the hardware. In any case a message is also shown to warn on the
unexpected condition.
This seems to happen with newer HW implementation of the sis900
chipset, since this never came up before.

Patch is against vanilla 2.6.28 (but the driver doesn't change so often,
so it will probably apply to older/newer versions too).

See bugzilla ID 10201 and 11649 and ignore the previous patch.

Signed-off-by: Daniele Venzano <venza@brownhat.org>

--
Daniele Venzano
http://www.brownhat.org


[-- Attachment #2: sis900_check_set_mac.diff --]
[-- Type: text/x-diff, Size: 645 bytes --]

--- a/drivers/net/sis900.c	2009-01-13 15:12:35.000000000 +0100
+++ b/drivers/net/sis900.c	2009-01-13 15:38:05.000000000 +0100
@@ -504,10 +504,10 @@ static int __devinit sis900_probe(struct
 	else
 		ret = sis900_get_mac_addr(pci_dev, net_dev);
 
-	if (ret == 0) {
-		printk(KERN_WARNING "%s: Cannot read MAC address.\n", dev_name);
-		ret = -ENODEV;
-		goto err_unmap_rx;
+	if (!ret || !is_valid_ether_addr(net_dev->dev_addr)) {
+		random_ether_addr(net_dev->dev_addr);
+		printk(KERN_WARNING "%s: Unreadable or invalid MAC address,"
+				"using random generated one\n", dev_name);
 	}
 
 	/* 630ET : set the mii access mode as software-mode */

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] SIS900 show warning if bogus MAC address (take 2)
  2009-01-13 18:18 [PATCH] SIS900 show warning if bogus MAC address (take 2) Daniele Venzano
@ 2009-01-13 19:06 ` Stephen Hemminger
  2009-01-13 23:44 ` Andrew Morton
  1 sibling, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2009-01-13 19:06 UTC (permalink / raw)
  To: Daniele Venzano; +Cc: netdev, akpm, venza

On Tue, 13 Jan 2009 19:18:21 +0100
Daniele Venzano <venza@brownhat.org> wrote:

> The attached patch modifies the sis900 driver when the MAC address
> read from the hardware is invalid. As suggested, the patch now
> generates a random address so that the user can go on and use
> the hardware. In any case a message is also shown to warn on the
> unexpected condition.
> This seems to happen with newer HW implementation of the sis900
> chipset, since this never came up before.
> 
> Patch is against vanilla 2.6.28 (but the driver doesn't change so often,
> so it will probably apply to older/newer versions too).
> 
> See bugzilla ID 10201 and 11649 and ignore the previous patch.
> 
> Signed-off-by: Daniele Venzano <venza@brownhat.org>
> 
> --
> Daniele Venzano
> http://www.brownhat.org
> 

It would be good if this driver was converted from using dev_name (ie pci_name()) 
and used the standard routines which print that and more: dev_err, dev_warn, dev_dbg, etc?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] SIS900 show warning if bogus MAC address (take 2)
  2009-01-13 18:18 [PATCH] SIS900 show warning if bogus MAC address (take 2) Daniele Venzano
  2009-01-13 19:06 ` Stephen Hemminger
@ 2009-01-13 23:44 ` Andrew Morton
  2009-01-15  4:46   ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2009-01-13 23:44 UTC (permalink / raw)
  To: Daniele Venzano; +Cc: netdev, venza

On Tue, 13 Jan 2009 19:18:21 +0100
Daniele Venzano <venza@brownhat.org> wrote:
>
> Subject: [PATCH] SIS900 show warning if bogus MAC address (take 2)
>

The title is now wrong.  I rewrote it in my copy to

sis900: generate fake MAC address if the hardware doesn't have one

> The attached patch modifies the sis900 driver when the MAC address
> read from the hardware is invalid. As suggested, the patch now
> generates a random address so that the user can go on and use
> the hardware. In any case a message is also shown to warn on the
> unexpected condition.
> This seems to happen with newer HW implementation of the sis900
> chipset, since this never came up before.
> 
> Patch is against vanilla 2.6.28 (but the driver doesn't change so often,
> so it will probably apply to older/newer versions too).
> 
> See bugzilla ID 10201 and 11649 and ignore the previous patch.

When referring to bugzilla reports I like to use the full URL.  It's
simpler for readers and makes life easier for those people who search
changelogs looking for bug reports to close off.

> diff -puN drivers/net/sis900.c~sis900-generate-fake-mac-address-if-the-hardware-doesnt-have-one drivers/net/sis900.c
> --- a/drivers/net/sis900.c~sis900-generate-fake-mac-address-if-the-hardware-doesnt-have-one
> +++ a/drivers/net/sis900.c
> @@ -509,10 +509,10 @@ static int __devinit sis900_probe(struct
>  	else
>  		ret = sis900_get_mac_addr(pci_dev, net_dev);
>  
> -	if (ret == 0) {
> -		printk(KERN_WARNING "%s: Cannot read MAC address.\n", dev_name);
> -		ret = -ENODEV;
> -		goto err_unmap_rx;
> +	if (!ret || !is_valid_ether_addr(net_dev->dev_addr)) {
> +		random_ether_addr(net_dev->dev_addr);
> +		printk(KERN_WARNING "%s: Unreadable or invalid MAC address,"
> +				"using random generated one\n", dev_name);

So we generate the fake address a) if the reading failed and b) if the
reading succeeded, but returned a bad address.

Fair enough, I guess.  I wonder if other drivers implement that policy.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] SIS900 show warning if bogus MAC address (take 2)
  2009-01-13 23:44 ` Andrew Morton
@ 2009-01-15  4:46   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2009-01-15  4:46 UTC (permalink / raw)
  To: akpm; +Cc: venza, netdev

From: Andrew Morton <akpm@linux-foundation.org>
Date: Tue, 13 Jan 2009 15:44:07 -0800

> On Tue, 13 Jan 2009 19:18:21 +0100
> Daniele Venzano <venza@brownhat.org> wrote:
> >
> > Subject: [PATCH] SIS900 show warning if bogus MAC address (take 2)
> >
> 
> The title is now wrong.  I rewrote it in my copy to
> 
> sis900: generate fake MAC address if the hardware doesn't have one

I've applied this patch with this correction to net-2.6

> So we generate the fake address a) if the reading failed and b) if the
> reading succeeded, but returned a bad address.
> 
> Fair enough, I guess.  I wonder if other drivers implement that policy.

Several do.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-01-15  4:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-13 18:18 [PATCH] SIS900 show warning if bogus MAC address (take 2) Daniele Venzano
2009-01-13 19:06 ` Stephen Hemminger
2009-01-13 23:44 ` Andrew Morton
2009-01-15  4:46   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).