diff mbox

cfg80211: Do not call CRDA when using internal regulatory database

Message ID 1389909758-6807-1-git-send-email-chaitanya.mgit@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Krishna Chaitanya Jan. 16, 2014, 10:02 p.m. UTC
When using internal regulatory data base kconfig option
do not try to call crda, this complely defeats the 
purposes of enabling internal regulatory db.

Signed-off-by: Chaitanya T K <chaitanya.mgit@gmail.com>

---
 net/wireless/reg.c |   29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Krishna Chaitanya Jan. 17, 2014, 6:52 p.m. UTC | #1
On Fri, Jan 17, 2014 at 3:32 AM, Chaitanya T K <chaitanya.mgit@gmail.com> wrote:
>
> When using internal regulatory data base kconfig option
> do not try to call crda, this complely defeats the
> purposes of enabling internal regulatory db.
>
> Signed-off-by: Chaitanya T K <chaitanya.mgit@gmail.com>
>
> ---
>  net/wireless/reg.c |   29 +++++++++++++++--------------
>  1 file changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/net/wireless/reg.c b/net/wireless/reg.c
> index 7d20d84..1cb0f99 100644
> --- a/net/wireless/reg.c
> +++ b/net/wireless/reg.c
> @@ -454,16 +454,16 @@ static void reg_regdb_search(struct work_struct *work)
>
>  static DECLARE_WORK(reg_regdb_work, reg_regdb_search);
>
> -static void reg_regdb_query(const char *alpha2)
> +static int reg_regdb_query(const char *alpha2)
>  {
>         struct reg_regdb_search_request *request;
>
>         if (!alpha2)
> -               return;
> +               return -1;
>
>         request = kzalloc(sizeof(struct reg_regdb_search_request), GFP_KERNEL);
>         if (!request)
> -               return;
> +               return -1;
>
I guess the return values must be 1 so that in case of failure
we ignore the reg update. Will wait for sometime for other
comments and send V2.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Johannes Berg Jan. 17, 2014, 6:54 p.m. UTC | #2
On Sat, 2014-01-18 at 00:22 +0530, Krishna Chaitanya wrote:
> On Fri, Jan 17, 2014 at 3:32 AM, Chaitanya T K <chaitanya.mgit@gmail.com> wrote:
> >
> > When using internal regulatory data base kconfig option
> > do not try to call crda, this complely defeats the
> > purposes of enabling internal regulatory db.
> >
> > Signed-off-by: Chaitanya T K <chaitanya.mgit@gmail.com>
> >
> > ---
> >  net/wireless/reg.c |   29 +++++++++++++++--------------
> >  1 file changed, 15 insertions(+), 14 deletions(-)
> >
> > diff --git a/net/wireless/reg.c b/net/wireless/reg.c
> > index 7d20d84..1cb0f99 100644
> > --- a/net/wireless/reg.c
> > +++ b/net/wireless/reg.c
> > @@ -454,16 +454,16 @@ static void reg_regdb_search(struct work_struct *work)
> >
> >  static DECLARE_WORK(reg_regdb_work, reg_regdb_search);
> >
> > -static void reg_regdb_query(const char *alpha2)
> > +static int reg_regdb_query(const char *alpha2)
> >  {
> >         struct reg_regdb_search_request *request;
> >
> >         if (!alpha2)
> > -               return;
> > +               return -1;
> >
> >         request = kzalloc(sizeof(struct reg_regdb_search_request), GFP_KERNEL);
> >         if (!request)
> > -               return;
> > +               return -1;
> >
> I guess the return values must be 1 so that in case of failure
> we ignore the reg update. Will wait for sometime for other
> comments and send V2.

-1 is -EPERM anyway, which doesn't seem appropriate.

johannes


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Johannes Berg Jan. 17, 2014, 6:55 p.m. UTC | #3
On Fri, 2014-01-17 at 03:32 +0530, Chaitanya T K wrote:
> When using internal regulatory data base kconfig option
> do not try to call crda, this complely defeats the 
> purposes of enabling internal regulatory db.

In general I don't think you can just break user visible behaviour this
way.

johannes

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Krishna Chaitanya Jan. 17, 2014, 7:03 p.m. UTC | #4
On Sat, Jan 18, 2014 at 12:25 AM, Johannes Berg
<johannes@sipsolutions.net> wrote:
> On Fri, 2014-01-17 at 03:32 +0530, Chaitanya T K wrote:
>> When using internal regulatory data base kconfig option
>> do not try to call crda, this complely defeats the
>> purposes of enabling internal regulatory db.
>
> In general I don't think you can just break user visible behaviour this
> way.
Well, users are habituated the wrong way :-). Any new user seeing the
internal_regdb might just forget about CRDA and face problems, in case
the DB is different in both.

How should we go about it, then?
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Krishna Chaitanya Jan. 17, 2014, 10:10 p.m. UTC | #5
On Sat, Jan 18, 2014 at 12:33 AM, Krishna Chaitanya
<chaitanya.mgit@gmail.com> wrote:
> On Sat, Jan 18, 2014 at 12:25 AM, Johannes Berg
> <johannes@sipsolutions.net> wrote:
>> On Fri, 2014-01-17 at 03:32 +0530, Chaitanya T K wrote:
>>> When using internal regulatory data base kconfig option
>>> do not try to call crda, this complely defeats the
>>> purposes of enabling internal regulatory db.
>>
>> In general I don't think you can just break user visible behaviour this
>> way.
> Well, users are habituated the wrong way :-). Any new user seeing the
> internal_regdb might just forget about CRDA and face problems, in case
> the DB is different in both.
>
> How should we go about it, then?
When user enabled internal_regdb target, if he forgets to copy the db.txt
we throw a warn_on and continue with WORLD regdom. So user has to copy
the db.txt and we will read rules from there.This all happens independent of
CRDA running/not in userspace. So i dont see any visible user impact
if at all someone decides to enabled internal_regdb even after seeing
all the warnings in place (kconfig, doc ..) :-).

One more bug in the below check:

if (call_crda(lr->alpha2))
        return REG_REQ_IGNORE;

If call_crda fails (kobject_event return negative no) then also
we return REG_REQ_OK. It should be

if (call_crda(lr->alpha2) < 0)
        return REG_REQ_IGNORE;
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 7d20d84..1cb0f99 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -454,16 +454,16 @@  static void reg_regdb_search(struct work_struct *work)
 
 static DECLARE_WORK(reg_regdb_work, reg_regdb_search);
 
-static void reg_regdb_query(const char *alpha2)
+static int reg_regdb_query(const char *alpha2)
 {
 	struct reg_regdb_search_request *request;
 
 	if (!alpha2)
-		return;
+		return -1;
 
 	request = kzalloc(sizeof(struct reg_regdb_search_request), GFP_KERNEL);
 	if (!request)
-		return;
+		return -1;
 
 	memcpy(request->alpha2, alpha2, 2);
 
@@ -472,6 +472,7 @@  static void reg_regdb_query(const char *alpha2)
 	mutex_unlock(&reg_regdb_search_mutex);
 
 	schedule_work(&reg_regdb_work);
+	return 0;
 }
 
 /* Feel free to add any other sanity checks here */
@@ -482,7 +483,15 @@  static void reg_regdb_size_check(void)
 }
 #else
 static inline void reg_regdb_size_check(void) {}
-static inline void reg_regdb_query(const char *alpha2) {}
+static inline int reg_regdb_query(const char *alpha2)
+{
+	if (!is_world_regdom((char *) alpha2))
+		pr_info("Calling CRDA for country: %c%c\n",
+			alpha2[0], alpha2[1]);
+	else
+		pr_info("Calling CRDA to update world regulatory domain\n");
+	return kobject_uevent(&reg_pdev->dev.kobj, KOBJ_CHANGE);
+}
 #endif /* CONFIG_CFG80211_INTERNAL_REGDB */
 
 /*
@@ -492,16 +501,8 @@  static inline void reg_regdb_query(const char *alpha2) {}
  */
 static int call_crda(const char *alpha2)
 {
-	if (!is_world_regdom((char *) alpha2))
-		pr_info("Calling CRDA for country: %c%c\n",
-			alpha2[0], alpha2[1]);
-	else
-		pr_info("Calling CRDA to update world regulatory domain\n");
-
-	/* query internal regulatory database (if it exists) */
-	reg_regdb_query(alpha2);
-
-	return kobject_uevent(&reg_pdev->dev.kobj, KOBJ_CHANGE);
+	/* query internal regulatory database/crda depending on config */
+	return reg_regdb_query(alpha2);
 }
 
 static enum reg_request_treatment