> From: Stephen Hemminger [mailto:[email protected]]
> Sent: Friday, 6 February 2026 02.49
> 
> Why are the header structures marked packed, that is bogus, BSD and
> Linux don't do it.

They have been packed since the first public release in 2013 [1].

I guess it's because the IP and TCP headers contain 4-byte fields, which make 
those structures 4-byte aligned; but since the IP header follows a 14 byte 
Ethernet header (without the magic 2-byte pre-padding done by the kernel), the 
instances of the IP header are not 4-byte aligned, but 2-byte aligned. Marking 
them packed is a way of stripping the alignment.

BTW, the IPv4 header was bumped (from no alignment) to 2-byte alignment with 
patch [2].

[1]: 
https://github.com/DPDK/dpdk/commit/af75078fece3615088e561357c1e97603e43a5fe#diff-620c2b2031359304a7f26328a52035c9f8ddf722b9280f957047dcb81467777f
[2]: 
https://github.com/DPDK/dpdk/commit/c14fba68edfa4aeba7c0dfb5dbc3b4f23affbb81


> Windows probably does 

Yes, probably.
The Microsoft compiler is more pedantic (leading to fewer bugs), and many of 
those structures should formally be packed (or more correctly: unaligned).

> but Windows code seems to love packed even when
> it is not necessary.

I guess packing (without thinking about the need for it) has become a bad habit 
for some Windows programmers.

Reply via email to