Re: [PATCH] netpoll endian fixes

From: Duncan Sands
Date: Wed Sep 08 2004 - 05:03:01 EST


> It looks like it ought to be 0x45 everywhere, meaning it's currently
> broken everywhere. But no one's complained. Unfortunately at the
> present moment I've got one machine short of a test rig unpacked, so
> I'm loathe to push another fix until I get some other test reports.

Hi Matt, I agree that it should be 0x45 everywhere. After thinking a bit
I concluded that the

#if defined(__LITTLE_ENDIAN_BITFIELD)
__u8 ihl:4,
version:4;
#elif defined (__BIG_ENDIAN_BITFIELD)
__u8 version:4,
ihl:4;

in the definition of struct iphdr is to make sure that compiler uses the
first four bits of the byte to refer to version, rather than the last four;
and this only matters when you are accessing the nibbles via the ihl
or version structure fields. Thus it makes sure that if you write 0x45
to the byte, then version will return 4 and ihl will return 5. Presumably
the C standard specifies how bitfield expressions should be laid out
in the byte, and ihl:4, version:4; gives opposite results on little-endian
and big-endian machines...

Ciao,

Duncan.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/