[U-Boot] IP_t should be a "packed" struct

Ben Warren biggerbadderben at gmail.com
Wed Jan 28 18:55:45 CET 2009


Luigi 'Comio' Mantellini wrote:
> Hi ML,
>
> I'm working on a mips target and I used qemu_mips target to simulate my target 
> (that I hope to have in the next week...)
>
> Following my activities I noticed that IP_t structure is no defined with 
> attribute "packed". I noticed this issue because using a self-made toolchain 
> (gcc4.2.4+binutils2.8+uclibc0.9.30) the compiler has aligned all bytes to 
> 32bit boundary. This is not ok, because the packets IP_t can be non aligned 
> (see the /net/net.c PingSend function, for an example).
>
>   
Why is your compiler aligning all bytes to 32-bit boundary?  Seems like 
an awful waste of space.  This struct should pack itself nicely, and 
does on the small sample of toolchains I've tried (gcc 4.3.2 x86_64 and 
gcc 4.0.0 ppc_4xx).
> The dirty solution is to define the structure with the 
> __attribute__((__packed__))... but, from my point of view, a better packet 
> forging mechanism should be implemented into the net.c stack.
>
> I attached a trivial patch that solved the issue on my target.
>
> Any comments is welcome.
>
> best regards,
>
> luigi
>
>  
I'd focus on fixing your toolchain.  Your problem will not be confined 
to protocol headers.
>  
> ------------------------------------------------------------------------
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
regards,
Ben



More information about the U-Boot mailing list