Subject: Re: alignment crash in v6 ipfilter when receiving on gif
To: matthew green <mrg@eterna.com.au>
From: Pavel Cahyna <pavel@NetBSD.org>
List: port-sparc64
Date: 07/18/2007 08:00:32
On Wed, Jul 18, 2007 at 11:04:58AM +1000, matthew green wrote:
>    
>    There's a deeper problem, which is that I'm not sure our network code
>    guarantees any alignment at all of packets in mbufs.  mbuf(9) doesn't
>    address alignment.  But it seems on sparc64 everything is naturally
>    32-bit aligned, and 64-bit except for gif, or this would have blown up
>    on other interfaces.
> 
> 
> it's not upto mbuf(9) to do this.  it has no idea what alignment data
> in packet data needs.  there's nothing to say that even given a well
> aligned start address, that an aligned member won't be at an unaligned
> offset, such as 4 bytes on a 2 byte boundary (this happens.)

Network interface drivers ensure that data after the Ethernet header are
aligned (don't remember how much but at least 32-bit) and the IP input 
path ensures it again.

It is not surprising that in the case of gif there isn't 64-bit
alignment. If the original packet is aligned, the next header will be
misaligned because IPv4 header length is not a multiple of 8 bytes.

Pavel