* [PATCH] pcnet32 compilation fix for 2.4.3pre6
@ 2001-03-22 6:38 Andrzej Krzysztofowicz
2001-03-22 10:43 ` Jeff Garzik
2001-03-22 13:40 ` Jeff Garzik
0 siblings, 2 replies; 13+ messages in thread
From: Andrzej Krzysztofowicz @ 2001-03-22 6:38 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Alan Cox, kernel list
Hi,
It looks like a not fully merged patch from Alan's tree:
drivers/net/net.o: In function `pcnet32_open':
drivers/net/net.o(.text+0x3bb9): undefined reference to `is_valid_ether_addr'
drivers/net/net.o: In function `pcnet32_probe1':
drivers/net/net.o(.text.init+0x5fa): undefined reference to `is_valid_ether_addr'
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla/include/linux/etherdevice.h linux.ac/include/linux/etherdevice.h
--- linux.vanilla/include/linux/etherdevice.h Fri Oct 27 20:22:34 2000
+++ linux.ac/include/linux/etherdevice.h Fri Feb 16 11:10:22 2001
@@ -45,6 +45,14 @@
memcpy (dest->data, src, len);
}
+/* Check that the ethernet address (MAC) is not 00:00:00:00:00:00 and is not
+ * a multicast address. Return true if the address is valid.
+ */
+static __inline__ int is_valid_ether_addr( u8 *addr )
+{
+ return !(addr[0]&1) && memcmp( addr, "\0\0\0\0\0\0", 6);
+}
+
#endif
#endif /* _LINUX_ETHERDEVICE_H */
--
=======================================================================
Andrzej M. Krzysztofowicz ankry@mif.pg.gda.pl
phone (48)(58) 347 14 61
Faculty of Applied Phys. & Math., Technical University of Gdansk
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] pcnet32 compilation fix for 2.4.3pre6
2001-03-22 6:38 [PATCH] pcnet32 compilation fix for 2.4.3pre6 Andrzej Krzysztofowicz
@ 2001-03-22 10:43 ` Jeff Garzik
2001-03-22 13:40 ` Jeff Garzik
1 sibling, 0 replies; 13+ messages in thread
From: Jeff Garzik @ 2001-03-22 10:43 UTC (permalink / raw)
To: Andrzej Krzysztofowicz; +Cc: Linus Torvalds, Alan Cox, kernel list
Andrzej Krzysztofowicz wrote:
>
> Hi,
> It looks like a not fully merged patch from Alan's tree:
>
> drivers/net/net.o: In function `pcnet32_open':
> drivers/net/net.o(.text+0x3bb9): undefined reference to `is_valid_ether_addr'
> drivers/net/net.o: In function `pcnet32_probe1':
> drivers/net/net.o(.text.init+0x5fa): undefined reference to `is_valid_ether_addr'
Ouch, missed that. Thanks for the patch.
--
Jeff Garzik | May you have warm words on a cold evening,
Building 1024 | a full mooon on a dark night,
MandrakeSoft | and a smooth road all the way to your door.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH] pcnet32 compilation fix for 2.4.3pre6
2001-03-22 6:38 [PATCH] pcnet32 compilation fix for 2.4.3pre6 Andrzej Krzysztofowicz
2001-03-22 10:43 ` Jeff Garzik
@ 2001-03-22 13:40 ` Jeff Garzik
2001-03-22 14:39 ` Eli Carter
2001-03-22 14:49 ` Alan Cox
1 sibling, 2 replies; 13+ messages in thread
From: Jeff Garzik @ 2001-03-22 13:40 UTC (permalink / raw)
To: Andrzej Krzysztofowicz; +Cc: Linus Torvalds, Alan Cox, kernel list
[-- Attachment #1: Type: text/plain, Size: 535 bytes --]
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 Garzik | May you have warm words on a cold evening,
Building 1024 | a full mooon on a dark night,
MandrakeSoft | and a smooth road all the way to your door.
[-- Attachment #2: etherdev.patch --]
[-- Type: text/plain, Size: 1037 bytes --]
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 */
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] pcnet32 compilation fix for 2.4.3pre6
2001-03-22 13:40 ` Jeff Garzik
@ 2001-03-22 14:39 ` Eli Carter
2001-03-22 14:46 ` Jeff Garzik
2001-03-22 14:49 ` Alan Cox
1 sibling, 1 reply; 13+ messages in thread
From: Eli Carter @ 2001-03-22 14:39 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Andrzej Krzysztofowicz, Linus Torvalds, Alan Cox, kernel list
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.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] pcnet32 compilation fix for 2.4.3pre6
2001-03-22 14:39 ` Eli Carter
@ 2001-03-22 14:46 ` Jeff Garzik
2001-03-22 15:10 ` Eli Carter
0 siblings, 1 reply; 13+ messages in thread
From: Jeff Garzik @ 2001-03-22 14:46 UTC (permalink / raw)
To: Eli Carter; +Cc: Andrzej Krzysztofowicz, Linus Torvalds, Alan Cox, kernel list
[-- Attachment #1: Type: text/plain, Size: 506 bytes --]
Eli Carter wrote:
> 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.
oops. Thanks, updated patch attached. My patch also adds inline source
docs, and uses 'static inline' instead of 'static __inline__', two small
style improvements.
--
Jeff Garzik | May you have warm words on a cold evening,
Building 1024 | a full mooon on a dark night,
MandrakeSoft | and a smooth road all the way to your door.
[-- Attachment #2: etherdev.patch --]
[-- Type: text/plain, Size: 935 bytes --]
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 14:44:51
@@ -46,6 +46,22 @@
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,};
+
+ return !(addr[0]&1) && memcmp( addr, zaddr, 6);
+}
+
#endif
#endif /* _LINUX_ETHERDEVICE_H */
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] pcnet32 compilation fix for 2.4.3pre6
2001-03-22 13:40 ` Jeff Garzik
2001-03-22 14:39 ` Eli Carter
@ 2001-03-22 14:49 ` Alan Cox
1 sibling, 0 replies; 13+ messages in thread
From: Alan Cox @ 2001-03-22 14:49 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Andrzej Krzysztofowicz, Linus Torvalds, Alan Cox, kernel list
> hmm, on second thought, I think I would prefer the attached patch
> (compiled but not tested).
Pointless...
> 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.
If the multicast bit is set then we already fail the address. Your test
does nothing.
Alan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] pcnet32 compilation fix for 2.4.3pre6
2001-03-22 14:46 ` Jeff Garzik
@ 2001-03-22 15:10 ` Eli Carter
2001-03-22 16:23 ` Jeff Garzik
2001-03-29 21:09 ` dank
0 siblings, 2 replies; 13+ messages in thread
From: Eli Carter @ 2001-03-22 15:10 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Andrzej Krzysztofowicz, Linus Torvalds, Alan Cox, kernel list
Jeff Garzik wrote:
>
> Eli Carter wrote:
> > 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.
>
> oops. Thanks, updated patch attached. My patch also adds inline source
> docs, and uses 'static inline' instead of 'static __inline__', two small
> style improvements.
Mmmm.... documentation. Yummy. ;)
When I submitted the original patch, someone wanted to add the ff's
check as well... to reduce the number of people who make that
suggestion, perhaps the comment should read:
+ * Check that the Ethernet address (MAC) is not a multicast address or
+ * FF:FF:FF:FF:FF:FF (by checking addr[0]&1) and is not
00:00:00:00:00:00.
+ *
Does that make it clear that both cases are covered by the one test?
Hmm... I used __inline__ because the other function in the same
headerfile used it... What is the difference between the two, and is
one depricated now? (And what about in 2.2.x?)
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 14:44:51
> @@ -46,6 +46,22 @@
> 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,};
> +
> + return !(addr[0]&1) && memcmp( addr, zaddr, 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.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] pcnet32 compilation fix for 2.4.3pre6
2001-03-22 15:10 ` Eli Carter
@ 2001-03-22 16:23 ` Jeff Garzik
2001-03-29 21:09 ` dank
1 sibling, 0 replies; 13+ messages in thread
From: Jeff Garzik @ 2001-03-22 16:23 UTC (permalink / raw)
To: Eli Carter; +Cc: Andrzej Krzysztofowicz, Linus Torvalds, Alan Cox, kernel list
Eli Carter wrote:
> Mmmm.... documentation. Yummy. ;)
>
> When I submitted the original patch, someone wanted to add the ff's
> check as well... to reduce the number of people who make that
> suggestion, perhaps the comment should read:
>
> + * Check that the Ethernet address (MAC) is not a multicast address or
> + * FF:FF:FF:FF:FF:FF (by checking addr[0]&1) and is not
> 00:00:00:00:00:00.
> + *
>
> Does that make it clear that both cases are covered by the one test?
yeah
> Hmm... I used __inline__ because the other function in the same
> headerfile used it... What is the difference between the two, and is
> one depricated now? (And what about in 2.2.x?)
since kernel requires gcc, which supports plaine ole 'inline', we don't
need to use the longer form.
--
Jeff Garzik | May you have warm words on a cold evening,
Building 1024 | a full mooon on a dark night,
MandrakeSoft | and a smooth road all the way to your door.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] pcnet32 compilation fix for 2.4.3pre6
2001-03-22 15:10 ` Eli Carter
2001-03-22 16:23 ` Jeff Garzik
@ 2001-03-29 21:09 ` dank
2001-03-29 21:25 ` Ulrich Drepper
1 sibling, 1 reply; 13+ messages in thread
From: dank @ 2001-03-29 21:09 UTC (permalink / raw)
To: linux-kernel; +Cc: Eli Carter
Eli Carter wrote:
> Hmm... I used __inline__ because the other function in the same
> headerfile used it... What is the difference between the two, and is
> one depricated now? (And what about in 2.2.x?)
the inline keyword was not added into the c language until the ansi/iso
c99 revision, echoing its use in c++. prior to that time, gcc supplied
__inline__ as a vendor extension simulating this behavior which could be
compiled without violating checks for strict ansi conformance.
with the new ansi standard, this use of __inline__ is no longer
necessary, although for gcc to grok it as legal ansi requires (iirc) the
macro _ISOC99_SOURCE_ must be defined.
--
nick black * head developer, trellis network security * www.trellisinc.com
"the tao gave birth to machine language. machine language gave birth to the
assembler. the assembler gave rise to the compiler. now there are ten
thousand languages. each has its place, but avoid cobol if you can." - ttop
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] pcnet32 compilation fix for 2.4.3pre6
2001-03-29 21:09 ` dank
@ 2001-03-29 21:25 ` Ulrich Drepper
2001-03-29 21:29 ` Eli Carter
2001-03-29 22:55 ` Tom Leete
0 siblings, 2 replies; 13+ messages in thread
From: Ulrich Drepper @ 2001-03-29 21:25 UTC (permalink / raw)
To: dank; +Cc: linux-kernel, Eli Carter
dank@trellisinc.com writes:
> with the new ansi standard, this use of __inline__ is no longer
> necessary,
This is not correct. Since the semantics of inline in C99 and gcc
differ all code which depends on the gcc semantics should continue to
use __inline__ since this keyword will hopefully forever signal the
gcc semantics.
--
---------------. ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Red Hat `--' drepper at redhat.com `------------------------
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] pcnet32 compilation fix for 2.4.3pre6
2001-03-29 21:25 ` Ulrich Drepper
@ 2001-03-29 21:29 ` Eli Carter
2001-03-29 22:55 ` Tom Leete
1 sibling, 0 replies; 13+ messages in thread
From: Eli Carter @ 2001-03-29 21:29 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: dank, linux-kernel
Ulrich Drepper wrote:
>
> dank@trellisinc.com writes:
>
> > with the new ansi standard, this use of __inline__ is no longer
> > necessary,
>
> This is not correct. Since the semantics of inline in C99 and gcc
> differ all code which depends on the gcc semantics should continue to
> use __inline__ since this keyword will hopefully forever signal the
> gcc semantics.
So what are the differences? (Or, what would I read to learn the
differences?)
When are they important to us?
TIA,
Eli
-----------------------. 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.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] pcnet32 compilation fix for 2.4.3pre6
2001-03-29 21:25 ` Ulrich Drepper
2001-03-29 21:29 ` Eli Carter
@ 2001-03-29 22:55 ` Tom Leete
2001-03-30 9:36 ` Jeff Garzik
1 sibling, 1 reply; 13+ messages in thread
From: Tom Leete @ 2001-03-29 22:55 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: dank, linux-kernel, Eli Carter
Ulrich Drepper wrote:
>
> dank@trellisinc.com writes:
>
> > with the new ansi standard, this use of __inline__ is no longer
> > necessary,
>
> This is not correct. Since the semantics of inline in C99 and gcc
> differ all code which depends on the gcc semantics should continue to
> use __inline__ since this keyword will hopefully forever signal the
> gcc semantics.
Unfortunately, it seems that gcc will define __inline__ as a synonym for
inline, whatever inline is currently in use. I asked this on the gcc list a
while ago. The archive there should have the replies.
Regards,
Tom
--
The Daemons lurk and are dumb. -- Emerson
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] pcnet32 compilation fix for 2.4.3pre6
2001-03-29 22:55 ` Tom Leete
@ 2001-03-30 9:36 ` Jeff Garzik
0 siblings, 0 replies; 13+ messages in thread
From: Jeff Garzik @ 2001-03-30 9:36 UTC (permalink / raw)
To: Tom Leete; +Cc: Ulrich Drepper, dank, linux-kernel, Eli Carter
On Thu, 29 Mar 2001, Tom Leete wrote:
> Ulrich Drepper wrote:
> >
> > dank@trellisinc.com writes:
> >
> > > with the new ansi standard, this use of __inline__ is no longer
> > > necessary,
> >
> > This is not correct. Since the semantics of inline in C99 and gcc
> > differ all code which depends on the gcc semantics should continue to
> > use __inline__ since this keyword will hopefully forever signal the
> > gcc semantics.
> Unfortunately, it seems that gcc will define __inline__ as a synonym for
> inline, whatever inline is currently in use. I asked this on the gcc list a
> while ago. The archive there should have the replies.
None of this matters :)
The kernel standard is 'static inline', so that is the preferred
usage in standard kernel code, without overriding reasons.
(also note that it is an outstanding cleanup item to replace
'extern [__]inline[__]' with 'static inline', unless there are
overriding reasons not to do so.)
Jeff
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2001-03-30 9:37 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-03-22 6:38 [PATCH] pcnet32 compilation fix for 2.4.3pre6 Andrzej Krzysztofowicz
2001-03-22 10:43 ` Jeff Garzik
2001-03-22 13:40 ` Jeff Garzik
2001-03-22 14:39 ` Eli Carter
2001-03-22 14:46 ` Jeff Garzik
2001-03-22 15:10 ` Eli Carter
2001-03-22 16:23 ` Jeff Garzik
2001-03-29 21:09 ` dank
2001-03-29 21:25 ` Ulrich Drepper
2001-03-29 21:29 ` Eli Carter
2001-03-29 22:55 ` Tom Leete
2001-03-30 9:36 ` Jeff Garzik
2001-03-22 14:49 ` Alan Cox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox