All of lore.kernel.org
 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

* Re: [PATCH] macvtap add missing ioctls
  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
  0 siblings, 1 reply; 13+ messages in thread
From: David Miller @ 2015-05-09 21:40 UTC (permalink / raw)
  To: justin; +Cc: netdev

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.

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

* [PATCH v2] macvtap add missing ioctls
  2015-05-09 21:40 ` David Miller
@ 2015-05-10  9:15   ` Justin Cormack
  2015-05-10 12:50     ` [PATCH v3] macvtap add missing ioctls - fix wrapping Justin Cormack
  0 siblings, 1 reply; 13+ messages in thread
From: Justin Cormack @ 2015-05-10  9:15 UTC (permalink / raw)
  To: David Miller, 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

* Re: [PATCH v3] macvtap add missing ioctls - fix wrapping
  2015-05-10  9:15   ` [PATCH v2] " Justin Cormack
@ 2015-05-10 12:50     ` Justin Cormack
  2015-05-11 17:49       ` David Miller
  0 siblings, 1 reply; 13+ messages in thread
From: Justin Cormack @ 2015-05-10 12:50 UTC (permalink / raw)
  To: David Miller, 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

* Re: [PATCH v3] macvtap add missing ioctls - fix wrapping
  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
  0 siblings, 1 reply; 13+ messages in thread
From: David Miller @ 2015-05-11 17:49 UTC (permalink / raw)
  To: justin; +Cc: netdev

From: Justin Cormack <justin@myriabit.com>
Date: Sun, 10 May 2015 13:50: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>
> 
> 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))

This is not indented correctly.

When an if() statement spans multiple lines, the second and subsequent lines
should start exactly at the first column following the openning parenthesis
of the first line.  You should use the appropriate number of TAB then
SPACE characters necessary to achieve this.

Thanks.

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

* [PATCH v4] macvtap add missing ioctls - fix wrapping
  2015-05-11 17:49       ` David Miller
@ 2015-05-11 19:00         ` Justin Cormack
  2015-05-13  3:01           ` David Miller
  0 siblings, 1 reply; 13+ messages in thread
From: Justin Cormack @ 2015-05-11 19:00 UTC (permalink / raw)
  To: David Miller, 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..5f98b34 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

* Re: [PATCH v4] macvtap add missing ioctls - fix wrapping
  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 11:35             ` [PATCH v5] macvtap add missing ioctls Justin Cormack
  0 siblings, 2 replies; 13+ messages in thread
From: David Miller @ 2015-05-13  3:01 UTC (permalink / raw)
  To: justin; +Cc: netdev

From: Justin Cormack <justin@myriabit.com>
Date: Mon, 11 May 2015 20:00:10 +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>

Applied to net-next, thanks.

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

* Re: [PATCH v4] macvtap add missing ioctls - fix wrapping
  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
  1 sibling, 1 reply; 13+ messages in thread
From: Justin Cormack @ 2015-05-13 10:06 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

On Tue, 2015-05-12 at 23:01 -0400, David Miller wrote:
> From: Justin Cormack <justin@myriabit.com>
> Date: Mon, 11 May 2015 20:00:10 +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>
> 
> Applied to net-next, thanks.
> 

The kbuild test picked up a stupid error, should I send a new patch
version, or a patch against net-next?

Justin

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

* [PATCH v5] macvtap add missing ioctls
  2015-05-13  3:01           ` David Miller
  2015-05-13 10:06             ` Justin Cormack
@ 2015-05-13 11:35             ` Justin Cormack
  2015-05-13 16:09               ` David Miller
  1 sibling, 1 reply; 13+ messages in thread
From: Justin Cormack @ 2015-05-13 11:35 UTC (permalink / raw)
  To: David Miller; +Cc: 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..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;
 	}

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

* Re: [PATCH v4] macvtap add missing ioctls - fix wrapping
  2015-05-13 10:06             ` Justin Cormack
@ 2015-05-13 16:06               ` David Miller
  0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2015-05-13 16:06 UTC (permalink / raw)
  To: justin; +Cc: netdev

From: Justin Cormack <justin@myriabit.com>
Date: Wed, 13 May 2015 11:06:01 +0100

> On Tue, 2015-05-12 at 23:01 -0400, David Miller wrote:
>> From: Justin Cormack <justin@myriabit.com>
>> Date: Mon, 11 May 2015 20:00:10 +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>
>> 
>> Applied to net-next, thanks.
>> 
> 
> The kbuild test picked up a stupid error, should I send a new patch
> version, or a patch against net-next?

Patches are never removable from my tree, so you must always send relative
fixes.

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

* Re: [PATCH v5] macvtap add missing ioctls
  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
  0 siblings, 1 reply; 13+ messages in thread
From: David Miller @ 2015-05-13 16:09 UTC (permalink / raw)
  To: justin; +Cc: netdev

From: Justin Cormack <justin@myriabit.com>
Date: Wed, 13 May 2015 12:35:16 +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>

As I stated, you cannot just send a new version of a patch I already
applied to my tree.

It is in the permanent GIT commit record, and cannot be removed.

Therefore, you must send a relative fix.

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

* [PATCH net-next] fix missing copy_from_user in macvtap
  2015-05-13 16:09               ` David Miller
@ 2015-05-13 18:19                 ` Justin Cormack
  2015-05-13 18:21                   ` David Miller
  0 siblings, 1 reply; 13+ messages in thread
From: Justin Cormack @ 2015-05-13 18:19 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

Fix missing copy_from_user in macvtap SIOCSIFHWADDR ioctl.

Signed-off-by: Justin Cormack <justin@netbsd.org>

diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index c8a2389..483afb1 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;
 
@@ -1119,13 +1120,15 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
 		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, &ifr->ifr_hwaddr);
+		ret = dev_set_mac_address(vlan->dev, &sa);
 		macvtap_put_vlan(vlan);
 		rtnl_unlock();
 		return ret;

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

* Re: [PATCH net-next] fix missing copy_from_user in macvtap
  2015-05-13 18:19                 ` [PATCH net-next] fix missing copy_from_user in macvtap Justin Cormack
@ 2015-05-13 18:21                   ` David Miller
  0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2015-05-13 18:21 UTC (permalink / raw)
  To: justin; +Cc: netdev

From: Justin Cormack <justin@myriabit.com>
Date: Wed, 13 May 2015 19:19:02 +0100

> Fix missing copy_from_user in macvtap SIOCSIFHWADDR ioctl.
> 
> Signed-off-by: Justin Cormack <justin@netbsd.org>

Applied.

^ permalink raw reply	[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 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.