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

2016-09-28 Thread Sowmini Varadhan
On (09/28/16 11:08), Alexander Duyck wrote: > > - then udp_gro_receive -> vxlan_gro_receive pulls up vxlan header > > into linear part, and then.. > > This is the point where we need to stop, drop the existing headers, > call skb_reserve(NET_IP_ALIGN), and then pick back up where we left > off.

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

2016-09-28 Thread Alexander Duyck
On Wed, Sep 28, 2016 at 10:03 AM, Sowmini Varadhan wrote: > On (09/23/16 17:43), Alexander Duyck wrote: >> > On (09/23/16 10:38), Alexander Duyck wrote: > ; >> >> almost think of it as us doing something like the inverse of >> >> pskb_pull_tail. The general idea here is we want to actua

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

2016-09-28 Thread Sowmini Varadhan
On (09/23/16 17:43), Alexander Duyck wrote: > > On (09/23/16 10:38), Alexander Duyck wrote: ; > >> almost think of it as us doing something like the inverse of > >> pskb_pull_tail. The general idea here is we want to actually leave > >> the data in skb->data, but just reference it from f

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

2016-09-23 Thread Alexander Duyck
On Fri, Sep 23, 2016 at 4:41 PM, Sowmini Varadhan wrote: > On (09/23/16 10:38), Alexander Duyck wrote: >> >> So basically what I was thinking is we do something like reserving >> NET_IP_ALIGN and continue writing headers to skb->data, but we force >> the tracking for the inner headers into frag[0]

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

2016-09-23 Thread Sowmini Varadhan
On (09/23/16 10:38), Alexander Duyck wrote: > > So basically what I was thinking is we do something like reserving > NET_IP_ALIGN and continue writing headers to skb->data, but we force > the tracking for the inner headers into frag[0] so that we can keep > the inner headers aligned without messin

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

2016-09-23 Thread Alexander Duyck
On Fri, Sep 23, 2016 at 10:20 AM, Sowmini Varadhan wrote: > On (09/23/16 07:17), Alexander Duyck wrote: >> >> Is this basically about, e.g., putting the vxlanhdr in its own >> >> skb_frag_t, or something else? >> > >> > Yes, and this way skb_header_pointer() is forced to do a memcpy. > : >> For

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

2016-09-23 Thread Sowmini Varadhan
On (09/23/16 07:17), Alexander Duyck wrote: > >> Is this basically about, e.g., putting the vxlanhdr in its own > >> skb_frag_t, or something else? > > > > Yes, and this way skb_header_pointer() is forced to do a memcpy. : > For Tx it all becomes a bit trickier since it would likely require us >

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

2016-09-23 Thread Alexander Duyck
On Fri, Sep 23, 2016 at 5:06 AM, David Miller wrote: > From: Sowmini Varadhan > Date: Thu, 22 Sep 2016 17:30:10 -0400 > >> On (09/22/16 01:52), David Miller wrote: >>> Alternatively we can do Alexander Duyck's trick, by pushing >>> the headers into the frag list, forcing a pull and realignment >>

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

2016-09-23 Thread David Miller
From: Sowmini Varadhan Date: Thu, 22 Sep 2016 17:30:10 -0400 > On (09/22/16 01:52), David Miller wrote: >> Alternatively we can do Alexander Duyck's trick, by pushing >> the headers into the frag list, forcing a pull and realignment >> by the next protocol layer. > > What is the "Alexander Duyck

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

2016-09-22 Thread Sowmini Varadhan
On (09/22/16 01:52), David Miller wrote: > Alternatively we can do Alexander Duyck's trick, by pushing > the headers into the frag list, forcing a pull and realignment > by the next protocol layer. What is the "Alexander Duyck trick" (hints about module or commit id, where this can be found, pleas

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

2016-09-21 Thread David Miller
From: Jiri Benc Date: Tue, 20 Sep 2016 19:09:29 +0200 > But the point stands, we have much greater problems here than VXLAN. > And I don't think that wrapping all IP address accesses into > get/put_unaligned all around the stack is the solution. Right, and I don't like marking things as packed e

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

2016-09-20 Thread Sowmini Varadhan
On (09/20/16 19:09), Jiri Benc wrote: > > But the point stands, we have much greater problems here than VXLAN. > And I don't think that wrapping all IP address accesses into > get/put_unaligned all around the stack is the solution. > Agreed, and I think Tom made that point too. For the immediat

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

2016-09-20 Thread Tom Herbert
On Tue, Sep 20, 2016 at 10:09 AM, Jiri Benc wrote: > On Tue, 20 Sep 2016 18:43:33 +0200, Jiri Benc wrote: >> On Tue, 20 Sep 2016 12:31:08 -0400, Sowmini Varadhan wrote: >> > The vxlan header is after the ethernet header (14 bytes), >> > IP header (20 bytes, assuming no options) and udp header (8 b

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

2016-09-20 Thread Jiri Benc
On Tue, 20 Sep 2016 13:07:42 -0400, Sowmini Varadhan wrote: > I will try out Hannes' solution (which makes sense) in a moment, > and report back. No objections to marking the struct as packed. Will only push the problem to a different place, though. Jiri

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

2016-09-20 Thread Jiri Benc
On Tue, 20 Sep 2016 18:43:33 +0200, Jiri Benc wrote: > On Tue, 20 Sep 2016 12:31:08 -0400, Sowmini Varadhan wrote: > > The vxlan header is after the ethernet header (14 bytes), > > IP header (20 bytes, assuming no options) and udp header (8 bytes). > > If the VXLAN header is not aligned to 4 bytes

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

2016-09-20 Thread Sowmini Varadhan
On (09/20/16 18:43), Jiri Benc wrote: > > IPv6 header is certainly not 20 bytes. vxlan encapsulates an IPv6/ethernet frame in a UDP/IPv4/ethernet packet. the ipv4 header is 20 bytes (without options). mld_newpack is dealing with the vxlan net_device in this case, which has ->hard_header_len of 14

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

2016-09-20 Thread Hannes Frederic Sowa
On 20.09.2016 16:27, Sowmini Varadhan wrote: > The vxlan header is at offset (14 + 20 + 8) into the packet, > so the vxh is not aligned in vxlan_build_skb. Use [get/put]_unaligned > functions to modify flags and vni field in the vxh. > > Signed-off-by: Sowmini Varadhan > --- > drivers/net/vxlan.

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

2016-09-20 Thread Jiri Benc
On Tue, 20 Sep 2016 12:31:08 -0400, Sowmini Varadhan wrote: > The vxlan header is after the ethernet header (14 bytes), > IP header (20 bytes, assuming no options) and udp header (8 bytes). If the VXLAN header is not aligned to 4 bytes, then IP header is not aligned to 4 bytes, too, and you have g

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

2016-09-20 Thread Sowmini Varadhan
On (09/20/16 18:11), Jiri Benc wrote: > > The vxlan header is at offset (14 + 20 + 8) into the packet, > > so the vxh is not aligned in vxlan_build_skb. Use [get/put]_unaligned > > functions to modify flags and vni field in the vxh. > > How did you calculate that? IP header should be aligned to 4

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

2016-09-20 Thread Jiri Benc
On Tue, 20 Sep 2016 10:27:00 -0400, Sowmini Varadhan wrote: > The vxlan header is at offset (14 + 20 + 8) into the packet, > so the vxh is not aligned in vxlan_build_skb. Use [get/put]_unaligned > functions to modify flags and vni field in the vxh. How did you calculate that? IP header should be a

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

2016-09-20 Thread Sowmini Varadhan
On (09/20/16 08:31), Tom Herbert wrote: > > On Tue, Sep 20, 2016 at 7:27 AM, Sowmini Varadhan > wrote: > > The vxlan header is at offset (14 + 20 + 8) into the packet, > > so the vxh is not aligned in vxlan_build_skb. Use [get/put]_unaligned > > functions to modify flags and vni field in the vxh.

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

2016-09-20 Thread Tom Herbert
On Tue, Sep 20, 2016 at 7:27 AM, Sowmini Varadhan wrote: > The vxlan header is at offset (14 + 20 + 8) into the packet, > so the vxh is not aligned in vxlan_build_skb. Use [get/put]_unaligned > functions to modify flags and vni field in the vxh. > I'm wondering if VXLAN is just the tip of the iceb

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

2016-09-20 Thread Sowmini Varadhan
The vxlan header is at offset (14 + 20 + 8) into the packet, so the vxh is not aligned in vxlan_build_skb. Use [get/put]_unaligned functions to modify flags and vni field in the vxh. Signed-off-by: Sowmini Varadhan --- drivers/net/vxlan.c | 10 ++ 1 files changed, 6 insertions(+), 4 de