提交 b5082083 编写于 作者: J Justin Cormack 提交者: David S. Miller

macvtap add missing ioctls - fix wrapping

The macvtap driver tries to emulate all the ioctls supported by a normal
tun/tap driver, however it was missing the generic SIOCGIFHWADDR and
SIOCSIFHWADDR ioctls to get and set the mac address that are supported
by tun/tap. This patch adds these.
Signed-off-by: NJustin Cormack <justin@netbsd.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 a62b70dd
...@@ -1101,6 +1101,35 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd, ...@@ -1101,6 +1101,35 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
rtnl_unlock(); rtnl_unlock();
return ret; return ret;
case SIOCGIFHWADDR:
rtnl_lock();
vlan = macvtap_get_vlan(q);
if (!vlan) {
rtnl_unlock();
return -ENOLINK;
}
ret = 0;
u = vlan->dev->type;
if (copy_to_user(&ifr->ifr_name, vlan->dev->name, IFNAMSIZ) ||
copy_to_user(&ifr->ifr_hwaddr.sa_data, vlan->dev->dev_addr, ETH_ALEN) ||
put_user(u, &ifr->ifr_hwaddr.sa_family))
ret = -EFAULT;
macvtap_put_vlan(vlan);
rtnl_unlock();
return ret;
case SIOCSIFHWADDR:
rtnl_lock();
vlan = macvtap_get_vlan(q);
if (!vlan) {
rtnl_unlock();
return -ENOLINK;
}
ret = dev_set_mac_address(vlan->dev, &ifr->ifr_hwaddr);
macvtap_put_vlan(vlan);
rtnl_unlock();
return ret;
default: default:
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册