Subject: Re: alignment crash in v6 ipfilter when receiving on gif
To: Martin Husemann <martin@duskware.de>
From: Chris Ross <cross+netbsd@distal.com>
List: port-sparc64
Date: 07/10/2007 10:02:46
On Jul 10, 2007, at 9:45 AM, Martin Husemann wrote:
> To me it looks like a bug in the code:
>
> 	&ip6->ip6_src is known to be 32bit aligned
>
> but
>
> 	i6addr_t needs 64bit alignment.
>
> This kind of casts allow the compiler to assume proper alignment of  
> the
> casted pointer, and thus to use 64bit loads.
>
> The memcpy() suggest in the refered thread is the correct fix.

   I guess I don't understand what you mean by "this kind of cast."   
You mean the casts to i6addr_t* ?  So because i6addr_t is a 128-bit  
sized object, the compiler assumes it's properly aligned?  Hmm, I  
suppose that would make some sense.

   In that case, one of the suggestions in the thread was to put a 64- 
bit value in the union ip6_ctlun that's contained in struct ip6_hdr.   
This would make struct ip6_hdr 32 bits larger, but would align both  
ip6_src and ip6_dst.  Wouldn't that be a better "fix" than having to  
perform a memcpy for every ICMPv6 packet that passes through the kernel?

                                    - Chris