All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] mac80211: Assign locally managed MAC address for each vif
@ 2011-04-20 10:49 Rajkumar Manoharan
  2011-04-20 10:59 ` Johannes Berg
  0 siblings, 1 reply; 2+ messages in thread
From: Rajkumar Manoharan @ 2011-04-20 10:49 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Rajkumar Manoharan

If the chip does not have set of hw mac addresses for each vif,
let's generate a locally managed mac address for the secondary
vifs. By doing this, we can avoid setting hw ether address
before bringing up the interface. The actual hw mac address
is set to the first vif.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
---
 net/mac80211/iface.c |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 4054399..ba75e25 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -1011,19 +1011,33 @@ static void ieee80211_assign_perm_addr(struct ieee80211_local *local,
 				       struct net_device *dev,
 				       enum nl80211_iftype type)
 {
-	struct ieee80211_sub_if_data *sdata;
+	struct ieee80211_sub_if_data *sdata, *ifdata = NULL;
 	u64 mask, start, addr, val, inc;
 	u8 *m;
 	u8 tmp_addr[ETH_ALEN];
-	int i;
+	int i = 0;
 
 	/* default ... something at least */
 	memcpy(dev->perm_addr, local->hw.wiphy->perm_addr, ETH_ALEN);
 
 	if (is_zero_ether_addr(local->hw.wiphy->addr_mask) &&
-	    local->hw.wiphy->n_addresses <= 1)
-		return;
+	    local->hw.wiphy->n_addresses <= 1) {
 
+		list_for_each_entry(ifdata, &local->interfaces, list)
+			i++;
+		/*
+		 * XOR virtual interface index into the least significant bits
+		 * to generate a different MAC address for secondary vifs
+		 */
+		if (i) {
+			dev->perm_addr[0] |= 0x02; /* Locally managed address */
+			dev->perm_addr[5] ^= i & 0xff;
+			dev->perm_addr[4] ^= (i & 0xff00) >> 8;
+			dev->perm_addr[3] ^= (i & 0xff0000) >> 16;
+		}
+
+		return;
+	}
 
 	mutex_lock(&local->iflist_mtx);
 
-- 
1.7.4.4


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

* Re: [RFC] mac80211: Assign locally managed MAC address for each vif
  2011-04-20 10:49 [RFC] mac80211: Assign locally managed MAC address for each vif Rajkumar Manoharan
@ 2011-04-20 10:59 ` Johannes Berg
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2011-04-20 10:59 UTC (permalink / raw)
  To: Rajkumar Manoharan; +Cc: linux-wireless

On Wed, 2011-04-20 at 16:19 +0530, Rajkumar Manoharan wrote:
> If the chip does not have set of hw mac addresses for each vif,
> let's generate a locally managed mac address for the secondary
> vifs. By doing this, we can avoid setting hw ether address
> before bringing up the interface. The actual hw mac address
> is set to the first vif.

Won't that wreak havoc with udev device naming?

Also, in what cases do you need to assign manually? wpa_s should be able
to assign them now, at least for p2p.

And another point to consider: there are a number of cases where you
need the same address, like VLAN for example.

Not sure, I guess I'm not convinced this is really needed.

johannes


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

end of thread, other threads:[~2011-04-20 10:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-20 10:49 [RFC] mac80211: Assign locally managed MAC address for each vif Rajkumar Manoharan
2011-04-20 10:59 ` Johannes Berg

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.