macvtap add missing ioctls
Subsystems (2)
PATCH 1/1 macvtap add missing ioctls
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 <[email protected]>
drivers/net/macvtap.c +29 -0
@@ -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 ; }
David Miller
maintainerFrom: Justin Cormack <[email protected]>
Date: Wed, 06 May 2015 16:56:15 +0100
Quoted 5 lines
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 <[email protected]>
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.
PATCH v2 1/1 macvtap add missing ioctls
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.
drivers/net/macvtap.c +0 -0
@@ -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;
}
Re: [PATCH v3] macvtap add missing ioctls - fix wrapping
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.
drivers/net/macvtap.c +29 -0
@@ -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 ; }
David Miller
maintainerRe: [PATCH v3] macvtap add missing ioctls - fix wrapping
From: Justin Cormack <[email protected]>
Date: Sun, 10 May 2015 13:50:15 +0100
Quoted 17 lines
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 <[email protected]>drivers/net/macvtap.c +2
-0@@ -1101,6 +1101,35 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,rtnl_unlock ();return ret; +case SIOCGIFHWADDR : +rtnl_lock ();
drivers/net/macvtap.c static long macvtap_ioctl(struct file *file, unsigned int cmd, · line 1115
Quoted 10 lines
drivers/net/macvtap.c +10
-0+ 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.
PATCH v4 1/1 macvtap add missing ioctls - fix wrapping
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.
drivers/net/macvtap.c +29 -0
@@ -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 ; }
Re: [PATCH v4] macvtap add missing ioctls - fix wrapping
From: Justin Cormack <[email protected]>
Date: Mon, 11 May 2015 20:00:10 +0100
Quoted 6 lines
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 <[email protected]>
Applied to net-next, thanks.
Re: [PATCH v4] macvtap add missing ioctls - fix wrapping
Quoted 12 lines · David Miller
From: Justin Cormack <[email protected]>
Date: Mon, 11 May 2015 20:00:10 +0100Quoted 6 lines
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 <[email protected]>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
David Miller
maintainerRe: [PATCH v4] macvtap add missing ioctls - fix wrapping
From: Justin Cormack <[email protected]>
Date: Wed, 13 May 2015 11:06:01 +0100
Quoted 9 lines · David Miller
Quoted 8 lines
From: Justin Cormack <[email protected]>
Date: Mon, 11 May 2015 20:00:10 +0100Quoted 5 lines
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.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Justin Cormack <[email protected]>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.
PATCH v5 1/1 macvtap add missing ioctls
In reply to David MillerThe 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.
drivers/net/macvtap.c +32 -0
@@ -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 ; }
David Miller
maintainerFrom: Justin Cormack <[email protected]>
Date: Wed, 13 May 2015 12:35:16 +0100
Quoted 6 lines
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 <[email protected]>
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.
PATCH 1/1 fix missing copy_from_user in macvtap
Fix missing copy_from_user in macvtap SIOCSIFHWADDR ioctl.
drivers/net/macvtap.c +4 -1
@@ -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;
Re: [PATCH net-next] fix missing copy_from_user in macvtap
From: Justin Cormack <[email protected]>
Date: Wed, 13 May 2015 19:19:02 +0100
Quoted 3 lines
Fix missing
copy_from_userin macvtap SIOCSIFHWADDR ioctl.Signed-off-by Justin Cormack <[email protected]>
Applied.