From: Justin Cormack <justin@myriabit.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: [PATCH v5] macvtap add missing ioctls
Date: Wed, 13 May 2015 12:35:16 +0100 [thread overview]
Message-ID: <1431516916.3278.8.camel@myriabit.com> (raw)
In-Reply-To: <20150512.230121.330638562727327262.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..d2a7783 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -1006,6 +1006,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
unsigned int __user *up = argp;
unsigned short u;
int __user *sp = argp;
+ struct sockaddr sa;
int s;
int ret;
@@ -1101,6 +1102,37 @@ 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:
+ if (copy_from_user(&sa, &ifr->ifr_hwaddr, sizeof(sa)))
+ return -EFAULT;
+ rtnl_lock();
+ vlan = macvtap_get_vlan(q);
+ if (!vlan) {
+ rtnl_unlock();
+ return -ENOLINK;
+ }
+ ret = dev_set_mac_address(vlan->dev, &sa);
+ macvtap_put_vlan(vlan);
+ rtnl_unlock();
+ return ret;
+
default:
return -EINVAL;
}
next prev parent reply other threads:[~2015-05-13 11:35 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 ` [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 ` Justin Cormack [this message]
2015-05-13 16:09 ` [PATCH v5] macvtap add missing ioctls 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=1431516916.3278.8.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).