Message ID | 1430927775.669.2.camel@myriabit.com |
---|---|
State | Changes Requested, archived |
Delegated to: | David Miller |
Headers | show |
From: Justin Cormack <justin@myriabit.com> Date: Wed, 06 May 2015 16:56:15 +0100 > 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 Justin Cormack <justin@netbsd.org> The correct format of a signoff is "Signed-off-by: " The exact format is important because scripts, GIT tools, and web applications parse these tags. Also please format your commit message to ~80 columns. Please fix this up and resubmit, thanks. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c index 8c350c5..f37e8f9 100644 --- a/drivers/net/macvtap.c +++ b/drivers/net/macvtap.c @@ -1101,6 +1101,35 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd, rtnl_unlock(); 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: return -EINVAL; }