--- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -937,6 +937,11 @@ static int ipgre_tunnel_validate(struct if (flags & (GRE_VERSION|GRE_ROUTING)) return -EINVAL; + if (data[IFLA_GRE_COLLECT_METADATA] && + data[IFLA_GRE_ENCAP_TYPE] && + nla_get_u16(data[IFLA_GRE_ENCAP_TYPE]) != TUNNEL_ENCAP_NONE) + return -EINVAL; + return 0; }