From: Johannes Berg <johannes@sipsolutions.net>
To: linux-wireless@vger.kernel.org
Cc: Johannes Berg <johannes.berg@intel.com>
Subject: [RFC 3/6] mac80211: simplify zero address checks
Date: Wed, 25 Aug 2010 22:56:22 +0200 [thread overview]
Message-ID: <20100825205726.741362601@sipsolutions.net> (raw)
In-Reply-To: 20100825205619.152295081@sipsolutions.net
From: Johannes Berg <johannes.berg@intel.com>
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>
---
net/mac80211/iface.c | 38 +++++++++++++-------------------------
1 file changed, 13 insertions(+), 25 deletions(-)
--- wireless-testing.orig/net/mac80211/iface.c 2010-08-25 21:59:11.000000000 +0200
+++ wireless-testing/net/mac80211/iface.c 2010-08-25 22:01:50.000000000 +0200
@@ -103,10 +103,9 @@ static int ieee80211_open(struct net_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_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 */
next prev parent reply other threads:[~2010-08-25 20:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-25 20:56 [RFC 0/6] "runtime" iftype switching Johannes Berg
2010-08-25 20:56 ` [RFC 1/6] mac80211: clean up ifdown/cleanup paths Johannes Berg
2010-08-25 20:56 ` [RFC 2/6] mac80211: switch to ieee80211_sdata_running Johannes Berg
2010-08-25 20:56 ` Johannes Berg [this message]
2010-08-25 20:56 ` [RFC 4/6] mac80211: split out concurrent vif checks Johannes Berg
2010-08-25 20:56 ` [RFC 5/6] mac80211: support runtime interface type changes Johannes Berg
2010-08-26 14:22 ` [RFC 5/6 v2] " Johannes Berg
2010-08-25 20:56 ` [RFC 6/6] mac80211_hwsim: support runtime iftype changes Johannes Berg
2010-08-25 21:10 ` [RFC 0/6] "runtime" iftype switching John W. Linville
2010-08-26 7:23 ` Johannes Berg
2010-08-26 11:58 ` John W. Linville
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100825205726.741362601@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=johannes.berg@intel.com \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).