netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Justin Cormack <justin@myriabit.com>
To: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Subject: [PATCH v2] macvtap add missing ioctls
Date: Sun, 10 May 2015 10:15:59 +0100	[thread overview]
Message-ID: <1431249359.669.5.camel@myriabit.com> (raw)
In-Reply-To: <20150509.174017.6956415471104971.davem@davemloft.net>

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

  reply	other threads:[~2015-05-10  9:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-06 15:56 [PATCH] macvtap add missing ioctls Justin Cormack
2015-05-09 21:40 ` David Miller
2015-05-10  9:15   ` Justin Cormack [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1431249359.669.5.camel@myriabit.com \
    --to=justin@myriabit.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).