netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next V2] net/vxlan: Avoid unaligned access in vxlan_build_skb()
@ 2016-09-20 18:57 Sowmini Varadhan
  2016-09-21  9:43 ` Jiri Benc
  2016-09-21 10:10 ` Hannes Frederic Sowa
  0 siblings, 2 replies; 7+ messages in thread
From: Sowmini Varadhan @ 2016-09-20 18:57 UTC (permalink / raw)
  To: netdev; +Cc: sowmini.varadhan, jbenc, davem, hannes

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 <sowmini.varadhan@oracle.com>
---
 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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next V2] net/vxlan: Avoid unaligned access in vxlan_build_skb()
  2016-09-20 18:57 [PATCH net-next V2] net/vxlan: Avoid unaligned access in vxlan_build_skb() Sowmini Varadhan
@ 2016-09-21  9:43 ` Jiri Benc
  2016-09-21 10:10 ` Hannes Frederic Sowa
  1 sibling, 0 replies; 7+ messages in thread
From: Jiri Benc @ 2016-09-21  9:43 UTC (permalink / raw)
  To: Sowmini Varadhan; +Cc: netdev, davem, hannes

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 <sowmini.varadhan@oracle.com>

Acked-by: Jiri Benc <jbenc@redhat.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next V2] net/vxlan: Avoid unaligned access in vxlan_build_skb()
  2016-09-20 18:57 [PATCH net-next V2] net/vxlan: Avoid unaligned access in vxlan_build_skb() Sowmini Varadhan
  2016-09-21  9:43 ` Jiri Benc
@ 2016-09-21 10:10 ` Hannes Frederic Sowa
  2016-09-21 16:14   ` Alexei Starovoitov
  1 sibling, 1 reply; 7+ messages in thread
From: Hannes Frederic Sowa @ 2016-09-21 10:10 UTC (permalink / raw)
  To: Sowmini Varadhan, netdev; +Cc: jbenc, davem

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 <sowmini.varadhan@oracle.com>

Performance wise this should only affect code generation for archs where
it matters anyway.

Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>

Thanks,
Hannes

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next V2] net/vxlan: Avoid unaligned access in vxlan_build_skb()
  2016-09-21 10:10 ` Hannes Frederic Sowa
@ 2016-09-21 16:14   ` Alexei Starovoitov
  2016-09-21 16:49     ` Hannes Frederic Sowa
  2016-09-21 16:53     ` Eric Dumazet
  0 siblings, 2 replies; 7+ messages in thread
From: Alexei Starovoitov @ 2016-09-21 16:14 UTC (permalink / raw)
  To: Hannes Frederic Sowa; +Cc: Sowmini Varadhan, netdev, jbenc, davem

On Wed, Sep 21, 2016 at 12:10:55PM +0200, Hannes Frederic Sowa wrote:
> 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 <sowmini.varadhan@oracle.com>
> 
> 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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next V2] net/vxlan: Avoid unaligned access in vxlan_build_skb()
  2016-09-21 16:14   ` Alexei Starovoitov
@ 2016-09-21 16:49     ` Hannes Frederic Sowa
  2016-09-21 16:53     ` Eric Dumazet
  1 sibling, 0 replies; 7+ messages in thread
From: Hannes Frederic Sowa @ 2016-09-21 16:49 UTC (permalink / raw)
  To: Alexei Starovoitov; +Cc: Sowmini Varadhan, netdev, jbenc, davem

On 21.09.2016 18:14, Alexei Starovoitov wrote:
> On Wed, Sep 21, 2016 at 12:10:55PM +0200, Hannes Frederic Sowa wrote:
>> 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 <sowmini.varadhan@oracle.com>
>>
>> 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next V2] net/vxlan: Avoid unaligned access in vxlan_build_skb()
  2016-09-21 16:14   ` Alexei Starovoitov
  2016-09-21 16:49     ` Hannes Frederic Sowa
@ 2016-09-21 16:53     ` Eric Dumazet
  2016-09-21 17:12       ` Alexei Starovoitov
  1 sibling, 1 reply; 7+ messages in thread
From: Eric Dumazet @ 2016-09-21 16:53 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: Hannes Frederic Sowa, Sowmini Varadhan, netdev, jbenc, davem

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next V2] net/vxlan: Avoid unaligned access in vxlan_build_skb()
  2016-09-21 16:53     ` Eric Dumazet
@ 2016-09-21 17:12       ` Alexei Starovoitov
  0 siblings, 0 replies; 7+ messages in thread
From: Alexei Starovoitov @ 2016-09-21 17:12 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Hannes Frederic Sowa, Sowmini Varadhan, netdev, jbenc, davem

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:
> 
> > 
> > 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!

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-09-21 17:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-20 18:57 [PATCH net-next V2] net/vxlan: Avoid unaligned access in vxlan_build_skb() Sowmini Varadhan
2016-09-21  9:43 ` Jiri Benc
2016-09-21 10:10 ` Hannes Frederic Sowa
2016-09-21 16:14   ` Alexei Starovoitov
2016-09-21 16:49     ` Hannes Frederic Sowa
2016-09-21 16:53     ` Eric Dumazet
2016-09-21 17:12       ` Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).