Commit 9e7c5b39 authored by Alexander Ovechkin's avatar Alexander Ovechkin Committed by Jakub Kicinski
Browse files

ip6_tunnel: set inner ipproto before ip6_tnl_encap



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

Fixes: 6c11fbf9 ("ip6_tunnel: add MPLS transmit support")
Signed-off-by: default avatarAlexander Ovechkin <ovov@yandex-team.ru>
Link: https://lore.kernel.org/r/20201029171012.20904-1-ovov@yandex-team.ru


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 07e08873
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1271,6 +1271,8 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
	if (max_headroom > dev->needed_headroom)
		dev->needed_headroom = max_headroom;

	skb_set_inner_ipproto(skb, proto);

	err = ip6_tnl_encap(skb, t, &proto, fl6);
	if (err)
		return err;
@@ -1280,8 +1282,6 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
		ipv6_push_frag_opts(skb, &opt.ops, &proto);
	}

	skb_set_inner_ipproto(skb, proto);

	skb_push(skb, sizeof(struct ipv6hdr));
	skb_reset_network_header(skb);
	ipv6h = ipv6_hdr(skb);