diff mbox

[RFC] mac80211: Assign locally managed MAC address for each vif

Message ID 1303296542-18260-1-git-send-email-rmanoharan@atheros.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Rajkumar Manoharan April 20, 2011, 10:49 a.m. UTC
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(-)

Comments

Johannes Berg April 20, 2011, 10:59 a.m. UTC | #1
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

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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