linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 net-next 0/9] set addr_assign_type when inheriting a dev_addr
@ 2013-08-30 16:08 Bjørn Mork
  2013-08-30 16:08 ` [PATCH v2 net-next 1/9] net: etherdevice: add address inherit helper Bjørn Mork
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Bjørn Mork @ 2013-08-30 16:08 UTC (permalink / raw)
  To: netdev
  Cc: Bjørn Mork, Patrick McHardy, Jiri Pirko, John W. Linville,
	linux-wireless, Jouni Malinen, libertas-dev, Greg Kroah-Hartman,
	devel, Forest Bond, Stephen Hemminger, Dan Carpenter

Copying the dev_addr from a parent device is an operation
common to a number of drivers. The addr_assign_type should
be updated accordingly, either by reusing the value from
the source device or explicitly indicating that the address
is stolen by setting addr_assign_type to NET_ADDR_STOLEN.

This patch set adds a helper copying both the dev_addr and
the addr_assign_type, and use this helper in drivers which
don't currently set the addr_assign_type. Using NET_ADDR_STOLEN
might be more appropriate in some of these cases.  Please
let me know, and I'll update the patch accordingly.

Changes in v2:
 - assuming addr_len == ETH_ALEN to allow optimized memcpy
 - dropped the vt6656 patch due to addr_len being unset in that driver


Bjørn Mork (9):
  net: etherdevice: add address inherit helper
  net: vlan: inherit addr_assign_type along with dev_addr
  net: dsa: inherit addr_assign_type along with dev_addr
  net: macvlan: inherit addr_assign_type along with dev_addr
  net: team: inherit addr_assign_type along with dev_addr
  net: airo: inherit addr_assign_type along with dev_addr
  net: hostap: inherit addr_assign_type along with dev_addr
  net: libertas: inherit addr_assign_type along with dev_addr
  staging: vt6655: inherit addr_assign_type along with dev_addr

 drivers/net/macvlan.c                     |    2 +-
 drivers/net/team/team.c                   |    2 +-
 drivers/net/wireless/airo.c               |    2 +-
 drivers/net/wireless/hostap/hostap_hw.c   |    2 +-
 drivers/net/wireless/hostap/hostap_main.c |    2 +-
 drivers/net/wireless/libertas/mesh.c      |    2 +-
 drivers/staging/vt6655/hostap.c           |    2 +-
 drivers/staging/vt6655/ioctl.c            |    2 +-
 drivers/staging/vt6655/wpactl.c           |    2 +-
 include/linux/etherdevice.h               |   15 +++++++++++++++
 net/8021q/vlan_dev.c                      |    2 +-
 net/dsa/slave.c                           |    2 +-
 12 files changed, 26 insertions(+), 11 deletions(-)

-- 
1.7.10.4


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

* [PATCH v2 net-next 1/9] net: etherdevice: add address inherit helper
  2013-08-30 16:08 [PATCH v2 net-next 0/9] set addr_assign_type when inheriting a dev_addr Bjørn Mork
@ 2013-08-30 16:08 ` Bjørn Mork
  2013-08-30 16:08 ` [PATCH v2 net-next 6/9] net: airo: inherit addr_assign_type along with dev_addr Bjørn Mork
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Bjørn Mork @ 2013-08-30 16:08 UTC (permalink / raw)
  To: netdev
  Cc: Bjørn Mork, Stephen Hemminger, Patrick McHardy, Jiri Pirko,
	John W. Linville, linux-wireless, Jouni Malinen, libertas-dev,
	Greg Kroah-Hartman, devel, Forest Bond

Some etherdevices inherit their address from a parent or
master device. The addr_assign_type should be updated along
with the address in these cases.  Adding a helper function
to simplify this.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
 include/linux/etherdevice.h |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index c623861..d8b5124 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -199,6 +199,21 @@ static inline void eth_hw_addr_random(struct net_device *dev)
 }
 
 /**
+ * eth_hw_addr_inherit - Copy dev_addr from another net_device
+ * @dst: pointer to net_device to copy dev_addr to
+ * @src: pointer to net_device to copy dev_addr from
+ *
+ * Copy the Ethernet address from one net_device to another along with
+ * the address attributes (addr_assign_type).
+ */
+static inline void eth_hw_addr_inherit(struct net_device *dst,
+				       struct net_device *src)
+{
+	dst->addr_assign_type = src->addr_assign_type;
+	memcpy(dst->dev_addr, src->dev_addr, ETH_ALEN);
+}
+
+/**
  * compare_ether_addr - Compare two Ethernet addresses
  * @addr1: Pointer to a six-byte array containing the Ethernet address
  * @addr2: Pointer other six-byte array containing the Ethernet address
-- 
1.7.10.4


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

* [PATCH v2 net-next 6/9] net: airo: inherit addr_assign_type along with dev_addr
  2013-08-30 16:08 [PATCH v2 net-next 0/9] set addr_assign_type when inheriting a dev_addr Bjørn Mork
  2013-08-30 16:08 ` [PATCH v2 net-next 1/9] net: etherdevice: add address inherit helper Bjørn Mork
@ 2013-08-30 16:08 ` Bjørn Mork
  2013-08-30 16:08 ` [PATCH v2 net-next 7/9] net: hostap: " Bjørn Mork
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Bjørn Mork @ 2013-08-30 16:08 UTC (permalink / raw)
  To: netdev; +Cc: Bjørn Mork, linux-wireless

A device inheriting a random or set address should reflect this in
its addr_assign_type.

Acked-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
 drivers/net/wireless/airo.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index d0adbaf..7fe1964 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -2693,7 +2693,7 @@ static struct net_device *init_wifidev(struct airo_info *ai,
 	dev->base_addr = ethdev->base_addr;
 	dev->wireless_data = ethdev->wireless_data;
 	SET_NETDEV_DEV(dev, ethdev->dev.parent);
-	memcpy(dev->dev_addr, ethdev->dev_addr, dev->addr_len);
+	eth_hw_addr_inherit(dev, ethdev);
 	err = register_netdev(dev);
 	if (err<0) {
 		free_netdev(dev);
-- 
1.7.10.4


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

* [PATCH v2 net-next 7/9] net: hostap: inherit addr_assign_type along with dev_addr
  2013-08-30 16:08 [PATCH v2 net-next 0/9] set addr_assign_type when inheriting a dev_addr Bjørn Mork
  2013-08-30 16:08 ` [PATCH v2 net-next 1/9] net: etherdevice: add address inherit helper Bjørn Mork
  2013-08-30 16:08 ` [PATCH v2 net-next 6/9] net: airo: inherit addr_assign_type along with dev_addr Bjørn Mork
@ 2013-08-30 16:08 ` Bjørn Mork
  2013-08-30 16:08 ` [PATCH v2 net-next 8/9] net: libertas: " Bjørn Mork
  2013-09-01  2:50 ` [PATCH v2 net-next 0/9] set addr_assign_type when inheriting a dev_addr David Miller
  4 siblings, 0 replies; 8+ messages in thread
From: Bjørn Mork @ 2013-08-30 16:08 UTC (permalink / raw)
  To: netdev; +Cc: Bjørn Mork, John W. Linville, linux-wireless, Jouni Malinen

A device inheriting a random or set address should reflect this in
its addr_assign_type.

Cc: Jouni Malinen <j@w1.fi>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
 drivers/net/wireless/hostap/hostap_hw.c   |    2 +-
 drivers/net/wireless/hostap/hostap_main.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c
index 6307a4e..c275dc1 100644
--- a/drivers/net/wireless/hostap/hostap_hw.c
+++ b/drivers/net/wireless/hostap/hostap_hw.c
@@ -1425,7 +1425,7 @@ static int prism2_hw_init2(struct net_device *dev, int initial)
 		}
 		list_for_each(ptr, &local->hostap_interfaces) {
 			iface = list_entry(ptr, struct hostap_interface, list);
-			memcpy(iface->dev->dev_addr, dev->dev_addr, ETH_ALEN);
+			eth_hw_addr_inherit(iface->dev, dev);
 		}
 	} else if (local->fw_ap)
 		prism2_check_sta_fw_version(local);
diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c
index e4f56ad..a1257c9 100644
--- a/drivers/net/wireless/hostap/hostap_main.c
+++ b/drivers/net/wireless/hostap/hostap_main.c
@@ -66,7 +66,7 @@ struct net_device * hostap_add_interface(struct local_info *local,
 	list_add(&iface->list, &local->hostap_interfaces);
 
 	mdev = local->dev;
-	memcpy(dev->dev_addr, mdev->dev_addr, ETH_ALEN);
+	eth_hw_addr_inherit(dev, mdev);
 	dev->base_addr = mdev->base_addr;
 	dev->irq = mdev->irq;
 	dev->mem_start = mdev->mem_start;
-- 
1.7.10.4


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

* [PATCH v2 net-next 8/9] net: libertas: inherit addr_assign_type along with dev_addr
  2013-08-30 16:08 [PATCH v2 net-next 0/9] set addr_assign_type when inheriting a dev_addr Bjørn Mork
                   ` (2 preceding siblings ...)
  2013-08-30 16:08 ` [PATCH v2 net-next 7/9] net: hostap: " Bjørn Mork
@ 2013-08-30 16:08 ` Bjørn Mork
  2013-09-01  2:50 ` [PATCH v2 net-next 0/9] set addr_assign_type when inheriting a dev_addr David Miller
  4 siblings, 0 replies; 8+ messages in thread
From: Bjørn Mork @ 2013-08-30 16:08 UTC (permalink / raw)
  To: netdev; +Cc: Bjørn Mork, libertas-dev, linux-wireless

A device inheriting a random or set address should reflect this in
its addr_assign_type.

Acked-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
 drivers/net/wireless/libertas/mesh.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/libertas/mesh.c b/drivers/net/wireless/libertas/mesh.c
index efae07e..6fef746 100644
--- a/drivers/net/wireless/libertas/mesh.c
+++ b/drivers/net/wireless/libertas/mesh.c
@@ -1017,7 +1017,7 @@ static int lbs_add_mesh(struct lbs_private *priv)
 
 	mesh_dev->netdev_ops = &mesh_netdev_ops;
 	mesh_dev->ethtool_ops = &lbs_ethtool_ops;
-	memcpy(mesh_dev->dev_addr, priv->dev->dev_addr, ETH_ALEN);
+	eth_hw_addr_inherit(mesh_dev, priv->dev);
 
 	SET_NETDEV_DEV(priv->mesh_dev, priv->dev->dev.parent);
 
-- 
1.7.10.4


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

* Re: [PATCH v2 net-next 0/9] set addr_assign_type when inheriting a dev_addr
  2013-08-30 16:08 [PATCH v2 net-next 0/9] set addr_assign_type when inheriting a dev_addr Bjørn Mork
                   ` (3 preceding siblings ...)
  2013-08-30 16:08 ` [PATCH v2 net-next 8/9] net: libertas: " Bjørn Mork
@ 2013-09-01  2:50 ` David Miller
  2013-09-03  7:38   ` Bjørn Mork
  4 siblings, 1 reply; 8+ messages in thread
From: David Miller @ 2013-09-01  2:50 UTC (permalink / raw)
  To: bjorn
  Cc: netdev, kaber, jiri, linville, linux-wireless, j, libertas-dev,
	gregkh, devel, forest, stephen, dan.carpenter

From: Bjørn Mork <bjorn@mork.no>
Date: Fri, 30 Aug 2013 18:08:43 +0200

> Copying the dev_addr from a parent device is an operation
> common to a number of drivers. The addr_assign_type should
> be updated accordingly, either by reusing the value from
> the source device or explicitly indicating that the address
> is stolen by setting addr_assign_type to NET_ADDR_STOLEN.
> 
> This patch set adds a helper copying both the dev_addr and
> the addr_assign_type, and use this helper in drivers which
> don't currently set the addr_assign_type. Using NET_ADDR_STOLEN
> might be more appropriate in some of these cases.  Please
> let me know, and I'll update the patch accordingly.
> 
> Changes in v2:
>  - assuming addr_len == ETH_ALEN to allow optimized memcpy
>  - dropped the vt6656 patch due to addr_len being unset in that driver

Looks good, series applied, thanks.

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

* Re: [PATCH v2 net-next 0/9] set addr_assign_type when inheriting a dev_addr
  2013-09-01  2:50 ` [PATCH v2 net-next 0/9] set addr_assign_type when inheriting a dev_addr David Miller
@ 2013-09-03  7:38   ` Bjørn Mork
  2013-09-04  1:41     ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Bjørn Mork @ 2013-09-03  7:38 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, kaber, jiri, linville, linux-wireless, j, libertas-dev,
	gregkh, devel, forest, stephen, dan.carpenter

David Miller <davem@davemloft.net> writes:

> From: Bjørn Mork <bjorn@mork.no>
> Date: Fri, 30 Aug 2013 18:08:43 +0200
>
>> Copying the dev_addr from a parent device is an operation
>> common to a number of drivers. The addr_assign_type should
>> be updated accordingly, either by reusing the value from
>> the source device or explicitly indicating that the address
>> is stolen by setting addr_assign_type to NET_ADDR_STOLEN.
>> 
>> This patch set adds a helper copying both the dev_addr and
>> the addr_assign_type, and use this helper in drivers which
>> don't currently set the addr_assign_type. Using NET_ADDR_STOLEN
>> might be more appropriate in some of these cases.  Please
>> let me know, and I'll update the patch accordingly.
>> 
>> Changes in v2:
>>  - assuming addr_len == ETH_ALEN to allow optimized memcpy
>>  - dropped the vt6656 patch due to addr_len being unset in that driver
>
> Looks good, series applied, thanks.

Thanks.  But it doesn't look like it ended up in net-next?  Or am I
missing something (again)?


Bjørn

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

* Re: [PATCH v2 net-next 0/9] set addr_assign_type when inheriting a dev_addr
  2013-09-03  7:38   ` Bjørn Mork
@ 2013-09-04  1:41     ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2013-09-04  1:41 UTC (permalink / raw)
  To: bjorn
  Cc: netdev, kaber, jiri, linville, linux-wireless, j, libertas-dev,
	gregkh, devel, forest, stephen, dan.carpenter

From: Bjørn Mork <bjorn@mork.no>
Date: Tue, 03 Sep 2013 09:38:10 +0200

> But it doesn't look like it ended up in net-next?  Or am I missing
> something (again)?

I forgot to push it out from my workstation before going away for the
holiday weekend, this has now been fixed :-)

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

end of thread, other threads:[~2013-09-04  1:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-30 16:08 [PATCH v2 net-next 0/9] set addr_assign_type when inheriting a dev_addr Bjørn Mork
2013-08-30 16:08 ` [PATCH v2 net-next 1/9] net: etherdevice: add address inherit helper Bjørn Mork
2013-08-30 16:08 ` [PATCH v2 net-next 6/9] net: airo: inherit addr_assign_type along with dev_addr Bjørn Mork
2013-08-30 16:08 ` [PATCH v2 net-next 7/9] net: hostap: " Bjørn Mork
2013-08-30 16:08 ` [PATCH v2 net-next 8/9] net: libertas: " Bjørn Mork
2013-09-01  2:50 ` [PATCH v2 net-next 0/9] set addr_assign_type when inheriting a dev_addr David Miller
2013-09-03  7:38   ` Bjørn Mork
2013-09-04  1:41     ` David Miller

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).