[PATCH net-next V2] net/vxlan: Avoid unaligned access in vxlan_build_skb()

Subsystems: networking [general], the rest

STALE3677d

7 messages, 5 authors, 2016-09-21 · open the first message on its own page

[PATCH net-next V2] net/vxlan: Avoid unaligned access in vxlan_build_skb()

From: Sowmini Varadhan <hidden>
Date: 2016-09-20 18:57:59

The vxlan header may not be aligned to 4 bytes in
vxlan_build_skb (e.g., for MLD packets). This patch
avoids unaligned access traps from vxlan_build_skb
(in platforms like sparc) by making struct vxlanhdr __packed.

Signed-off-by: Sowmini Varadhan <redacted>
---
 include/net/vxlan.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/include/net/vxlan.h b/include/net/vxlan.h
index 0255613..1ec56f4 100644
--- a/include/net/vxlan.h
+++ b/include/net/vxlan.h
@@ -18,7 +18,7 @@
 struct vxlanhdr {
 	__be32 vx_flags;
 	__be32 vx_vni;
-};
+} __packed;
 
 /* VXLAN header flags. */
 #define VXLAN_HF_VNI	cpu_to_be32(BIT(27))
-- 
1.7.1

Re: [PATCH net-next V2] net/vxlan: Avoid unaligned access in vxlan_build_skb()

From: Jiri Benc <hidden>
Date: 2016-09-21 09:43:17

On Tue, 20 Sep 2016 14:57:37 -0400, Sowmini Varadhan wrote:
The vxlan header may not be aligned to 4 bytes in
vxlan_build_skb (e.g., for MLD packets). This patch
avoids unaligned access traps from vxlan_build_skb
(in platforms like sparc) by making struct vxlanhdr __packed.

Signed-off-by: Sowmini Varadhan <redacted>
Acked-by: Jiri Benc <redacted>

Re: [PATCH net-next V2] net/vxlan: Avoid unaligned access in vxlan_build_skb()

From: Hannes Frederic Sowa <hidden>
Date: 2016-09-21 10:10:58

On 20.09.2016 20:57, Sowmini Varadhan wrote:
The vxlan header may not be aligned to 4 bytes in
vxlan_build_skb (e.g., for MLD packets). This patch
avoids unaligned access traps from vxlan_build_skb
(in platforms like sparc) by making struct vxlanhdr __packed.

Signed-off-by: Sowmini Varadhan <redacted>
Performance wise this should only affect code generation for archs where
it matters anyway.

Acked-by: Hannes Frederic Sowa <redacted>

Thanks,
Hannes

Re: [PATCH net-next V2] net/vxlan: Avoid unaligned access in vxlan_build_skb()

From: Alexei Starovoitov <hidden>
Date: 2016-09-21 16:15:08

On Wed, Sep 21, 2016 at 12:10:55PM +0200, Hannes Frederic Sowa wrote:
On 20.09.2016 20:57, Sowmini Varadhan wrote:
quoted
The vxlan header may not be aligned to 4 bytes in
vxlan_build_skb (e.g., for MLD packets). This patch
avoids unaligned access traps from vxlan_build_skb
(in platforms like sparc) by making struct vxlanhdr __packed.

Signed-off-by: Sowmini Varadhan <redacted>
Performance wise this should only affect code generation for archs where
it matters anyway.
I think it's the opposite. Even on x86 compiler will use byte loads.

Re: [PATCH net-next V2] net/vxlan: Avoid unaligned access in vxlan_build_skb()

From: Hannes Frederic Sowa <hidden>
Date: 2016-09-21 16:49:21

On 21.09.2016 18:14, Alexei Starovoitov wrote:
On Wed, Sep 21, 2016 at 12:10:55PM +0200, Hannes Frederic Sowa wrote:
quoted
On 20.09.2016 20:57, Sowmini Varadhan wrote:
quoted
The vxlan header may not be aligned to 4 bytes in
vxlan_build_skb (e.g., for MLD packets). This patch
avoids unaligned access traps from vxlan_build_skb
(in platforms like sparc) by making struct vxlanhdr __packed.

Signed-off-by: Sowmini Varadhan <redacted>
Performance wise this should only affect code generation for archs where
it matters anyway.
I think it's the opposite. Even on x86 compiler will use byte loads.
I checked that on x86-64 actually. Also clearly visible here:

https://godbolt.org/g/xsW2P1

Bye,
Hannes

Re: [PATCH net-next V2] net/vxlan: Avoid unaligned access in vxlan_build_skb()

From: Eric Dumazet <hidden>
Date: 2016-09-21 16:54:22

On Wed, 2016-09-21 at 09:14 -0700, Alexei Starovoitov wrote:
I think it's the opposite. Even on x86 compiler will use byte loads.
Unless you tweaked gcc, it should still use word loads on x86.

Re: [PATCH net-next V2] net/vxlan: Avoid unaligned access in vxlan_build_skb()

From: Alexei Starovoitov <hidden>
Date: 2016-09-21 17:12:29

On Wed, Sep 21, 2016 at 09:53:31AM -0700, Eric Dumazet wrote:
On Wed, 2016-09-21 at 09:14 -0700, Alexei Starovoitov wrote:
quoted
I think it's the opposite. Even on x86 compiler will use byte loads.
Unless you tweaked gcc, it should still use word loads on x86.
checked that on x86-64 actually. Also clearly visible here:
ahh. ok. good to know. thanks guys!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help