All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net/vxlan: Avoid unaligned access in vxlan_build_skb()
@ 2016-09-20 14:27 Sowmini Varadhan
  2016-09-20 15:31 ` Tom Herbert
                   ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: Sowmini Varadhan @ 2016-09-20 14:27 UTC (permalink / raw)
  To: netdev; +Cc: davem, jbenc, hannes, aduyck, daniel, pabeni, 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 <sowmini.varadhan@oracle.com>
---
 drivers/net/vxlan.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index e7d1668..f903fa4 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1751,15 +1751,17 @@ static int vxlan_build_skb(struct sk_buff *skb, struct dst_entry *dst,
 		goto out_free;
 
 	vxh = (struct vxlanhdr *) __skb_push(skb, sizeof(*vxh));
-	vxh->vx_flags = VXLAN_HF_VNI;
-	vxh->vx_vni = vxlan_vni_field(vni);
+	put_unaligned(VXLAN_HF_VNI, &vxh->vx_flags);
+	put_unaligned(vxlan_vni_field(vni), &vxh->vx_vni);
 
 	if (type & SKB_GSO_TUNNEL_REMCSUM) {
 		unsigned int start;
+		__be32 tmpvni = get_unaligned(&vxh->vx_vni);
 
 		start = skb_checksum_start_offset(skb) - sizeof(struct vxlanhdr);
-		vxh->vx_vni |= vxlan_compute_rco(start, skb->csum_offset);
-		vxh->vx_flags |= VXLAN_HF_RCO;
+		tmpvni |= vxlan_compute_rco(start, skb->csum_offset);
+		put_unaligned(tmpvni, &vxh->vx_vni);
+		put_unaligned(VXLAN_HF_VNI | VXLAN_HF_RCO, &vxh->vx_flags);
 
 		if (!skb_is_gso(skb)) {
 			skb->ip_summed = CHECKSUM_NONE;
-- 
1.7.1

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

end of thread, other threads:[~2016-09-28 19:56 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-20 14:27 [PATCH net-next] net/vxlan: Avoid unaligned access in vxlan_build_skb() Sowmini Varadhan
2016-09-20 15:31 ` Tom Herbert
2016-09-20 15:49   ` Sowmini Varadhan
2016-09-20 16:11 ` Jiri Benc
2016-09-20 16:31   ` Sowmini Varadhan
2016-09-20 16:43     ` Jiri Benc
2016-09-20 17:07       ` Sowmini Varadhan
2016-09-20 17:15         ` Jiri Benc
2016-09-20 17:09       ` Jiri Benc
2016-09-20 17:19         ` Tom Herbert
2016-09-20 17:24         ` Sowmini Varadhan
2016-09-22  5:52         ` David Miller
2016-09-22 21:30           ` Sowmini Varadhan
2016-09-23 12:06             ` David Miller
2016-09-23 14:17               ` Alexander Duyck
2016-09-23 17:20                 ` Sowmini Varadhan
2016-09-23 17:38                   ` Alexander Duyck
2016-09-23 23:41                     ` Sowmini Varadhan
2016-09-24  0:43                       ` Alexander Duyck
2016-09-28 17:03                         ` Sowmini Varadhan
2016-09-28 18:08                           ` Alexander Duyck
2016-09-28 19:56                             ` Sowmini Varadhan
2016-09-20 16:45 ` Hannes Frederic Sowa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.