Re: [PATCH] pcnet32 compilation fix for 2.4.3pre6

Eli Carter
2001-03-22T14:40:10Z

Jeff Garzik wrote:
>
> hmm, on second thought, I think I would prefer the attached patch
> (compiled but not tested).
>
> Hardware usually returns all 1's when it's not present, or not working,
> so think checking for addresses filled with 1's is a good idea too.
>
> I also took the patch from alan's tree and made the memcmp against
> six-byte 'zaddr' rather than a seven-byte string :)

Jeff,

The "!(addr[0]&1)" part of the test already catches the ff's case, so
that is redundant.
Using 6 bytes instead of 7 is an improvement.

Eli

> Index: include/linux/etherdevice.h
> ===================================================================
> RCS file: /cvsroot/gkernel/linux_2_4/include/linux/etherdevice.h,v
> retrieving revision 1.1.1.14.4.2
> diff -u -r1.1.1.14.4.2 etherdevice.h
> --- include/linux/etherdevice.h 2001/03/21 14:10:50 1.1.1.14.4.2
> +++ include/linux/etherdevice.h 2001/03/22 13:37:15
> @@ -46,6 +46,25 @@
> memcpy (dest->data, src, len);
> }
>
> +/**
> + * is_valid_ether_addr - Determine if the given Ethernet address is valid
> + * @addr: Pointer to a six-byte array containing the Ethernet address
> + *
> + * Check that the Ethernet address (MAC) is not 00:00:00:00:00:00, is not
> + * a multicast address, and is not FF:FF:FF:FF:FF:FF.
> + *
> + * Return true if the address is valid.
> + */
> +static inline int is_valid_ether_addr( u8 *addr )
> +{
> + const char zaddr[6] = {0,};
> + const char faddr[6] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
> +
> + return !(addr[0]&1) &&
> + memcmp( addr, zaddr, 6) &&
> + memcmp( addr, faddr, 6);
> +}
> +
> #endif
>
> #endif /* _LINUX_ETHERDEVICE_H */

--
-----------------------. Rule of Accuracy: When working toward
Eli Carter | the solution of a problem, it always
eli.carter(at)inet.com `------------------ helps if you know the answer.