Thread (26 messages) read the whole thread 26 messages, 6 authors, 2014-10-13

RE: [PATCH] flow-dissector: Fix alignment issue in __skb_flow_get_ports

From: David Laight <hidden>
Date: 2014-10-13 08:34:03

From: David Miller
From: Alexander Duyck <redacted>
Date: Fri, 10 Oct 2014 09:50:17 -0700
quoted
If I just use get_unaligned that is pretty easy in terms of cleanup
for the ports and IPv4 addresses, the IPv6 will still be a significant
hurdle to overcome though.
Actually, it's not that simple.

When the compiler sees things like "th->doff" it will load the 32-bit
word that 4-bit field contains and extract the value using shifts and
masking.

So we might need to sprinkle a "attribute((packed))" here and there
to make it work.
Marking a structure 'packed' forces the compiler to generate byte accesses.
It is enough to mark the 32bit members with __attribute__((aligned(2)))
(or use a typedef for u32 that includes that attribute).
Then the compiler will use 16bit accesses for that field.

	David
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help