cvs commit: src/include ar.h

Bruce Evans bde at zeta.org.au
Fri Nov 17 08:33:16 UTC 2006


On Thu, 16 Nov 2006, Yar Tikhiy wrote:

> On Mon, Nov 13, 2006 at 10:19:58AM -0700, M. Warner Losh wrote:
>> :
>> : BTW, you are responsible for the __packed in <netinet/ip.h>.  Please remove
>> : it.  The __CTASSERT() is enough to detect if heroic packing is ever needed.
>> : The only danger is if something has grown to depend on __packed reducing
>> : alignment as a side effect.  E.g., suppose we had a byte string containing
>> : a bytewise copy of a struct ip.  If the copy might be misaligned, then it
>> : should be copied to an actual struct ip before accessing it as a struct,
>> : but code that accesses it directly using ((struct ip *)&bs[N]) would work
>> : now due to the reduced alignment.  Places that really need __packed should
>> : probably use __aligned() to restore the natural alignment.
>>
>> DO NOT REMOVE IT.  IT IS ABSOLUTELY REQUIRED FOR ARM TO WORK RIGHT.
>> If you want to remove it, then you must make sure arm works right
>> after it because I'll add it back.
>
> Many years ago I was taught that comments in code could help to
> avoid such clashes in software development.  Is this true no more? ;-)

Apparently not.  There has always been a relevant comment in
<net/ethernet.h>:

%%%
/*
  * Mbuf adjust factor to force 32-bit alignment of IP header.
  * Drivers should do m_adj(m, ETHER_ALIGN) when setting up a
  * receive so the upper layers get the IP header properly aligned
  * past the 14-byte Ethernet header.
  */
#define	ETHER_ALIGN		2	/* driver adjust for IP hdr alignment */
%%%

Bruce


More information about the cvs-src mailing list