* [PATCH] net/wireless: add COUNTRY to to regulatory device uevent
@ 2011-03-08 18:45 Scott James Remnant
2011-11-08 22:15 ` Johannes Berg
0 siblings, 1 reply; 3+ messages in thread
From: Scott James Remnant @ 2011-03-08 18:45 UTC (permalink / raw)
To: Johannes Berg, John W. Linville
Cc: linux-wireless, Kay Sievers, Greg Kroah-Hartman, Sam Leffler,
keybuk, Luis R. Rodriguez
From: Scott James Remnant <keybuk@google.com>
Regulatory devices issue change uevents to inform userspace of a need
to call the crda tool; however these can often be sent before udevd is
running, and were not previously included in the results of
udevadm trigger (which requests a new change event using the /uevent
attribute of the sysfs object).
Add a uevent function to the device type which includes the COUNTRY
information from the last request if it has yet to be processed, the
case of multiple requests is already handled in the code by checking
whether an unprocessed one is queued in the same manner and refusing
to queue a new one.
The existing udev rule continues to work as before.
Signed-off-by: Scott James Remnant <keybuk@google.com>
Acked-By: Kay Sievers <kay.sievers@vrfy.org>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
---
net/wireless/reg.c | 39 ++++++++++++++++++++++++++++-----------
net/wireless/reg.h | 1 +
2 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 37693b6..de71c22 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -63,6 +63,10 @@ static struct regulatory_request *last_request;
/* To trigger userspace events */
static struct platform_device *reg_pdev;
+static struct device_type reg_device_type = {
+ .uevent = reg_device_uevent,
+};
+
/*
* Central wireless core regulatory domains, we only need two,
* the current one and a world regulatory domain in case we have no
@@ -362,16 +366,11 @@ static inline void reg_regdb_query(const char *alpha2) {}
/*
* This lets us keep regulatory code which is updated on a regulatory
- * basis in userspace.
+ * basis in userspace. Country information is filled in by
+ * reg_device_uevent
*/
static int call_crda(const char *alpha2)
{
- char country_env[9 + 2] = "COUNTRY=";
- char *envp[] = {
- country_env,
- NULL
- };
-
if (!is_world_regdom((char *) alpha2))
pr_info("Calling CRDA for country: %c%c\n",
alpha2[0], alpha2[1]);
@@ -381,10 +380,7 @@ static int call_crda(const char *alpha2)
/* query internal regulatory database (if it exists) */
reg_regdb_query(alpha2);
- country_env[8] = alpha2[0];
- country_env[9] = alpha2[1];
-
- return kobject_uevent_env(®_pdev->dev.kobj, KOBJ_CHANGE, envp);
+ return kobject_uevent(®_pdev->dev.kobj, KOBJ_CHANGE);
}
/* Used by nl80211 before kmalloc'ing our regulatory domain */
@@ -2087,6 +2083,25 @@ int set_regdom(const struct ieee80211_regdomain *rd)
return r;
}
+#ifdef CONFIG_HOTPLUG
+int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+ if (last_request && !last_request->processed) {
+ if (add_uevent_var(env, "COUNTRY=%c%c",
+ last_request->alpha2[0],
+ last_request->alpha2[1]))
+ return -ENOMEM;
+ }
+
+ return 0;
+}
+#else
+int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+ return -ENODEV;
+}
+#endif /* CONFIG_HOTPLUG */
+
/* Caller must hold cfg80211_mutex */
void reg_device_remove(struct wiphy *wiphy)
{
@@ -2118,6 +2133,8 @@ int __init regulatory_init(void)
if (IS_ERR(reg_pdev))
return PTR_ERR(reg_pdev);
+ reg_pdev->dev.type = ®_device_type;
+
spin_lock_init(®_requests_lock);
spin_lock_init(®_pending_beacons_lock);
diff --git a/net/wireless/reg.h b/net/wireless/reg.h
index c4695d0..b67d1c3 100644
--- a/net/wireless/reg.h
+++ b/net/wireless/reg.h
@@ -8,6 +8,7 @@ bool reg_is_valid_request(const char *alpha2);
int regulatory_hint_user(const char *alpha2);
+int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env);
void reg_device_remove(struct wiphy *wiphy);
int __init regulatory_init(void);
--
1.7.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] net/wireless: add COUNTRY to to regulatory device uevent
2011-03-08 18:45 [PATCH] net/wireless: add COUNTRY to to regulatory device uevent Scott James Remnant
@ 2011-11-08 22:15 ` Johannes Berg
2011-11-08 22:31 ` Luis R. Rodriguez
0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2011-11-08 22:15 UTC (permalink / raw)
To: Scott James Remnant
Cc: John W. Linville, linux-wireless, Kay Sievers, Greg Kroah-Hartman,
Sam Leffler, keybuk, Luis R. Rodriguez
On Tue, 2011-03-08 at 10:45 -0800, Scott James Remnant wrote:
> From: Scott James Remnant <keybuk@google.com>
>
> Regulatory devices issue change uevents to inform userspace of a need
> to call the crda tool; however these can often be sent before udevd is
> running, and were not previously included in the results of
> udevadm trigger (which requests a new change event using the /uevent
> attribute of the sysfs object).
>
> Add a uevent function to the device type which includes the COUNTRY
> information from the last request if it has yet to be processed, the
> case of multiple requests is already handled in the code by checking
> whether an unprocessed one is queued in the same manner and refusing
> to queue a new one.
>
> The existing udev rule continues to work as before.
Luis points out that it looks like this caused the crash I reported
earlier today -- in the module exit path we have a use-after-free of
last_request now.
johannes
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net/wireless: add COUNTRY to to regulatory device uevent
2011-11-08 22:15 ` Johannes Berg
@ 2011-11-08 22:31 ` Luis R. Rodriguez
0 siblings, 0 replies; 3+ messages in thread
From: Luis R. Rodriguez @ 2011-11-08 22:31 UTC (permalink / raw)
To: Johannes Berg
Cc: Scott James Remnant, John W. Linville, linux-wireless,
Kay Sievers, Greg Kroah-Hartman, Sam Leffler, keybuk
On Tue, Nov 8, 2011 at 2:15 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
> On Tue, 2011-03-08 at 10:45 -0800, Scott James Remnant wrote:
>> From: Scott James Remnant <keybuk@google.com>
>>
>> Regulatory devices issue change uevents to inform userspace of a need
>> to call the crda tool; however these can often be sent before udevd is
>> running, and were not previously included in the results of
>> udevadm trigger (which requests a new change event using the /uevent
>> attribute of the sysfs object).
>>
>> Add a uevent function to the device type which includes the COUNTRY
>> information from the last request if it has yet to be processed, the
>> case of multiple requests is already handled in the code by checking
>> whether an unprocessed one is queued in the same manner and refusing
>> to queue a new one.
>>
>> The existing udev rule continues to work as before.
>
> Luis points out that it looks like this caused the crash I reported
> earlier today -- in the module exit path we have a use-after-free of
> last_request now.
Sent patch.
Luis
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-11-08 22:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-08 18:45 [PATCH] net/wireless: add COUNTRY to to regulatory device uevent Scott James Remnant
2011-11-08 22:15 ` Johannes Berg
2011-11-08 22:31 ` Luis R. Rodriguez
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox