netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] macvtap add missing ioctls
@ 2015-05-06 15:56 Justin Cormack
  2015-05-09 21:40 ` David Miller
  0 siblings, 1 reply; 13+ messages in thread
From: Justin Cormack @ 2015-05-06 15:56 UTC (permalink / raw)
  To: netdev

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>

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;
 	}

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-05-13 18:21 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-06 15:56 [PATCH] macvtap add missing ioctls Justin Cormack
2015-05-09 21:40 ` David Miller
2015-05-10  9:15   ` [PATCH v2] " Justin Cormack
2015-05-10 12:50     ` [PATCH v3] macvtap add missing ioctls - fix wrapping Justin Cormack
2015-05-11 17:49       ` David Miller
2015-05-11 19:00         ` [PATCH v4] " Justin Cormack
2015-05-13  3:01           ` David Miller
2015-05-13 10:06             ` Justin Cormack
2015-05-13 16:06               ` David Miller
2015-05-13 11:35             ` [PATCH v5] macvtap add missing ioctls Justin Cormack
2015-05-13 16:09               ` David Miller
2015-05-13 18:19                 ` [PATCH net-next] fix missing copy_from_user in macvtap Justin Cormack
2015-05-13 18:21                   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).