diff options
author | Johannes Berg <johannes.berg@intel.com> | 2010-08-27 06:35:56 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-08-27 13:53:30 -0400 |
commit | bf533e0bfd77d9671adabdf134b1ac7f24bb0670 (patch) | |
tree | 80246d2a03e3aa1b6ebea0760cb4beab67e58f3d /net/mac80211 | |
parent | 26a58456be40d8181b884eb5b4e61e3f73ba94e0 (diff) |
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')
-rw-r--r-- | net/mac80211/iface.c | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index cc1c68d7dda6..ea50732ec526 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c | |||
@@ -103,10 +103,9 @@ static int ieee80211_open(struct net_device *dev) | |||
103 | u32 changed = 0; | 103 | u32 changed = 0; |
104 | int res; | 104 | int res; |
105 | u32 hw_reconf_flags = 0; | 105 | u32 hw_reconf_flags = 0; |
106 | u8 null_addr[ETH_ALEN] = {0}; | ||
107 | 106 | ||
108 | /* fail early if user set an invalid address */ | 107 | /* fail early if user set an invalid address */ |
109 | if (compare_ether_addr(dev->dev_addr, null_addr) && | 108 | if (!is_zero_ether_addr(dev->dev_addr) && |
110 | !is_valid_ether_addr(dev->dev_addr)) | 109 | !is_valid_ether_addr(dev->dev_addr)) |
111 | return -EADDRNOTAVAIL; | 110 | return -EADDRNOTAVAIL; |
112 | 111 | ||
@@ -195,33 +194,22 @@ static int ieee80211_open(struct net_device *dev) | |||
195 | } | 194 | } |
196 | 195 | ||
197 | /* | 196 | /* |
198 | * Check all interfaces and copy the hopefully now-present | 197 | * Copy the hopefully now-present MAC address to |
199 | * MAC address to those that have the special null one. | 198 | * this interface, if it has the special null one. |
200 | */ | 199 | */ |
201 | list_for_each_entry(nsdata, &local->interfaces, list) { | 200 | if (is_zero_ether_addr(dev->dev_addr)) { |
202 | struct net_device *ndev = nsdata->dev; | 201 | memcpy(dev->dev_addr, |
203 | 202 | local->hw.wiphy->perm_addr, | |
204 | /* | 203 | ETH_ALEN); |
205 | * No need to check running since we do not allow | 204 | memcpy(dev->perm_addr, dev->dev_addr, ETH_ALEN); |
206 | * it to start up with this invalid address. | 205 | |
207 | */ | 206 | if (!is_valid_ether_addr(dev->dev_addr)) { |
208 | if (compare_ether_addr(null_addr, ndev->dev_addr) == 0) { | 207 | if (!local->open_count) |
209 | memcpy(ndev->dev_addr, | 208 | drv_stop(local); |
210 | local->hw.wiphy->perm_addr, | 209 | return -EADDRNOTAVAIL; |
211 | ETH_ALEN); | ||
212 | memcpy(ndev->perm_addr, ndev->dev_addr, ETH_ALEN); | ||
213 | } | 210 | } |
214 | } | 211 | } |
215 | 212 | ||
216 | /* | ||
217 | * Validate the MAC address for this device. | ||
218 | */ | ||
219 | if (!is_valid_ether_addr(dev->dev_addr)) { | ||
220 | if (!local->open_count) | ||
221 | drv_stop(local); | ||
222 | return -EADDRNOTAVAIL; | ||
223 | } | ||
224 | |||
225 | switch (sdata->vif.type) { | 213 | switch (sdata->vif.type) { |
226 | case NL80211_IFTYPE_AP_VLAN: | 214 | case NL80211_IFTYPE_AP_VLAN: |
227 | /* no need to tell driver */ | 215 | /* no need to tell driver */ |