Skip to contentSkip to conversation

net: Copy inner L3 and L4 headers as unaligned on GRE TEB

PATCH In review Alexander Duyck 4 participants 5 messages Feb 9, 2016 – Feb 16, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: Copy inner L3 and L4 headers as unaligned on GRE TEB

This patch corrects the unaligned accesses seen on GRE TEB tunnels when generating hash keys. Specifically what this patch does is make it so that we force the use of skb_copy_bits when the GRE inner headers will be unaligned due to NET_IP_ALIGNED being a non-zero value.

---

I don't have the ability to test it but this should fix flow dissector for GRE TEB tunnels traffic seen on architectures that require network and transport headers to be 4 byte aligned.

 net/core/flow_dissector.c |    7 +++++++
 1 file changed, 7 insertions(+)
net/core/flow_dissector.c +7 -0
index 699b2c415cb0..9c181ba7263e 100644
@@ -402,6 +402,13 @@ ip_proto_again:
 				goto out_bad;
 			proto = eth->h_proto;
 			nhoff += sizeof(*eth);
+
+			/* Cap headers that we access via pointers at the
+			 * end of the Ethernet header as our maximum alignment
+			 * at that point is only 2 bytes.
+			 */
+			if (NET_IP_ALIGN)
+				hlen = nhoff;
 		}
 
 		key_control->flags |= FLOW_DIS_ENCAPSULATION;
#1 lore raw
Quoted 20 lines · Alexander Duyck

This patch corrects the unaligned accesses seen on GRE TEB tunnels when generating hash keys. Specifically what this patch does is make it so that we force the use of skb_copy_bits when the GRE inner headers will be unaligned due to NET_IP_ALIGNED being a non-zero value.

---

I don't have the ability to test it but this should fix flow dissector for GRE TEB tunnels traffic seen on architectures that require network and transport headers to be 4 byte aligned.

 net/core/flow_dissector.c |    7 +++++++
 1 file changed, 7 insertions(+)
net/core/flow_dissector.c +0 -0
index 699b2c415cb0..9c181ba7263e 100644

net/core/flow_dissector.c ip_proto_again: · line 411

Quoted 10 lines
net/core/flow_dissector.c +7 -0
@@ -402,6 +402,13 @@ ip_proto_again:
                                goto out_bad;
                        proto = eth->h_proto;
                        nhoff += sizeof(*eth);
+
+                       /* Cap headers that we access via pointers at the
+                        * end of the Ethernet header as our maximum alignment
+                        * at that point is only 2 bytes.
+                        */
+                       if (NET_IP_ALIGN)
+                               hlen = nhoff;

I think this should be:

if (NET_IP_ALIGN)

     goto out_good;
Quoted 4 lines
net/core/flow_dissector.c +0 -0
                }
 
                key_control->flags |= FLOW_DIS_ENCAPSULATION;
#2 lore raw
Quoted 34 lines · Tom Herbert
Quoted 20 lines · Alexander Duyck

This patch corrects the unaligned accesses seen on GRE TEB tunnels when generating hash keys. Specifically what this patch does is make it so that we force the use of skb_copy_bits when the GRE inner headers will be unaligned due to NET_IP_ALIGNED being a non-zero value.

---

I don't have the ability to test it but this should fix flow dissector for GRE TEB tunnels traffic seen on architectures that require network and transport headers to be 4 byte aligned.

 net/core/flow_dissector.c |    7 +++++++
 1 file changed, 7 insertions(+)
net/core/flow_dissector.c +0 -0
index 699b2c415cb0..9c181ba7263e 100644

net/core/flow_dissector.c ip_proto_again: · line 411

Quoted 10 lines
net/core/flow_dissector.c +7 -0
@@ -402,6 +402,13 @@ ip_proto_again:
                                goto out_bad;
                        proto = eth->h_proto;
                        nhoff += sizeof(*eth);
+
+                       /* Cap headers that we access via pointers at the
+                        * end of the Ethernet header as our maximum alignment
+                        * at that point is only 2 bytes.
+                        */
+                       if (NET_IP_ALIGN)
+                               hlen = nhoff;

I think this should be:

Quoted 3 lines

if (NET_IP_ALIGN)

     goto out_good;

That is no good since we already updated proto with the inner header protocol value. I would prefer to parse the entire header and just keep the behavior consistent between IP aligned and DMA aligned systems.

The only change in behavior is that the reported header length from the function eth_get_headlen will only pull to the end of the Ethernet header since we are now only reporting the aligned IP header length.

Otherwise if we need to exit we should probably exit with "goto out_bad"

- Alex

Acked-by on v1 1/1
#3 lore raw
In reply to Alexander Duyck
Quoted 6 lines · Alexander Duyck

This patch corrects the unaligned accesses seen on GRE TEB tunnels when generating hash keys. Specifically what this patch does is make it so that we force the use of skb_copy_bits when the GRE inner headers will be unaligned due to NET_IP_ALIGNED being a non-zero value.

Quoted 28 lines

---

I don't have the ability to test it but this should fix flow dissector for GRE TEB tunnels traffic seen on architectures that require network and transport headers to be 4 byte aligned.

 net/core/flow_dissector.c |    7 +++++++
 1 file changed, 7 insertions(+)
net/core/flow_dissector.c +7 -0
index 699b2c415cb0..9c181ba7263e 100644
@@ -402,6 +402,13 @@ ip_proto_again:
                                goto out_bad;
                        proto = eth->h_proto;
                        nhoff += sizeof(*eth);
+
+                       /* Cap headers that we access via pointers at the
+                        * end of the Ethernet header as our maximum alignment
+                        * at that point is only 2 bytes.
+                        */
+                       if (NET_IP_ALIGN)
+                               hlen = nhoff;
                }
 
                key_control->flags |= FLOW_DIS_ENCAPSULATION;
maintainer
#4 lore raw
In reply to Alexander Duyck

From: Alexander Duyck <[email protected]>
Date: Tue, 09 Feb 2016 06:14:43 -0800

Quoted 6 lines

This patch corrects the unaligned accesses seen on GRE TEB tunnels when generating hash keys. Specifically what this patch does is make it so that we force the use of skb_copy_bits when the GRE inner headers will be unaligned due to NET_IP_ALIGNED being a non-zero value.

Applied and queued up for -stable, thanks Alex.