Skip to content

Commit 272502f

Browse files
Mark Tomlinsondavem330
authored andcommitted
gre6: Fix reception with IP6_TNL_F_RCV_DSCP_COPY
When receiving an IPv4 packet inside an IPv6 GRE packet, and the IP6_TNL_F_RCV_DSCP_COPY flag is set on the tunnel, the IPv4 header would get corrupted. This is due to the common ip6_tnl_rcv() function assuming that the inner header is always IPv6. This patch checks the tunnel protocol for IPv4 inner packets, but still defaults to IPv6. Fixes: 308edfd ("gre6: Cleanup GREv6 receive path, call common GRE functions") Signed-off-by: Mark Tomlinson <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e14fd8d commit 272502f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

net/ipv6/ip6_tunnel.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,15 @@ int ip6_tnl_rcv(struct ip6_tnl *t, struct sk_buff *skb,
915915
struct metadata_dst *tun_dst,
916916
bool log_ecn_err)
917917
{
918-
return __ip6_tnl_rcv(t, skb, tpi, tun_dst, ip6ip6_dscp_ecn_decapsulate,
918+
int (*dscp_ecn_decapsulate)(const struct ip6_tnl *t,
919+
const struct ipv6hdr *ipv6h,
920+
struct sk_buff *skb);
921+
922+
dscp_ecn_decapsulate = ip6ip6_dscp_ecn_decapsulate;
923+
if (tpi->proto == htons(ETH_P_IP))
924+
dscp_ecn_decapsulate = ip4ip6_dscp_ecn_decapsulate;
925+
926+
return __ip6_tnl_rcv(t, skb, tpi, tun_dst, dscp_ecn_decapsulate,
919927
log_ecn_err);
920928
}
921929
EXPORT_SYMBOL(ip6_tnl_rcv);

0 commit comments

Comments
 (0)