/* Map an interface index to its name (SIOCGIFNAME) We need this ioctl for efficient implementation of the if_indextoname() function required by the IPv6 API. Without it, we would have to search all the interfaces to find a match.  */
static int dev_ifname(struct net *net, struct ifreq __user *arg)
/* Map an interface index to its name (SIOCGIFNAME) We need this ioctl for efficient implementation of the if_indextoname() function required by the IPv6 API. Without it, we would have to search all the interfaces to find a match.  */
static int dev_ifname(struct net *net, struct ifreq __user *arg)
{
	struct net_device *dev;
	struct ifreq ifr;
	if (copy_from_user(&ifr, arg, sizeof(struct ifreq)))
		return -EFAULT;
	rcu_read_lock();
	dev = dev_get_by_index_rcu(net, ifr.ifr_ifindex);
	if (!dev) {
		rcu_read_unlock();
		return -ENODEV;
	}
	strcpy(ifr.ifr_name, dev->name);
	rcu_read_unlock();
	if (copy_to_user(arg, &ifr, sizeof(struct ifreq)))
		return -EFAULT;
	return 0;
}