Skip to content

Commit

Permalink
gre6: Fix reception with IP6_TNL_F_RCV_DSCP_COPY
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Mark Tomlinson authored and davem330 committed Aug 20, 2020
1 parent e14fd8d commit 272502f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion net/ipv6/ip6_tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,15 @@ int ip6_tnl_rcv(struct ip6_tnl *t, struct sk_buff *skb,
struct metadata_dst *tun_dst,
bool log_ecn_err)
{
return __ip6_tnl_rcv(t, skb, tpi, tun_dst, ip6ip6_dscp_ecn_decapsulate,
int (*dscp_ecn_decapsulate)(const struct ip6_tnl *t,
const struct ipv6hdr *ipv6h,
struct sk_buff *skb);

dscp_ecn_decapsulate = ip6ip6_dscp_ecn_decapsulate;
if (tpi->proto == htons(ETH_P_IP))
dscp_ecn_decapsulate = ip4ip6_dscp_ecn_decapsulate;

return __ip6_tnl_rcv(t, skb, tpi, tun_dst, dscp_ecn_decapsulate,
log_ecn_err);
}
EXPORT_SYMBOL(ip6_tnl_rcv);
Expand Down

0 comments on commit 272502f

Please sign in to comment.