Skip to contentSkip to conversation

gro: Allow tunnel stacking in the case of FOU/GUE

PATCH Superseded Alexander Duyck 5 participants 13 messages Mar 28, 2016 – Mar 29, 2016

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gro: Allow tunnel stacking in the case of FOU/GUE

This patch should fix the issues seen with a recent fix to prevent tunnel-in-tunnel frames from being generated with GRO. The fix itself is correct for now as long as we do not add any devices that support NETIF_F_GSO_GRE_CSUM. When such a device is added it could have the potential to mess things up due to the fact that the outer transport header points to the outer UDP header and not the GRE header as would be expected.

Fixes fac8e0f579695 ("tunnels: Don't apply GRO to multiple layers of encapsulation.")

---

This should allow us to keep the fix that Jesse added without breaking the 3 cases that Tom called out in terms of FOU/GUE.

Additional work will be needed in net-next as we probably need to make it so that offloads work correctly when we get around to supporting NETIF_F_GSO_GRE_CSUM.

 net/ipv4/fou.c |   32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
net/ipv4/fou.c +32 -0
index 4136da9275b2..2c30256ee959 100644
@@ -195,6 +195,22 @@ static struct sk_buff **fou_gro_receive(struct sk_buff **head,
 	u8 proto = NAPI_GRO_CB(skb)->proto;
 	const struct net_offload **offloads;
 
+	switch (proto) {
+	case IPPROTO_IPIP:
+	case IPPROTO_IPV6:
+	case IPPROTO_GRE:
+		/* We can clear the encap_mark for these 3 protocols as
+		 * we are either adding an L4 tunnel header to the outer
+		 * L3 tunnel header, or we are are simply treating the
+		 * GRE tunnel header as though it is a UDP protocol
+		 * specific header such as VXLAN or GENEVE.
+		 */
+		NAPI_GRO_CB(skb)->encap_mark = 0;
+		/* fall-through */
+	default:
+		break;
+	}
+
 	rcu_read_lock();
 	offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
 	ops = rcu_dereference(offloads[proto]);
@@ -359,6 +375,22 @@ static struct sk_buff **gue_gro_receive(struct sk_buff **head,
 		NAPI_GRO_CB(p)->flush |= NAPI_GRO_CB(p)->flush_id;
 	}
 
+	switch (guehdr->proto_ctype) {
+	case IPPROTO_IPIP:
+	case IPPROTO_IPV6:
+	case IPPROTO_GRE:
+		/* We can clear the encap_mark for these 3 protocols as
+		 * we are either adding an L4 tunnel header to the outer
+		 * L3 tunnel header, or we are are simply treating the
+		 * GRE tunnel header as though it is a UDP protocol
+		 * specific header such as VXLAN or GENEVE.
+		 */
+		NAPI_GRO_CB(skb)->encap_mark = 0;
+		/* fall-through */
+	default:
+		break;
+	}
+
 	rcu_read_lock();
 	offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
 	ops = rcu_dereference(offloads[guehdr->proto_ctype]);
#1 lore raw
Quoted 7 lines · Alexander Duyck

This patch should fix the issues seen with a recent fix to prevent tunnel-in-tunnel frames from being generated with GRO. The fix itself is correct for now as long as we do not add any devices that support NETIF_F_GSO_GRE_CSUM. When such a device is added it could have the potential to mess things up due to the fact that the outer transport header points to the outer UDP header and not the GRE header as would be expected.

Did you test this?

Quoted 65 lines
Fixes fac8e0f579695 ("tunnels: Don't apply GRO to multiple layers of encapsulation.")

---

This should allow us to keep the fix that Jesse added without breaking the 3 cases that Tom called out in terms of FOU/GUE.

Additional work will be needed in net-next as we probably need to make it so that offloads work correctly when we get around to supporting NETIF_F_GSO_GRE_CSUM.

 net/ipv4/fou.c |   32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
net/ipv4/fou.c +32 -0
index 4136da9275b2..2c30256ee959 100644
@@ -195,6 +195,22 @@ static struct sk_buff **fou_gro_receive(struct sk_buff **head,
        u8 proto = NAPI_GRO_CB(skb)->proto;
        const struct net_offload **offloads;
 
+       switch (proto) {
+       case IPPROTO_IPIP:
+       case IPPROTO_IPV6:
+       case IPPROTO_GRE:
+               /* We can clear the encap_mark for these 3 protocols as
+                * we are either adding an L4 tunnel header to the outer
+                * L3 tunnel header, or we are are simply treating the
+                * GRE tunnel header as though it is a UDP protocol
+                * specific header such as VXLAN or GENEVE.
+                */
+               NAPI_GRO_CB(skb)->encap_mark = 0;
+               /* fall-through */
+       default:
+               break;
+       }
+
        rcu_read_lock();
        offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
        ops = rcu_dereference(offloads[proto]);
@@ -359,6 +375,22 @@ static struct sk_buff **gue_gro_receive(struct sk_buff **head,
                NAPI_GRO_CB(p)->flush |= NAPI_GRO_CB(p)->flush_id;
        }
 
+       switch (guehdr->proto_ctype) {
+       case IPPROTO_IPIP:
+       case IPPROTO_IPV6:
+       case IPPROTO_GRE:
+               /* We can clear the encap_mark for these 3 protocols as
+                * we are either adding an L4 tunnel header to the outer
+                * L3 tunnel header, or we are are simply treating the
+                * GRE tunnel header as though it is a UDP protocol
+                * specific header such as VXLAN or GENEVE.
+                */
+               NAPI_GRO_CB(skb)->encap_mark = 0;
+               /* fall-through */
+       default:
+               break;
+       }
+
        rcu_read_lock();
        offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
        ops = rcu_dereference(offloads[guehdr->proto_ctype]);
#2 lore raw
In reply to Alexander Duyck
Quoted 8 lines · Alexander Duyck

This patch should fix the issues seen with a recent fix to prevent tunnel-in-tunnel frames from being generated with GRO. The fix itself is correct for now as long as we do not add any devices that support NETIF_F_GSO_GRE_CSUM. When such a device is added it could have the potential to mess things up due to the fact that the outer transport header points to the outer UDP header and not the GRE header as would be expected.

Fixes fac8e0f579695 ("tunnels: Don't apply GRO to multiple layers of encapsulation.")

This could only fix FOU/GUE. It is very possible someone else could happily be doing some other layered encapsulation and never had a problem before, so the decision to start enforcing only a single layer of encapsulation for GRO would still break them. I still think we should revert the patch, and for next version fixes things to that any combination/nesting of encapsulation is supported, and if there are exceptions to that support they need be clearly documented.

Quoted 64 lines

---

This should allow us to keep the fix that Jesse added without breaking the 3 cases that Tom called out in terms of FOU/GUE.

Additional work will be needed in net-next as we probably need to make it so that offloads work correctly when we get around to supporting NETIF_F_GSO_GRE_CSUM.

 net/ipv4/fou.c |   32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
net/ipv4/fou.c +32 -0
index 4136da9275b2..2c30256ee959 100644
@@ -195,6 +195,22 @@ static struct sk_buff **fou_gro_receive(struct sk_buff **head,
        u8 proto = NAPI_GRO_CB(skb)->proto;
        const struct net_offload **offloads;
 
+       switch (proto) {
+       case IPPROTO_IPIP:
+       case IPPROTO_IPV6:
+       case IPPROTO_GRE:
+               /* We can clear the encap_mark for these 3 protocols as
+                * we are either adding an L4 tunnel header to the outer
+                * L3 tunnel header, or we are are simply treating the
+                * GRE tunnel header as though it is a UDP protocol
+                * specific header such as VXLAN or GENEVE.
+                */
+               NAPI_GRO_CB(skb)->encap_mark = 0;
+               /* fall-through */
+       default:
+               break;
+       }
+
        rcu_read_lock();
        offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
        ops = rcu_dereference(offloads[proto]);
@@ -359,6 +375,22 @@ static struct sk_buff **gue_gro_receive(struct sk_buff **head,
                NAPI_GRO_CB(p)->flush |= NAPI_GRO_CB(p)->flush_id;
        }
 
+       switch (guehdr->proto_ctype) {
+       case IPPROTO_IPIP:
+       case IPPROTO_IPV6:
+       case IPPROTO_GRE:
+               /* We can clear the encap_mark for these 3 protocols as
+                * we are either adding an L4 tunnel header to the outer
+                * L3 tunnel header, or we are are simply treating the
+                * GRE tunnel header as though it is a UDP protocol
+                * specific header such as VXLAN or GENEVE.
+                */
+               NAPI_GRO_CB(skb)->encap_mark = 0;
+               /* fall-through */
+       default:
+               break;
+       }
+
        rcu_read_lock();
        offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
        ops = rcu_dereference(offloads[guehdr->proto_ctype]);
#3 lore raw
Quoted 10 lines · Tom Herbert
Quoted 8 lines · Alexander Duyck

This patch should fix the issues seen with a recent fix to prevent tunnel-in-tunnel frames from being generated with GRO. The fix itself is correct for now as long as we do not add any devices that support NETIF_F_GSO_GRE_CSUM. When such a device is added it could have the potential to mess things up due to the fact that the outer transport header points to the outer UDP header and not the GRE header as would be expected.

Fixes fac8e0f579695 ("tunnels: Don't apply GRO to multiple layers of encapsulation.")
Quoted 7 lines

This could only fix FOU/GUE. It is very possible someone else could happily be doing some other layered encapsulation and never had a problem before, so the decision to start enforcing only a single layer of encapsulation for GRO would still break them. I still think we should revert the patch, and for next version fixes things to that any combination/nesting of encapsulation is supported, and if there are exceptions to that support they need be clearly documented.

It was pointed out to me that prior to my patch, it was also possible to remotely cause a stack overflow by filling up a packet with tunnel headers and letting GRO descend through them over and over again.

Tom, I'm sorry that you don't like how I fixed this issue but there really, truly is a bug here. I gave you a specific example to be clear but that doesn't mean that is the only case. I am aware that the bug is not encountered in all situations and that the fix removes an optimization in some of those but I think that ensuring correct behavior must come first.

#4 lore raw
Quoted 19 lines · Jesse Gross
Quoted 10 lines · Tom Herbert
Quoted 8 lines · Alexander Duyck

This patch should fix the issues seen with a recent fix to prevent tunnel-in-tunnel frames from being generated with GRO. The fix itself is correct for now as long as we do not add any devices that support NETIF_F_GSO_GRE_CSUM. When such a device is added it could have the potential to mess things up due to the fact that the outer transport header points to the outer UDP header and not the GRE header as would be expected.

Fixes fac8e0f579695 ("tunnels: Don't apply GRO to multiple layers of encapsulation.")
Quoted 7 lines

This could only fix FOU/GUE. It is very possible someone else could happily be doing some other layered encapsulation and never had a problem before, so the decision to start enforcing only a single layer of encapsulation for GRO would still break them. I still think we should revert the patch, and for next version fixes things to that any combination/nesting of encapsulation is supported, and if there are exceptions to that support they need be clearly documented.

Quoted 4 lines

It was pointed out to me that prior to my patch, it was also possible to remotely cause a stack overflow by filling up a packet with tunnel headers and letting GRO descend through them over and over again.

Then the fix would be set set a reasonable limit on the number of encapsulation levels.

Quoted 6 lines

Tom, I'm sorry that you don't like how I fixed this issue but there really, truly is a bug here. I gave you a specific example to be clear but that doesn't mean that is the only case. I am aware that the bug is not encountered in all situations and that the fix removes an optimization in some of those but I think that ensuring correct behavior must come first.

The example you gave results in packet loss, this is not incorrectness. Actually reproduce a real issue that leads to incorrectness and then we can talk about a solution.

Tom

#5 lore raw
Quoted 34 lines · Tom Herbert
Quoted 19 lines · Jesse Gross
Quoted 10 lines · Tom Herbert
Quoted 8 lines · Alexander Duyck

This patch should fix the issues seen with a recent fix to prevent tunnel-in-tunnel frames from being generated with GRO. The fix itself is correct for now as long as we do not add any devices that support NETIF_F_GSO_GRE_CSUM. When such a device is added it could have the potential to mess things up due to the fact that the outer transport header points to the outer UDP header and not the GRE header as would be expected.

Fixes fac8e0f579695 ("tunnels: Don't apply GRO to multiple layers of encapsulation.")
Quoted 7 lines

This could only fix FOU/GUE. It is very possible someone else could happily be doing some other layered encapsulation and never had a problem before, so the decision to start enforcing only a single layer of encapsulation for GRO would still break them. I still think we should revert the patch, and for next version fixes things to that any combination/nesting of encapsulation is supported, and if there are exceptions to that support they need be clearly documented.

Quoted 4 lines

It was pointed out to me that prior to my patch, it was also possible to remotely cause a stack overflow by filling up a packet with tunnel headers and letting GRO descend through them over and over again.

Then the fix would be set set a reasonable limit on the number of encapsulation levels.

Quoted 6 lines

Tom, I'm sorry that you don't like how I fixed this issue but there really, truly is a bug here. I gave you a specific example to be clear but that doesn't mean that is the only case. I am aware that the bug is not encountered in all situations and that the fix removes an optimization in some of those but I think that ensuring correct behavior must come first.

Quoted 3 lines

The example you gave results in packet loss, this is not incorrectness. Actually reproduce a real issue that leads to incorrectness and then we can talk about a solution.

Tom,

Just take a look in the __skb_udp_tunnel_segment or gre_gso_segment code. Then tell me how we are supposed to deal with the fact that the GSO code expects skb_inner_network_offset() to be valid. If you have more than an inner and an outer network header we cannot. So we cannot put GRE in UDP, or UDP in GRE if there is a network header between them. The FOU/GUE code gets around this because in the IPIP and SIT cases you are adding an L4 header between two L3 headers. The GRE case works because you essentially convert the GRE header into a tunnel header like VXLAN or GENEVE and we just overwrite the outer transport header offset.

What it comes down to is that we can only support 2 network headers per frame. One for the inner and one for the outer. That is why we can have an exception for GUE as it only has 2 network headers. If we had multiple levels of UDP, or GRE, or 2 levels of network headers either before or after either UDP or GRE we cannot support segmentation because the code will blow up and generate a malformed frame.

- Alex

#6 lore raw
Quoted 52 lines · Alexander Duyck
Quoted 34 lines · Tom Herbert
Quoted 19 lines · Jesse Gross
Quoted 10 lines · Tom Herbert
Quoted 8 lines · Alexander Duyck

This patch should fix the issues seen with a recent fix to prevent tunnel-in-tunnel frames from being generated with GRO. The fix itself is correct for now as long as we do not add any devices that support NETIF_F_GSO_GRE_CSUM. When such a device is added it could have the potential to mess things up due to the fact that the outer transport header points to the outer UDP header and not the GRE header as would be expected.

Fixes fac8e0f579695 ("tunnels: Don't apply GRO to multiple layers of encapsulation.")
Quoted 7 lines

This could only fix FOU/GUE. It is very possible someone else could happily be doing some other layered encapsulation and never had a problem before, so the decision to start enforcing only a single layer of encapsulation for GRO would still break them. I still think we should revert the patch, and for next version fixes things to that any combination/nesting of encapsulation is supported, and if there are exceptions to that support they need be clearly documented.

Quoted 4 lines

It was pointed out to me that prior to my patch, it was also possible to remotely cause a stack overflow by filling up a packet with tunnel headers and letting GRO descend through them over and over again.

Then the fix would be set set a reasonable limit on the number of encapsulation levels.

Quoted 6 lines

Tom, I'm sorry that you don't like how I fixed this issue but there really, truly is a bug here. I gave you a specific example to be clear but that doesn't mean that is the only case. I am aware that the bug is not encountered in all situations and that the fix removes an optimization in some of those but I think that ensuring correct behavior must come first.

Quoted 3 lines

The example you gave results in packet loss, this is not incorrectness. Actually reproduce a real issue that leads to incorrectness and then we can talk about a solution.

Tom,

Just take a look in the __skb_udp_tunnel_segment or gre_gso_segment code. Then tell me how we are supposed to deal with the fact that the GSO code expects skb_inner_network_offset() to be valid. If you have more than an inner and an outer network header we cannot. So we cannot put GRE in UDP, or UDP in GRE if there is a network header between them. The FOU/GUE code gets around this because in the IPIP and SIT cases you are adding an L4 header between two L3 headers. The GRE case works because you essentially convert the GRE header into a tunnel header like VXLAN or GENEVE and we just overwrite the outer transport header offset.

Quoted 8 lines

What it comes down to is that we can only support 2 network headers per frame. One for the inner and one for the outer. That is why we can have an exception for GUE as it only has 2 network headers. If we had multiple levels of UDP, or GRE, or 2 levels of network headers either before or after either UDP or GRE we cannot support segmentation because the code will blow up and generate a malformed frame.

If you apply Edward's jumbo L2 header concept then

Eth|IP|UDP|VXLAN|Eth|IP|UDP|GUE|GRE|IPIP|IPv6|TCP|payload becomes
Eth|IP|UDP|encapsulation-hdrs|IPv6|TCP|Payload. One set of outer

headers, one set of inner headers. The rules that encapsulation_hdrs don't contain fields that need to be modified for every segment need to be supported in GRO and the stack when it generates such a configuration.

Quoted 1 line

- Alex

author
#7 lore raw
Quoted 62 lines · Tom Herbert
Quoted 52 lines · Alexander Duyck
Quoted 34 lines · Tom Herbert
Quoted 19 lines · Jesse Gross
Quoted 10 lines · Tom Herbert
Quoted 8 lines · Alexander Duyck

This patch should fix the issues seen with a recent fix to prevent tunnel-in-tunnel frames from being generated with GRO. The fix itself is correct for now as long as we do not add any devices that support NETIF_F_GSO_GRE_CSUM. When such a device is added it could have the potential to mess things up due to the fact that the outer transport header points to the outer UDP header and not the GRE header as would be expected.

Fixes fac8e0f579695 ("tunnels: Don't apply GRO to multiple layers of encapsulation.")
Quoted 7 lines

This could only fix FOU/GUE. It is very possible someone else could happily be doing some other layered encapsulation and never had a problem before, so the decision to start enforcing only a single layer of encapsulation for GRO would still break them. I still think we should revert the patch, and for next version fixes things to that any combination/nesting of encapsulation is supported, and if there are exceptions to that support they need be clearly documented.

Quoted 4 lines

It was pointed out to me that prior to my patch, it was also possible to remotely cause a stack overflow by filling up a packet with tunnel headers and letting GRO descend through them over and over again.

Then the fix would be set set a reasonable limit on the number of encapsulation levels.

Quoted 6 lines

Tom, I'm sorry that you don't like how I fixed this issue but there really, truly is a bug here. I gave you a specific example to be clear but that doesn't mean that is the only case. I am aware that the bug is not encountered in all situations and that the fix removes an optimization in some of those but I think that ensuring correct behavior must come first.

Quoted 3 lines

The example you gave results in packet loss, this is not incorrectness. Actually reproduce a real issue that leads to incorrectness and then we can talk about a solution.

Tom,

Just take a look in the __skb_udp_tunnel_segment or gre_gso_segment code. Then tell me how we are supposed to deal with the fact that the GSO code expects skb_inner_network_offset() to be valid. If you have more than an inner and an outer network header we cannot. So we cannot put GRE in UDP, or UDP in GRE if there is a network header between them. The FOU/GUE code gets around this because in the IPIP and SIT cases you are adding an L4 header between two L3 headers. The GRE case works because you essentially convert the GRE header into a tunnel header like VXLAN or GENEVE and we just overwrite the outer transport header offset.

Quoted 8 lines

What it comes down to is that we can only support 2 network headers per frame. One for the inner and one for the outer. That is why we can have an exception for GUE as it only has 2 network headers. If we had multiple levels of UDP, or GRE, or 2 levels of network headers either before or after either UDP or GRE we cannot support segmentation because the code will blow up and generate a malformed frame.

Quoted 7 lines

If you apply Edward's jumbo L2 header concept then

Eth|IP|UDP|VXLAN|Eth|IP|UDP|GUE|GRE|IPIP|IPv6|TCP|payload becomes
Eth|IP|UDP|encapsulation-hdrs|IPv6|TCP|Payload. One set of outer

headers, one set of inner headers. The rules that encapsulation_hdrs don't contain fields that need to be modified for every segment need to be supported in GRO and the stack when it generates such a configuration.

Thats all well and good but nothing like that exists now. So you cannot expect us to fix the kernel to support code that isn't there. In addition there were a number of issues with the jumbo L2 header approach. That was one of the reasons why I went with the jumbo L3 header approach as it is much easier to be compliant with all the RFCs.

We might be able to get some of that supported for net-next but things are going to be limited. We need to have the UDP tunnels actually setting the DF bit which as far as I know none of them do now. In addition we will have to add rules for all the encapsulated types so that we can enforce the outer IP header incrementing in the event that DF is not set. Then we will also have to go through and make certain that we have the DF bit set in all headers between the transport and the outer network header in order to allow support for GSO partial.

What you are describing is no small task. There are bugs that need to be fixed now in net. We can try to get the features you want pushed for net-next but they don't exist now so locking down GRO so that it matches the feature set provided by GSO is not a regression.

- Alex

#8 lore raw
Quoted 71 lines · Alex Duyck
Quoted 62 lines · Tom Herbert
Quoted 52 lines · Alexander Duyck
Quoted 34 lines · Tom Herbert
Quoted 19 lines · Jesse Gross
Quoted 10 lines · Tom Herbert
Quoted 8 lines · Alexander Duyck

This patch should fix the issues seen with a recent fix to prevent tunnel-in-tunnel frames from being generated with GRO. The fix itself is correct for now as long as we do not add any devices that support NETIF_F_GSO_GRE_CSUM. When such a device is added it could have the potential to mess things up due to the fact that the outer transport header points to the outer UDP header and not the GRE header as would be expected.

Fixes fac8e0f579695 ("tunnels: Don't apply GRO to multiple layers of encapsulation.")
Quoted 7 lines

This could only fix FOU/GUE. It is very possible someone else could happily be doing some other layered encapsulation and never had a problem before, so the decision to start enforcing only a single layer of encapsulation for GRO would still break them. I still think we should revert the patch, and for next version fixes things to that any combination/nesting of encapsulation is supported, and if there are exceptions to that support they need be clearly documented.

Quoted 4 lines

It was pointed out to me that prior to my patch, it was also possible to remotely cause a stack overflow by filling up a packet with tunnel headers and letting GRO descend through them over and over again.

Then the fix would be set set a reasonable limit on the number of encapsulation levels.

Quoted 6 lines

Tom, I'm sorry that you don't like how I fixed this issue but there really, truly is a bug here. I gave you a specific example to be clear but that doesn't mean that is the only case. I am aware that the bug is not encountered in all situations and that the fix removes an optimization in some of those but I think that ensuring correct behavior must come first.

Quoted 3 lines

The example you gave results in packet loss, this is not incorrectness. Actually reproduce a real issue that leads to incorrectness and then we can talk about a solution.

Tom,

Just take a look in the __skb_udp_tunnel_segment or gre_gso_segment code. Then tell me how we are supposed to deal with the fact that the GSO code expects skb_inner_network_offset() to be valid. If you have more than an inner and an outer network header we cannot. So we cannot put GRE in UDP, or UDP in GRE if there is a network header between them. The FOU/GUE code gets around this because in the IPIP and SIT cases you are adding an L4 header between two L3 headers. The GRE case works because you essentially convert the GRE header into a tunnel header like VXLAN or GENEVE and we just overwrite the outer transport header offset.

Quoted 8 lines

What it comes down to is that we can only support 2 network headers per frame. One for the inner and one for the outer. That is why we can have an exception for GUE as it only has 2 network headers. If we had multiple levels of UDP, or GRE, or 2 levels of network headers either before or after either UDP or GRE we cannot support segmentation because the code will blow up and generate a malformed frame.

Quoted 7 lines

If you apply Edward's jumbo L2 header concept then

Eth|IP|UDP|VXLAN|Eth|IP|UDP|GUE|GRE|IPIP|IPv6|TCP|payload becomes
Eth|IP|UDP|encapsulation-hdrs|IPv6|TCP|Payload. One set of outer

headers, one set of inner headers. The rules that encapsulation_hdrs don't contain fields that need to be modified for every segment need to be supported in GRO and the stack when it generates such a configuration.

Quoted 2 lines

Thats all well and good but nothing like that exists now. So you cannot expect us to fix the kernel to support code that isn't there.

No, but I do expect that you support code that is already there. There was apparently zero testing done on the original patch and it caused one very obvious regression. So how can we have any confidence whatsoever that this patch doesn't break other things? Furthermore, with all these claims of bugs I still don't see that _anyone_ has taken the time to reproduce any issue and show that this patch materially fixes any thing. I seriously don't understand how basic testing could be such a challenge.

Anyway, what I expect is moot. It's up to davem to decide what to do with this...

Tom

Quoted 20 lines

In addition there were a number of issues with the jumbo L2 header approach. That was one of the reasons why I went with the jumbo L3 header approach as it is much easier to be compliant with all the RFCs.

We might be able to get some of that supported for net-next but things are going to be limited. We need to have the UDP tunnels actually setting the DF bit which as far as I know none of them do now. In addition we will have to add rules for all the encapsulated types so that we can enforce the outer IP header incrementing in the event that DF is not set. Then we will also have to go through and make certain that we have the DF bit set in all headers between the transport and the outer network header in order to allow support for GSO partial.

What you are describing is no small task. There are bugs that need to be fixed now in net. We can try to get the features you want pushed for net-next but they don't exist now so locking down GRO so that it matches the feature set provided by GSO is not a regression.

- Alex

maintainer
#9 lore raw

From: Tom Herbert <[email protected]>
Date: Mon, 28 Mar 2016 21:51:17 -0700

Quoted 11 lines

No, but I do expect that you support code that is already there. There was apparently zero testing done on the original patch and it caused one very obvious regression. So how can we have any confidence whatsoever that this patch doesn't break other things? Furthermore, with all these claims of bugs I still don't see that _anyone_ has taken the time to reproduce any issue and show that this patch materially fixes any thing. I seriously don't understand how basic testing could be such a challenge.

Anyway, what I expect is moot. It's up to davem to decide what to do with this...

You being upset with a lack of testing is one issue, and is legitimate.

But the fact that we can't support, and never could support, more than one network header at a time except in a very special case for GRO is very real. And you must acknowledge that this was a very shaky foundation upon which to erect the kinds of things you expect to work.

#10 lore raw
In reply to Alexander Duyck
Quoted 9 lines · Alexander Duyck

This patch should fix the issues seen with a recent fix to prevent tunnel-in-tunnel frames from being generated with GRO. The fix itself is correct for now as long as we do not add any devices that support NETIF_F_GSO_GRE_CSUM. When such a device is added it could have the potential to mess things up due to the fact that the outer transport header points to the outer UDP header and not the GRE header as would be expected.

Fixes fac8e0f579695 ("tunnels: Don't apply GRO to multiple layers of encapsulation.")
Quoted 8 lines

---

This should allow us to keep the fix that Jesse added without breaking the 3 cases that Tom called out in terms of FOU/GUE.

Additional work will be needed in net-next as we probably need to make it so that offloads work correctly when we get around to supporting NETIF_F_GSO_GRE_CSUM.

Thanks, this looks like a reasonable fix to me. I agree that there is more that can be done in the future to improve things but this should restore GRO while still avoiding possible issues.

#11 lore raw
In reply to Alexander Duyck
Quoted 34 lines · Alexander Duyck

This patch should fix the issues seen with a recent fix to prevent tunnel-in-tunnel frames from being generated with GRO. The fix itself is correct for now as long as we do not add any devices that support NETIF_F_GSO_GRE_CSUM. When such a device is added it could have the potential to mess things up due to the fact that the outer transport header points to the outer UDP header and not the GRE header as would be expected.

Fixes fac8e0f579695 ("tunnels: Don't apply GRO to multiple layers of encapsulation.")

---

This should allow us to keep the fix that Jesse added without breaking the 3 cases that Tom called out in terms of FOU/GUE.

Additional work will be needed in net-next as we probably need to make it so that offloads work correctly when we get around to supporting NETIF_F_GSO_GRE_CSUM.

 net/ipv4/fou.c |   32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
net/ipv4/fou.c +5 -0
index 4136da9275b2..2c30256ee959 100644
@@ -195,6 +195,22 @@ static struct sk_buff **fou_gro_receive(struct sk_buff **head,
        u8 proto = NAPI_GRO_CB(skb)->proto;
        const struct net_offload **offloads;
 
+       switch (proto) {
+       case IPPROTO_IPIP:
+       case IPPROTO_IPV6:
+       case IPPROTO_GRE:
+               /* We can clear the encap_mark for these 3 protocols as

net/ipv4/fou.c static struct sk_buff **fou_gro_receive(struct sk_buff **head, · line 212

Quoted 10 lines
net/ipv4/fou.c +10 -0
+                * we are either adding an L4 tunnel header to the outer
+                * L3 tunnel header, or we are are simply treating the
+                * GRE tunnel header as though it is a UDP protocol
+                * specific header such as VXLAN or GENEVE.
+                */
+               NAPI_GRO_CB(skb)->encap_mark = 0;
+               /* fall-through */
+       default:
+               break;
+       }

Switch statement is not needed, just do NAPI_GRO_CB(skb)->encap_mark = 0;

Quoted 14 lines
net/ipv4/fou.c +7 -0
+
        rcu_read_lock();
        offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
        ops = rcu_dereference(offloads[proto]);
@@ -359,6 +375,22 @@ static struct sk_buff **gue_gro_receive(struct sk_buff **head,
                NAPI_GRO_CB(p)->flush |= NAPI_GRO_CB(p)->flush_id;
        }
 
+       switch (guehdr->proto_ctype) {
+       case IPPROTO_IPIP:
+       case IPPROTO_IPV6:
+       case IPPROTO_GRE:
+               /* We can clear the encap_mark for these 3 protocols as
+                * we are either adding an L4 tunnel header to the outer

net/ipv4/fou.c static struct sk_buff **gue_gro_receive(struct sk_buff **head, · line 393

Quoted 10 lines
net/ipv4/fou.c +10 -0
+                * L3 tunnel header, or we are are simply treating the
+                * GRE tunnel header as though it is a UDP protocol
+                * specific header such as VXLAN or GENEVE.
+                */
+               NAPI_GRO_CB(skb)->encap_mark = 0;
+               /* fall-through */
+       default:
+               break;
+       }
+

Here also.

Quoted 4 lines
net/ipv4/fou.c +0 -0
        rcu_read_lock();
        offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
        ops = rcu_dereference(offloads[guehdr->proto_ctype]);
#12 lore raw
Quoted 65 lines · Tom Herbert
Quoted 34 lines · Alexander Duyck

This patch should fix the issues seen with a recent fix to prevent tunnel-in-tunnel frames from being generated with GRO. The fix itself is correct for now as long as we do not add any devices that support NETIF_F_GSO_GRE_CSUM. When such a device is added it could have the potential to mess things up due to the fact that the outer transport header points to the outer UDP header and not the GRE header as would be expected.

Fixes fac8e0f579695 ("tunnels: Don't apply GRO to multiple layers of encapsulation.")

---

This should allow us to keep the fix that Jesse added without breaking the 3 cases that Tom called out in terms of FOU/GUE.

Additional work will be needed in net-next as we probably need to make it so that offloads work correctly when we get around to supporting NETIF_F_GSO_GRE_CSUM.

 net/ipv4/fou.c |   32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
net/ipv4/fou.c +5 -0
index 4136da9275b2..2c30256ee959 100644
@@ -195,6 +195,22 @@ static struct sk_buff **fou_gro_receive(struct sk_buff **head,
        u8 proto = NAPI_GRO_CB(skb)->proto;
        const struct net_offload **offloads;
 
+       switch (proto) {
+       case IPPROTO_IPIP:
+       case IPPROTO_IPV6:
+       case IPPROTO_GRE:
+               /* We can clear the encap_mark for these 3 protocols as

net/ipv4/fou.c static struct sk_buff **fou_gro_receive(struct sk_buff **head, · line 212

Quoted 10 lines
net/ipv4/fou.c +10 -0
+                * we are either adding an L4 tunnel header to the outer
+                * L3 tunnel header, or we are are simply treating the
+                * GRE tunnel header as though it is a UDP protocol
+                * specific header such as VXLAN or GENEVE.
+                */
+               NAPI_GRO_CB(skb)->encap_mark = 0;
+               /* fall-through */
+       default:
+               break;
+       }

Switch statement is not needed, just do NAPI_GRO_CB(skb)->encap_mark = 0;

Quoted 17 lines
net/ipv4/fou.c +10 -0
+
        rcu_read_lock();
        offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
        ops = rcu_dereference(offloads[proto]);
@@ -359,6 +375,22 @@ static struct sk_buff **gue_gro_receive(struct sk_buff **head,
                NAPI_GRO_CB(p)->flush |= NAPI_GRO_CB(p)->flush_id;
        }
 
+       switch (guehdr->proto_ctype) {
+       case IPPROTO_IPIP:
+       case IPPROTO_IPV6:
+       case IPPROTO_GRE:
+               /* We can clear the encap_mark for these 3 protocols as
+                * we are either adding an L4 tunnel header to the outer
+                * L3 tunnel header, or we are are simply treating the
+                * GRE tunnel header as though it is a UDP protocol
+                * specific header such as VXLAN or GENEVE.
Quoted 13 lines

net/ipv4/fou.c static struct sk_buff **fou_gro_receive(struct sk_buff **head, · line 213

Quoted 7 lines
net/ipv4/fou.c +7 -0
+                */
+               NAPI_GRO_CB(skb)->encap_mark = 0;
+               /* fall-through */
+       default:
+               break;
+       }
+

Here also.

Quoted 4 lines
net/ipv4/fou.c +0 -0
        rcu_read_lock();
        offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
        ops = rcu_dereference(offloads[guehdr->proto_ctype]);

Okay, I can update that and submit a v2. The only real reason why I had the switch statements was out of an abundance of caution since those were the only 3 cases where I knew we would run into issues.

- Alex