Re: [PATCH net] ip6_tunnel: set inner ipproto before ip6_tnl_encap.
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date: 2020-10-16 17:56:26
On Fri, Oct 16, 2020 at 7:14 AM Alexander Ovechkin [off-list ref] wrote:
ip6_tnl_encap assigns to proto transport protocol which encapsulates inner packet, but we must pass to set_inner_ipproto protocol of that inner packet. Calling set_inner_ipproto after ip6_tnl_encap might break gso. For example, in case of encapsulating ipv6 packet in fou6 packet, inner_ipproto would be set to IPPROTO_UDP instead of IPPROTO_IPV6. This would lead to incorrect calling sequence of gso functions: ipv6_gso_segment -> udp6_ufo_fragment -> skb_udp_tunnel_segment -> udp6_ufo_fragment instead of: ipv6_gso_segment -> udp6_ufo_fragment -> skb_udp_tunnel_segment -> ip6ip6_gso_segment Signed-off-by: Alexander Ovechkin <redacted>
Commit 6c11fbf97e69 ("ip6_tunnel: add MPLS transmit support") moved
the call from ip6_tnl_encap's caller to inside ip6_tnl_encap.
It makes sense that that likely broke this behavior for UDP (L4) tunnels.
But it was moved on purpose to avoid setting the inner protocol to
IPPROTO_MPLS. That needs to use skb->inner_protocol to further
segment.
I suspect we need to set this before or after conditionally to avoid
breaking that use case.