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

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 12:50 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     ` Justin Cormack [this message]
2015-05-11 17:49       ` [PATCH v3] macvtap add missing ioctls - fix wrapping 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=1431262215.3278.2.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.