* [PATCH v3 04/15] nl80211: disallow user requests prior to regulatory_init()
2009-02-18 4:21 [PATCH v3 00/15] cfg80211: add a workqueue for regulatory processing Luis R. Rodriguez
@ 2009-02-18 4:21 ` Luis R. Rodriguez
2009-02-18 4:21 ` [PATCH v3 05/15] cfg80211: add regulatory_hint_core() to separate the core reg hint Luis R. Rodriguez
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Luis R. Rodriguez @ 2009-02-18 4:21 UTC (permalink / raw)
To: johannes, johannes, linville; +Cc: Luis R. Rodriguez, linux-wireless
If cfg80211 is built into the kernel there is perhaps a small
time window betwen nl80211_init() and regulatory_init() where
cfg80211_regdomain hasn't yet been initialized to let the
wireless core do its work. During that rare case and time
frame (if its even possible) we don't allow user regulatory
changes as cfg80211 is working on enabling its first regulatory
domain.
To check for cfg80211_regdomain we now contend the entire operation
using the cfg80211_mutex.
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
---
net/wireless/nl80211.c | 34 ++++++++++++++++++++++++++--------
1 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index f353e39..5d3e968 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1882,24 +1882,42 @@ static int nl80211_req_set_reg(struct sk_buff *skb, struct genl_info *info)
int r;
char *data = NULL;
- if (!info->attrs[NL80211_ATTR_REG_ALPHA2])
- return -EINVAL;
+ /*
+ * You should only get this when cfg80211 hasn't yet initialized
+ * completely when built-in to the kernel right between the time
+ * window between nl80211_init() and regulatory_init(), if that is
+ * even possible.
+ */
+ mutex_lock(&cfg80211_mutex);
+ if (unlikely(!cfg80211_regdomain)) {
+ r = -EINPROGRESS;
+ goto out;
+ }
+
+ if (!info->attrs[NL80211_ATTR_REG_ALPHA2]) {
+ r = -EINVAL;
+ goto out;
+ }
data = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]);
#ifdef CONFIG_WIRELESS_OLD_REGULATORY
/* We ignore world regdom requests with the old regdom setup */
- if (is_world_regdom(data))
- return -EINVAL;
+ if (is_world_regdom(data)) {
+ r = -EINVAL;
+ goto out;
+ }
#endif
- mutex_lock(&cfg80211_mutex);
r = __regulatory_hint(NULL, REGDOM_SET_BY_USER, data, 0, ENVIRON_ANY);
- mutex_unlock(&cfg80211_mutex);
- /* This means the regulatory domain was already set, however
+ /*
+ * This means the regulatory domain was already set, however
* we don't want to confuse userspace with a "successful error"
- * message so lets just treat it as a success */
+ * message so lets just treat it as a success
+ */
if (r == -EALREADY)
r = 0;
+out:
+ mutex_unlock(&cfg80211_mutex);
return r;
}
--
1.6.1.2.253.ga34a
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v3 05/15] cfg80211: add regulatory_hint_core() to separate the core reg hint
2009-02-18 4:21 [PATCH v3 00/15] cfg80211: add a workqueue for regulatory processing Luis R. Rodriguez
2009-02-18 4:21 ` [PATCH v3 04/15] nl80211: disallow user requests prior to regulatory_init() Luis R. Rodriguez
@ 2009-02-18 4:21 ` Luis R. Rodriguez
2009-02-18 4:21 ` [PATCH v3 06/15] cfg80211: propagate -ENOMEM during regulatory_init() Luis R. Rodriguez
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Luis R. Rodriguez @ 2009-02-18 4:21 UTC (permalink / raw)
To: johannes, johannes, linville; +Cc: Luis R. Rodriguez, linux-wireless
This makes the core hint path more readable and allows for us to
later make it obvious under what circumstances we need locking or not.
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
---
net/wireless/reg.c | 34 +++++++++++++++++++++++++---------
1 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index ba82312..6373a78 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1050,11 +1050,7 @@ static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by,
case REGDOM_SET_BY_INIT:
return -EINVAL;
case REGDOM_SET_BY_CORE:
- /*
- * Always respect new wireless core hints, should only happen
- * when updating the world regulatory domain at init.
- */
- return 0;
+ return -EINVAL;
case REGDOM_SET_BY_COUNTRY_IE:
if (unlikely(!is_an_alpha2(alpha2)))
return -EINVAL;
@@ -1183,6 +1179,26 @@ new_request:
return call_crda(alpha2);
}
+static int regulatory_hint_core(const char *alpha2)
+{
+ struct regulatory_request *request;
+
+ BUG_ON(last_request);
+
+ request = kzalloc(sizeof(struct regulatory_request),
+ GFP_KERNEL);
+ if (!request)
+ return -ENOMEM;
+
+ request->alpha2[0] = alpha2[0];
+ request->alpha2[1] = alpha2[1];
+ request->initiator = REGDOM_SET_BY_CORE;
+
+ last_request = request;
+
+ return call_crda(alpha2);
+}
+
void regulatory_hint(struct wiphy *wiphy, const char *alpha2)
{
int r;
@@ -1616,16 +1632,16 @@ int regulatory_init(void)
* stuck with the static values. We ignore "EU" code as
* that is not a valid ISO / IEC 3166 alpha2 */
if (ieee80211_regdom[0] != 'E' || ieee80211_regdom[1] != 'U')
- err = __regulatory_hint(NULL, REGDOM_SET_BY_CORE,
- ieee80211_regdom, 0, ENVIRON_ANY);
+ err = regulatory_hint_core(ieee80211_regdom);
#else
cfg80211_regdomain = cfg80211_world_regdom;
- err = __regulatory_hint(NULL, REGDOM_SET_BY_CORE, "00", 0, ENVIRON_ANY);
- if (err)
+ err = regulatory_hint_core("00");
+ if (err) {
printk(KERN_ERR "cfg80211: calling CRDA failed - "
"unable to update world regulatory domain, "
"using static definition\n");
+ }
#endif
return 0;
--
1.6.1.2.253.ga34a
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v3 06/15] cfg80211: propagate -ENOMEM during regulatory_init()
2009-02-18 4:21 [PATCH v3 00/15] cfg80211: add a workqueue for regulatory processing Luis R. Rodriguez
2009-02-18 4:21 ` [PATCH v3 04/15] nl80211: disallow user requests prior to regulatory_init() Luis R. Rodriguez
2009-02-18 4:21 ` [PATCH v3 05/15] cfg80211: add regulatory_hint_core() to separate the core reg hint Luis R. Rodriguez
@ 2009-02-18 4:21 ` Luis R. Rodriguez
2009-02-18 4:21 ` [PATCH v3 10/15] cfg80211: remove likely from an 11d hint case Luis R. Rodriguez
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Luis R. Rodriguez @ 2009-02-18 4:21 UTC (permalink / raw)
To: johannes, johannes, linville; +Cc: Luis R. Rodriguez, linux-wireless, Greg KH
Calling kobject_uevent_env() can fail mainly due to out of
memory conditions. We do not want to continue during such
conditions so propagate that as well instead of letting
cfg80211 load as if everything is peachy.
Additionally lets clarify that when CRDA is not called during
cfg80211's initialization _and_ if the error is not an -ENOMEM
its because kobject_uevent_env() failed to call CRDA, not because
CRDA failed. For those who want to find out why we also let you
do so by enabling the kernel config CONFIG_CFG80211_REG_DEBUG --
you'll get an actual stack trace.
So for now we'll treat non -ENOMEM kobject_uevent_env() failures as
non fatal during cfg80211's initialization.
CC: Greg KH <greg@kroah.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
---
net/wireless/reg.c | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 6373a78..47d5056 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1616,7 +1616,7 @@ void reg_device_remove(struct wiphy *wiphy)
int regulatory_init(void)
{
- int err;
+ int err = 0;
reg_pdev = platform_device_register_simple("regulatory", 0, NULL, 0);
if (IS_ERR(reg_pdev))
@@ -1637,12 +1637,24 @@ int regulatory_init(void)
cfg80211_regdomain = cfg80211_world_regdom;
err = regulatory_hint_core("00");
+#endif
if (err) {
- printk(KERN_ERR "cfg80211: calling CRDA failed - "
- "unable to update world regulatory domain, "
- "using static definition\n");
- }
+ if (err == -ENOMEM)
+ return err;
+ /*
+ * N.B. kobject_uevent_env() can fail mainly for when we're out
+ * memory which is handled and propagated appropriately above
+ * but it can also fail during a netlink_broadcast() or during
+ * early boot for call_usermodehelper(). For now treat these
+ * errors as non-fatal.
+ */
+ printk(KERN_ERR "cfg80211: kobject_uevent_env() was unable "
+ "to call CRDA during init");
+#ifdef CONFIG_CFG80211_REG_DEBUG
+ /* We want to find out exactly why when debugging */
+ WARN_ON(err);
#endif
+ }
return 0;
}
--
1.6.1.2.253.ga34a
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v3 10/15] cfg80211: remove likely from an 11d hint case
2009-02-18 4:21 [PATCH v3 00/15] cfg80211: add a workqueue for regulatory processing Luis R. Rodriguez
` (2 preceding siblings ...)
2009-02-18 4:21 ` [PATCH v3 06/15] cfg80211: propagate -ENOMEM during regulatory_init() Luis R. Rodriguez
@ 2009-02-18 4:21 ` Luis R. Rodriguez
2009-02-18 4:22 ` [PATCH v3 14/15] cfg80211: allow drivers that agree on regulatory to agree Luis R. Rodriguez
[not found] ` <20090218221824.GB3953@tuxdriver.com>
5 siblings, 0 replies; 7+ messages in thread
From: Luis R. Rodriguez @ 2009-02-18 4:21 UTC (permalink / raw)
To: johannes, johannes, linville; +Cc: Luis R. Rodriguez, linux-wireless
Truth of the matter this was confusing people so mark it as
unlikely as that is the case now.
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
---
net/wireless/reg.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index b474452..69cd4f0 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1331,14 +1331,16 @@ void regulatory_hint_11d(struct wiphy *wiphy,
if (!rd)
goto out;
- /* This will not happen right now but we leave it here for the
+ /*
+ * This will not happen right now but we leave it here for the
* the future when we want to add suspend/resume support and having
* the user move to another country after doing so, or having the user
- * move to another AP. Right now we just trust the first AP. This is why
- * this is marked as likley(). If we hit this before we add this support
- * we want to be informed of it as it would indicate a mistake in the
- * current design */
- if (likely(WARN_ON(reg_same_country_ie_hint(wiphy, checksum))))
+ * move to another AP. Right now we just trust the first AP.
+ *
+ * If we hit this before we add this support we want to be informed of
+ * it as it would indicate a mistake in the current design
+ */
+ if (unlikely(WARN_ON(reg_same_country_ie_hint(wiphy, checksum))))
goto out;
/* We keep this around for when CRDA comes back with a response so
--
1.6.1.2.253.ga34a
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v3 14/15] cfg80211: allow drivers that agree on regulatory to agree
2009-02-18 4:21 [PATCH v3 00/15] cfg80211: add a workqueue for regulatory processing Luis R. Rodriguez
` (3 preceding siblings ...)
2009-02-18 4:21 ` [PATCH v3 10/15] cfg80211: remove likely from an 11d hint case Luis R. Rodriguez
@ 2009-02-18 4:22 ` Luis R. Rodriguez
[not found] ` <20090218221824.GB3953@tuxdriver.com>
5 siblings, 0 replies; 7+ messages in thread
From: Luis R. Rodriguez @ 2009-02-18 4:22 UTC (permalink / raw)
To: johannes, johannes, linville; +Cc: Luis R. Rodriguez, linux-wireless
This allows drivers that agree on regulatory to share their
regulatory domain.
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
---
net/wireless/reg.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index ee27866..ae6921a 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1157,6 +1157,16 @@ static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by,
return 0;
return -EALREADY;
}
+
+ /*
+ * This would happen if you unplug and plug your card
+ * back in or if you add a new device for which the previously
+ * loaded card also agrees on the regulatory domain.
+ */
+ if (last_request->initiator == REGDOM_SET_BY_DRIVER &&
+ alpha2_equal(cfg80211_regdomain->alpha2, alpha2))
+ return -EALREADY;
+
return REG_INTERSECT;
case REGDOM_SET_BY_USER:
if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE)
--
1.6.1.2.253.ga34a
^ permalink raw reply related [flat|nested] 7+ messages in thread[parent not found: <20090218221824.GB3953@tuxdriver.com>]
* Re: [PATCH v3 00/15] cfg80211: add a workqueue for regulatory processing
[not found] ` <20090218221824.GB3953@tuxdriver.com>
@ 2009-02-18 22:20 ` Luis R. Rodriguez
0 siblings, 0 replies; 7+ messages in thread
From: Luis R. Rodriguez @ 2009-02-18 22:20 UTC (permalink / raw)
To: John W. Linville
Cc: Luis Rodriguez, johannes@sipsolutions.net,
linux-wireless@vger.kernel.org
On Wed, Feb 18, 2009 at 02:18:24PM -0800, John W. Linville wrote:
> On Tue, Feb 17, 2009 at 08:21:47PM -0800, Luis R. Rodriguez wrote:
> > This series has a few cleanups and minor fixes but mainly
> > adds a workqueue for cfg80211 to use to process all regulatory
> > hints. This v3 changes _all_ regulatory hints to use this
> > workqueue.
> >
> > I've combined this series with my later one that had only 3 patches=
=2E
> >
> > This series is also rebased on today's pull of wl.
> >
> > Luis R. Rodriguez (15):
> > cfg80211: rename cfg80211_registered_device's idx to wiphy_idx
> > cfg80211: add wiphy_idx_valid to check for wiphy_idx sanity
> > cfg80211: rename cfg80211_drv_mutex to cfg80211_mutex
> > nl80211: disallow user requests prior to regulatory_init()
> > cfg80211: add regulatory_hint_core() to separate the core reg hin=
t
> > cfg80211: propagate -ENOMEM during regulatory_init()
> > cfg80211: add assert_cfg80211_lock() to ensure proper protection
> > cfg80211: make regulatory_request use wiphy_idx instead of wiphy
> > cfg80211: protect first access of last_request on 11d hint under
> > mutex
> > cfg80211: remove likely from an 11d hint case
> > cfg80211: free rd on unlikely event on 11d hint
> > cfg80211: move all regulatory hints to workqueue
> > cfg80211: comments style cleanup
> > cfg80211: allow drivers that agree on regulatory to agree
> > cfg80211: rename regdom_changed to regdom_changes() and use it
>=20
> Not sure what happened, but all I got was this:
>=20
> 271 T Feb 17 Luis R. Rodrigu ( 44) [PATCH v3 00/15] cfg80211: add=
a workqueue for regulatory processing
> 272 O T Feb 17 Luis R. Rodrigu ( 0) =E2=94=9C=E2=94=80>[PATCH v3 0=
4/15] nl80211: disallow user requests prior to regulatory_init()
> 273 O T Feb 17 Luis R. Rodrigu ( 0) =E2=94=9C=E2=94=80>[PATCH v3 0=
5/15] cfg80211: add regulatory_hint_core() to separate the core reg hin=
t
> 274 O T Feb 17 Luis R. Rodrigu ( 0) =E2=94=9C=E2=94=80>[PATCH v3 0=
6/15] cfg80211: propagate -ENOMEM during regulatory_init()
> 275 O T Feb 17 Luis R. Rodrigu ( 0) =E2=94=9C=E2=94=80>[PATCH v3 1=
0/15] cfg80211: remove likely from an 11d hint case
> 276 O T Feb 17 Luis R. Rodrigu ( 0) =E2=94=94=E2=94=80>[PATCH v3 1=
4/15] cfg80211: allow drivers that agree on regulatory to agree
>=20
> Would you mind resending (at least to my address)?
Sorry about that... Microsoft Exchange 2007 happened. Will resend from =
a less buggy
SMTP somewhere.
Luis
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles=
s" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread