summaryrefslogtreecommitdiffstats
path: root/net/mac80211/iface.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2010-08-27 12:35:56 +0200
committerJohn W. Linville <linville@tuxdriver.com>2010-08-27 13:53:30 -0400
commitbf533e0bfd77d9671adabdf134b1ac7f24bb0670 (patch)
tree80246d2a03e3aa1b6ebea0760cb4beab67e58f3d /net/mac80211/iface.c
parent26a58456be40d8181b884eb5b4e61e3f73ba94e0 (diff)
downloadop-kernel-dev-bf533e0bfd77d9671adabdf134b1ac7f24bb0670.zip
op-kernel-dev-bf533e0bfd77d9671adabdf134b1ac7f24bb0670.tar.gz
mac80211: simplify zero address checks
The libertas_tf special code for zero addresses is a bit too complex, it compares against a stack value instead of using is_zero_ether_addr() and tries to update all interfaces even if just the one that's being brought up needs to be changed. Additionally, the repeated check for a valid MAC address need only be done if we actually changed it on the fly. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/iface.c')
-rw-r--r--net/mac80211/iface.c38
1 files changed, 13 insertions, 25 deletions
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index cc1c68d..ea50732 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -103,10 +103,9 @@ static int ieee80211_open(struct net_device *dev)
u32 changed = 0;
int res;
u32 hw_reconf_flags = 0;
- u8 null_addr[ETH_ALEN] = {0};
/* fail early if user set an invalid address */
- if (compare_ether_addr(dev->dev_addr, null_addr) &&
+ if (!is_zero_ether_addr(dev->dev_addr) &&
!is_valid_ether_addr(dev->dev_addr))
return -EADDRNOTAVAIL;
@@ -195,33 +194,22 @@ static int ieee80211_open(struct net_device *dev)
}
/*
- * Check all interfaces and copy the hopefully now-present
- * MAC address to those that have the special null one.
+ * Copy the hopefully now-present MAC address to
+ * this interface, if it has the special null one.
*/
- list_for_each_entry(nsdata, &local->interfaces, list) {
- struct net_device *ndev = nsdata->dev;
-
- /*
- * No need to check running since we do not allow
- * it to start up with this invalid address.
- */
- if (compare_ether_addr(null_addr, ndev->dev_addr) == 0) {
- memcpy(ndev->dev_addr,
- local->hw.wiphy->perm_addr,
- ETH_ALEN);
- memcpy(ndev->perm_addr, ndev->dev_addr, ETH_ALEN);
+ if (is_zero_ether_addr(dev->dev_addr)) {
+ memcpy(dev->dev_addr,
+ local->hw.wiphy->perm_addr,
+ ETH_ALEN);
+ memcpy(dev->perm_addr, dev->dev_addr, ETH_ALEN);
+
+ if (!is_valid_ether_addr(dev->dev_addr)) {
+ if (!local->open_count)
+ drv_stop(local);
+ return -EADDRNOTAVAIL;
}
}
- /*
- * Validate the MAC address for this device.
- */
- if (!is_valid_ether_addr(dev->dev_addr)) {
- if (!local->open_count)
- drv_stop(local);
- return -EADDRNOTAVAIL;
- }
-
switch (sdata->vif.type) {
case NL80211_IFTYPE_AP_VLAN:
/* no need to tell driver */
OpenPOWER on IntegriCloud