* [PATCH] fix HIPQUAD macro in kernel.h
@ 2002-08-08 11:31 Harald Welte
2002-08-08 11:41 ` Andi Kleen
2002-08-08 14:58 ` David S. Miller
0 siblings, 2 replies; 5+ messages in thread
From: Harald Welte @ 2002-08-08 11:31 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1447 bytes --]
Hi Dave!
Below is a fix for the HIPQUAD macro in kernel.h. The macro is currently
not endian-aware - it just assumes running on a little-endian machine.
If you don't like the #ifdefs in kernel.h, the macros could be moved into
include/linux/byteorder/.
Please apply, thanks
--- linux-2.4.19-rc5-plain/include/linux/kernel.h Wed Aug 7 22:55:03 2002
+++ linux-2.4.19-rc5-endian/include/linux/kernel.h Thu Aug 8 11:34:13 2002
@@ -12,6 +12,7 @@
#include <linux/stddef.h>
#include <linux/types.h>
#include <linux/compiler.h>
+#include <asm/byteorder.h>
/* Optimization barrier */
/* The "volatile" is due to gcc bugs */
@@ -128,11 +129,17 @@
((unsigned char *)&addr)[2], \
((unsigned char *)&addr)[3]
+#if defined(__LITTLE_ENDIAN)
#define HIPQUAD(addr) \
((unsigned char *)&addr)[3], \
((unsigned char *)&addr)[2], \
((unsigned char *)&addr)[1], \
((unsigned char *)&addr)[0]
+#elif defined(__BIG_ENDIAN)
+#define HIPQUAD NIPQUAD
+#else
+#error "Please fix asm/byteorder.h"
+#endif /* __LITTLE_ENDIAN */
/*
* min()/max() macros that also do
--
Live long and prosper
- Harald Welte / laforge@gnumonks.org http://www.gnumonks.org/
============================================================================
GCS/E/IT d- s-: a-- C+++ UL++++$ P+++ L++++$ E--- W- N++ o? K- w--- O- M+
V-- PS++ PE-- Y++ PGP++ t+ 5-- !X !R tv-- b+++ !DI !D G+ e* h--- r++ y+(*)
[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fix HIPQUAD macro in kernel.h
2002-08-08 11:31 [PATCH] fix HIPQUAD macro in kernel.h Harald Welte
@ 2002-08-08 11:41 ` Andi Kleen
2002-08-08 12:06 ` Harald Welte
2002-08-08 14:48 ` David S. Miller
2002-08-08 14:58 ` David S. Miller
1 sibling, 2 replies; 5+ messages in thread
From: Andi Kleen @ 2002-08-08 11:41 UTC (permalink / raw)
To: Harald Welte; +Cc: David Miller, netdev, linux-kernel
On Thu, Aug 08, 2002 at 01:31:12PM +0200, Harald Welte wrote:
> Hi Dave!
>
> Below is a fix for the HIPQUAD macro in kernel.h. The macro is currently
> not endian-aware - it just assumes running on a little-endian machine.
>
> If you don't like the #ifdefs in kernel.h, the macros could be moved into
> include/linux/byteorder/.
>
> Please apply, thanks
That change is wrong. IP address should be always in network order (=BE)
while in kernel.
-Andi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fix HIPQUAD macro in kernel.h
2002-08-08 11:41 ` Andi Kleen
@ 2002-08-08 12:06 ` Harald Welte
2002-08-08 14:48 ` David S. Miller
1 sibling, 0 replies; 5+ messages in thread
From: Harald Welte @ 2002-08-08 12:06 UTC (permalink / raw)
To: Andi Kleen; +Cc: David Miller, netdev, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1674 bytes --]
On Thu, Aug 08, 2002 at 01:41:13PM +0200, Andi Kleen wrote:
> On Thu, Aug 08, 2002 at 01:31:12PM +0200, Harald Welte wrote:
> > Hi Dave!
> >
> > Below is a fix for the HIPQUAD macro in kernel.h. The macro is currently
> > not endian-aware - it just assumes running on a little-endian machine.
> >
> > If you don't like the #ifdefs in kernel.h, the macros could be moved into
> > include/linux/byteorder/.
> >
> > Please apply, thanks
>
> That change is wrong. IP address should be always in network order (=BE)
> while in kernel.
well, there is for example a short codepath in ip_conntrack_irc.c, where
the ip address is parsed from the packet payload (after which it is present
in host byte order). Before it is written to the apropriate data structures,
we convert it to network byte order. And just before this happens,
there are debug printk's which use HIPQUAD.
What is the point of providing two macros (HIPQUAD and NIPQUAD), if
one of them does only work on little-endian. I would understand your point
if th HIPQUAD macro wasn't present at all (and only NIPQUAD existed).
I assumed that NIPQUAD does parse an ip address in network byte order,
and HIPQUAD in host byte order. If they are really meant for little or
big endian, they should be renamed to BEIPQUAD and LEIPQUAD.
> -Andi
--
Live long and prosper
- Harald Welte / laforge@gnumonks.org http://www.gnumonks.org/
============================================================================
GCS/E/IT d- s-: a-- C+++ UL++++$ P+++ L++++$ E--- W- N++ o? K- w--- O- M+
V-- PS++ PE-- Y++ PGP++ t+ 5-- !X !R tv-- b+++ !DI !D G+ e* h--- r++ y+(*)
[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fix HIPQUAD macro in kernel.h
2002-08-08 11:41 ` Andi Kleen
2002-08-08 12:06 ` Harald Welte
@ 2002-08-08 14:48 ` David S. Miller
1 sibling, 0 replies; 5+ messages in thread
From: David S. Miller @ 2002-08-08 14:48 UTC (permalink / raw)
To: ak; +Cc: laforge, netdev, linux-kernel
From: Andi Kleen <ak@suse.de>
Date: Thu, 8 Aug 2002 13:41:13 +0200
That change is wrong. IP address should be always in network order
(=BE) while in kernel.
He's fixing the HIPQUAD ('H' as in 'host') not NIPQUAD ('N' as in
'network') macro.
If you disagree with people using HIPQUAD at all, recommend that
it be deleted. Until then, it ought to be fixed :-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fix HIPQUAD macro in kernel.h
2002-08-08 11:31 [PATCH] fix HIPQUAD macro in kernel.h Harald Welte
2002-08-08 11:41 ` Andi Kleen
@ 2002-08-08 14:58 ` David S. Miller
1 sibling, 0 replies; 5+ messages in thread
From: David S. Miller @ 2002-08-08 14:58 UTC (permalink / raw)
To: laforge; +Cc: netdev, linux-kernel
From: Harald Welte <laforge@gnumonks.org>
Date: Thu, 8 Aug 2002 13:31:12 +0200
Below is a fix for the HIPQUAD macro in kernel.h. The macro is currently
not endian-aware - it just assumes running on a little-endian machine.
This looks fine, I've added it to both my 2.4.x and 2.5.x
networking trees.
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-08-08 14:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-08 11:31 [PATCH] fix HIPQUAD macro in kernel.h Harald Welte
2002-08-08 11:41 ` Andi Kleen
2002-08-08 12:06 ` Harald Welte
2002-08-08 14:48 ` David S. Miller
2002-08-08 14:58 ` David S. 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).