https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=272965
--- Comment #11 from Gleb Smirnoff <[email protected]> --- On Thu Dec 21 04:15:04 2023 UTC, [email protected] wrote: > Unfortunately, I can't agree with that. Aligning the input mbuf is only > papering > over the real problem and can only work for trivial cases. It doesn't help > for > vlans (unless HW strips header), for various protocol encapsulations and most > importantly it doesn't work at all for IPv6 :( > > The real problem is that our network stack uses undefined behavior. We can > alias > a byte buffer to a structure only if the given buffer pointer is conform with > the desired structure alignment, otherwise the behavior is undefined. This is, > strictly speaking , required for every architecture. The only way we can > reduce > the required alignment is by using the packed attribute for the affected > structures... I could be wrong, but AFAIU, the network protocols are all designed in such a manner, that as they stack up on each other, all fields in protocol headers are aligned, as long as the base of the packet is aligned. So, if the driver makes sure 'struct ether_header' is aligned, the upper protocols will also see their headers aligned. A misaligned read may happen only in something like an accept_filter(9) that will read into packet payload. And of course all structures defining network headers are marked with __packed. -- You are receiving this mail because: You are the assignee for the bug.
