2008-12-23 05:00:11

by Pavel Roskin

[permalink] [raw]
Subject: [PATCH] crda: use strerror() to report error code verbosely

Signed-off-by: Pavel Roskin <[email protected]>
---
crda.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/crda.c b/crda.c
index afc5df1..fe2766b 100644
--- a/crda.c
+++ b/crda.c
@@ -6,6 +6,7 @@

#include <errno.h>
#include <stdio.h>
+#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -297,7 +298,8 @@ int main(int argc, char **argv)
r = nl_send_auto_complete(nlstate.nl_handle, msg);

if (r < 0) {
- fprintf(stderr, "Failed to send regulatory request: %d\n", r);
+ fprintf(stderr, "Failed to send regulatory request: %s\n",
+ strerror(-r));
goto cb_out;
}

@@ -309,7 +311,7 @@ int main(int argc, char **argv)
r = nl_wait_for_ack(nlstate.nl_handle);
if (r < 0) {
fprintf(stderr, "Failed to set regulatory domain: "
- "%d\n", r);
+ "%s\n", strerror(-r));
goto cb_out;
}
}


2008-12-23 05:57:11

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH] crda: use strerror() to report error code verbosely

On Mon, Dec 22, 2008 at 9:49 PM, Pavel Roskin <[email protected]> wrote:
> Quoting "Luis R. Rodriguez" <[email protected]>:
>
>> I've been trying to avoid string.h on crda.c, granted it only
>> increases the final crda binary by about 30 bytes, but do we really
>> need it? In fact it'd be nice to further trim crda further to save
>> even more space. Thoughts?
>
> OK, maybe we don't need this patch if CDRA works correctly. I'm having bad
> luck with it.
>
> First of all, I cannot generate regulatory.bin that crda would accept.
>
> [proski@dv wireless-regdb]$ make
> ./db2bin.py regulatory.bin db.txt key.priv.pem
> openssl rsa -in key.priv.pem -out key.pub.pem -pubout -outform PEM
> writing RSA key

You don't need to build this unless you want to define your own rules.

> [proski@dv crda]$ make
> GEN keys-gcrypt.c
> CC reglib.o
> CC crda.o
> LD crda
> CC intersect.o
> CC print-regdom.o
> LD intersect
> CC regdbdump.o
> LD regdbdump
> CHK /home/proski/src/wireless-regdb/regulatory.bin
> Database signature verification failed.
> make: *** [verify] Error 234

And if you do and want to use the signature stuff you need to copy the
RSA public key into pubkeys/ directory of CRDA. Did you try that?

Luis

2008-12-23 05:34:22

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH] crda: use strerror() to report error code verbosely

On Mon, Dec 22, 2008 at 9:00 PM, Pavel Roskin <[email protected]> wrote:
> Signed-off-by: Pavel Roskin <[email protected]>
> ---
> crda.c | 6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/crda.c b/crda.c
> index afc5df1..fe2766b 100644
> --- a/crda.c
> +++ b/crda.c
> @@ -6,6 +6,7 @@
>
> #include <errno.h>
> #include <stdio.h>
> +#include <string.h>
> #include <sys/mman.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> @@ -297,7 +298,8 @@ int main(int argc, char **argv)
> r = nl_send_auto_complete(nlstate.nl_handle, msg);
>
> if (r < 0) {
> - fprintf(stderr, "Failed to send regulatory request: %d\n", r);
> + fprintf(stderr, "Failed to send regulatory request: %s\n",
> + strerror(-r));
> goto cb_out;
> }
>
> @@ -309,7 +311,7 @@ int main(int argc, char **argv)
> r = nl_wait_for_ack(nlstate.nl_handle);
> if (r < 0) {
> fprintf(stderr, "Failed to set regulatory domain: "
> - "%d\n", r);
> + "%s\n", strerror(-r));
> goto cb_out;
> }
> }

I've been trying to avoid string.h on crda.c, granted it only
increases the final crda binary by about 30 bytes, but do we really
need it? In fact it'd be nice to further trim crda further to save
even more space. Thoughts?

Luis

2008-12-23 15:05:29

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH] crda: use strerror() to report error code verbosely

On Tue, Dec 23, 2008 at 7:03 AM, Luis R. Rodriguez
<[email protected]> wrote:
> On Tue, Dec 23, 2008 at 6:58 AM, Pavel Roskin <[email protected]> wrote:
>> Quoting "Luis R. Rodriguez" <[email protected]>:
>>
>>> rm -rf on your wireless-regdb git tree and then git checkout -f. Then cp
>>> that regulatory.bin
>>> to the REG_BIN location and try to build that CRDA. Then try that CRDA.
>>
>> I remember I tried "make" in wireless-regdb without having M2Crypto
>> installed. Then I installed M2Crypto and ran "make clean" followed by
>> "make". "make clean" removed the original regulatory.bin.
>>
>> The "clean" target doesn't normally remove files under version control. It
>> only removes files that everybody can generate. For files that are harder
>> to create, there is "make distclean" and "make maintainer-clean".
>
> Good catch. I think it would be a lot simpler if we just referred
> people to the latest dated regulatory.bin:
>
> http://wireless.kernel.org/download/wireless-regdb/
>
> Maybe have a symlink and have CRDA wget it or something? Thoughts?

Oh and while at we can remove the "master" from the filename, its just
there because its part of the tag as its from the master branch.
Thoughts?

Luis

2008-12-23 15:03:34

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH] crda: use strerror() to report error code verbosely

On Tue, Dec 23, 2008 at 6:58 AM, Pavel Roskin <[email protected]> wrote:
> Quoting "Luis R. Rodriguez" <[email protected]>:
>
>> rm -rf on your wireless-regdb git tree and then git checkout -f. Then cp
>> that regulatory.bin
>> to the REG_BIN location and try to build that CRDA. Then try that CRDA.
>
> I remember I tried "make" in wireless-regdb without having M2Crypto
> installed. Then I installed M2Crypto and ran "make clean" followed by
> "make". "make clean" removed the original regulatory.bin.
>
> The "clean" target doesn't normally remove files under version control. It
> only removes files that everybody can generate. For files that are harder
> to create, there is "make distclean" and "make maintainer-clean".

Good catch. I think it would be a lot simpler if we just referred
people to the latest dated regulatory.bin:

http://wireless.kernel.org/download/wireless-regdb/

Maybe have a symlink and have CRDA wget it or something? Thoughts?

Luis

2008-12-23 14:41:20

by Pavel Roskin

[permalink] [raw]
Subject: Re: [PATCH] crda: use strerror() to report error code verbosely

Quoting Davide Pesavento <[email protected]>:

>> [root@ct proski]# COUNTRY=00 crda
>> Failed to set regulatory domain: -22
>> [root@ct proski]# COUNTRY=US crda
>> Failed to set regulatory domain: -22
>> [root@ct proski]# COUNTRY=DE crda
>> Failed to set regulatory domain: -22
>> [root@ct proski]#
>>
>> Maybe it can only be set once? But then -EBUSY would be more reasonable.
>>
>
> AFAIK, you have to use `iw reg set <country>` to manually change it.

That works. As I understand now, crda should never be run manually.
It should only run by the kernel through udev. If that is correct, it
should be written clearly in the crda README.

--
Regards,
Pavel Roskin

2008-12-23 12:14:42

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH] crda: use strerror() to report error code verbosely

On Tue, Dec 23, 2008 at 12:41:21AM -0800, Davide Pesavento wrote:
> On Tue, Dec 23, 2008 at 07:20, Pavel Roskin <[email protected]> wrote:
> > Quoting "Luis R. Rodriguez" <[email protected]>:
> >
> >> You don't need to build this unless you want to define your own rules.
> >
> > I see.
> >
> >> And if you do and want to use the signature stuff you need to copy the
> >> RSA public key into pubkeys/ directory of CRDA. Did you try that?
> >
> > No, I just wanted to install the most current regulatory database. Perhaps
> > the error message should be more clear.
> >
> > With both CONFIG_CFG80211_REG_DEBUG, CONFIG_WIRELESS_OLD_REGULATORY enabled
> > and modular mac80211 and cfg80211, regdomain is set correctly from udev:
> >
> > [ 7.642548] cfg80211: Using static regulatory domain info
> > [ 7.642551] cfg80211: Regulatory domain: US
> > [ 8.697261] cfg80211: Regulatory domain changed to country: US
> >
> > However, changing it to anything doesn't work:
> >
> > [root@ct proski]# COUNTRY=00 crda
> > Failed to set regulatory domain: -22
> > [root@ct proski]# COUNTRY=US crda
> > Failed to set regulatory domain: -22
> > [root@ct proski]# COUNTRY=DE crda
> > Failed to set regulatory domain: -22
> > [root@ct proski]#
> >
> > Maybe it can only be set once? But then -EBUSY would be more reasonable.
> >
>
> AFAIK, you have to use `iw reg set <country>` to manually change it.

Affirmative, or you can use wpa_supplicant from the git tree and add to your conf:

COUNTRY=US

Luis

2008-12-23 14:58:08

by Pavel Roskin

[permalink] [raw]
Subject: Re: [PATCH] crda: use strerror() to report error code verbosely

Quoting "Luis R. Rodriguez" <[email protected]>:

> rm -rf on your wireless-regdb git tree and then git checkout -f.
> Then cp that regulatory.bin
> to the REG_BIN location and try to build that CRDA. Then try that CRDA.

I remember I tried "make" in wireless-regdb without having M2Crypto
installed. Then I installed M2Crypto and ran "make clean" followed by
"make". "make clean" removed the original regulatory.bin.

The "clean" target doesn't normally remove files under version
control. It only removes files that everybody can generate. For
files that are harder to create, there is "make distclean" and "make
maintainer-clean".

--
Regards,
Pavel Roskin

2008-12-23 14:57:49

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH] crda: use strerror() to report error code verbosely

On Tue, Dec 23, 2008 at 6:41 AM, Pavel Roskin <[email protected]> wrote:
> Quoting Davide Pesavento <[email protected]>:
>
>>> [root@ct proski]# COUNTRY=00 crda
>>> Failed to set regulatory domain: -22
>>> [root@ct proski]# COUNTRY=US crda
>>> Failed to set regulatory domain: -22
>>> [root@ct proski]# COUNTRY=DE crda
>>> Failed to set regulatory domain: -22
>>> [root@ct proski]#
>>>
>>> Maybe it can only be set once? But then -EBUSY would be more reasonable.
>>>
>>
>> AFAIK, you have to use `iw reg set <country>` to manually change it.
>
> That works. As I understand now, crda should never be run manually.

That is correct.

> It
> should only run by the kernel through udev. If that is correct, it should
> be written clearly in the crda README.

Apologies if it is not clear. How's this:

---
CALLING CRDA -- UDEV
======================

Distributions can set up a udev rule to allow the kernel's regulatory
domain change request to be reviewed by CRDA so CRDA can pass an
appropriate regulatory domain. An example regulatory rule is provided
with this package as regulatory.rules
---

Or the giant diagram here:

http://wireless.kernel.org/en/developers/Regulatory

This also mentions:

---
CRDA

CRDA is our userspace agent which uploads regulatory domains into the
kernel, it acts as a udev helper.
---

Then the CRDA section on the CRDA page has a section:

http://wireless.kernel.org/en/developers/Regulatory/CRDA#LettingthekernelcallCRDA

We also have iw's documentation:

http://wireless.kernel.org/en/users/Documentation/iw#Updatingyourregulatorydomain

The wiki is editable by everyone so feel free to update that, and also
feel free to send patches to the README as you see fit.

Luis

2008-12-23 06:08:00

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: ath5k: whether "txpower off" is supported ?

On Mon, Dec 22, 2008 at 09:25:20PM -0800, Xu, Martin wrote:
> Hi
> I found that iwconfig txpower off can not work on ath5k driver.
> Ath5k driver(drivers/net/wireless/ath5k/base.c: ath5k_config() ) does not implement the txpower features.
> Some one can confirm me whether txpower off feature has been implemented? If not, why? It is because of the HW limitation? Thanks!

If its not in yet its because no one yet has bothered with it.

> BTW:
> Where can I found the ath5k HW spec? Thanks!

Your source of documentation is the legacy-hal and Sam Leffler's HAL. Have you looked at those?

wget http://www.kernel.org/pub/linux/kernel/people/mcgrof/legacy-hal.tar.bz2
svn co http://svn.freebsd.org/base/projects/ath_hal

Luis

2008-12-23 06:22:28

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH] crda: use strerror() to report error code verbosely

On Mon, Dec 22, 2008 at 10:20:37PM -0800, Pavel Roskin wrote:
> Quoting "Luis R. Rodriguez" <[email protected]>:
>
> > You don't need to build this unless you want to define your own rules.
>
> I see.
>
> > And if you do and want to use the signature stuff you need to copy the
> > RSA public key into pubkeys/ directory of CRDA. Did you try that?
>
> No, I just wanted to install the most current regulatory database.
> Perhaps the error message should be more clear.
>
> With both CONFIG_CFG80211_REG_DEBUG, CONFIG_WIRELESS_OLD_REGULATORY
> enabled and modular mac80211 and cfg80211, regdomain is set correctly
> from udev:
>
> [ 7.642548] cfg80211: Using static regulatory domain info
> [ 7.642551] cfg80211: Regulatory domain: US
> [ 8.697261] cfg80211: Regulatory domain changed to country: US
>
> However, changing it to anything doesn't work:
>
> [root@ct proski]# COUNTRY=00 crda
> Failed to set regulatory domain: -22
> [root@ct proski]# COUNTRY=US crda
> Failed to set regulatory domain: -22
> [root@ct proski]# COUNTRY=DE crda
> Failed to set regulatory domain: -22
> [root@ct proski]#
>
> Maybe it can only be set once? But then -EBUSY would be more reasonable.

rm -rf on your wireless-regdb git tree and then git checkout -f. Then cp that regulatory.bin
to the REG_BIN location and try to build that CRDA. Then try that CRDA.

Luis

2008-12-23 05:25:35

by Xu, Martin

[permalink] [raw]
Subject: ath5k: whether "txpower off" is supported ?

Hi
I found that iwconfig txpower off can not work on ath5k driver.
Ath5k driver(drivers/net/wireless/ath5k/base.c: ath5k_config() ) does not implement the txpower features.
Some one can confirm me whether txpower off feature has been implemented? If not, why? It is because of the HW limitation? Thanks!
BTW:
Where can I found the ath5k HW spec? Thanks!

2008-12-23 15:03:23

by Pavel Roskin

[permalink] [raw]
Subject: Re: [PATCH] crda: use strerror() to report error code verbosely

Quoting "Luis R. Rodriguez" <[email protected]>:

>> It
>> should only run by the kernel through udev. If that is correct, it should
>> be written clearly in the crda README.
>
> Apologies if it is not clear. How's this:
>
> ---
> CALLING CRDA -- UDEV
> ======================
>
> Distributions

... I'm not a distribution. Skipping to the next paragraph. :-)

> Or the giant diagram here:
>
> http://wireless.kernel.org/en/developers/Regulatory

Thanks.

> The wiki is editable by everyone so feel free to update that, and also
> feel free to send patches to the README as you see fit.

Will do. Sorry for the noise.

--
Regards,
Pavel Roskin

2008-12-23 05:49:52

by Pavel Roskin

[permalink] [raw]
Subject: Re: [PATCH] crda: use strerror() to report error code verbosely

Quoting "Luis R. Rodriguez" <[email protected]>:

> I've been trying to avoid string.h on crda.c, granted it only
> increases the final crda binary by about 30 bytes, but do we really
> need it? In fact it'd be nice to further trim crda further to save
> even more space. Thoughts?

OK, maybe we don't need this patch if CDRA works correctly. I'm
having bad luck with it.

First of all, I cannot generate regulatory.bin that crda would accept.

[proski@dv wireless-regdb]$ make
./db2bin.py regulatory.bin db.txt key.priv.pem
openssl rsa -in key.priv.pem -out key.pub.pem -pubout -outform PEM
writing RSA key

[proski@dv crda]$ make
GEN keys-gcrypt.c
CC reglib.o
CC crda.o
LD crda
CC intersect.o
CC print-regdom.o
LD intersect
CC regdbdump.o
LD regdbdump
CHK /home/proski/src/wireless-regdb/regulatory.bin
Database signature verification failed.
make: *** [verify] Error 234

wireless-regdb and crda are current from git. The system is Fedora
10, x86_64 with a custom kernel.

Only regulatory.bin from wireless-regdb-master is OK. It is indeed different.

[proski@dv wireless-regdb]$ cmp -b regulatory.bin /usr/lib/crda/regulatory.bin
regulatory.bin /usr/lib/crda/regulatory.bin differ: byte 2685, line 3
is 36 ^^ 130 X

Once I install the working regulatory.bin, I can compile crda. It
appears that crda needs COUNTRY in the environment, but it's not
documented anywhere and there is no sample file whre to set it. I
tried adding "export COUNTRY=US" to /etc/sysconfig/i18n, and it
appears in the environment when logged in on the console. However,
crda doesn't apprear to see it:

[ 0.720023] cfg80211: Calling CRDA to update world regulatory domain
[ 0.720065] cfg80211: calling CRDA failed - unable to update world
regulatory domain, using static definition

Not only did it try to set the world domain, it failed at that.
However, running crda on the command line is successful:

COUNTRY=00 crda

From the kernel log:

[ 3579.145902] cfg80211: World regulatory domain updated:
[ 3579.145905] (start_freq - end_freq @ bandwidth),
(max_antenna_gain, max_eirp)
[ 3579.145907] (2402000 KHz - 2472000 KHz @ 40000 KHz), (600 mBi, 2000 mBm)

But setting any specific country fails:

[root@ct crda]# COUNTRY=US crda
Failed to set regulatory domain: -22
[root@ct crda]# COUNTRY=DE crda
Failed to set regulatory domain: -22
[root@ct crda]# COUNTRY=RU crda
Failed to set regulatory domain: -22
[root@ct crda]# COUNTRY=QW crda
No country match in regulatory database.
[root@ct crda]#

-22 is -EINVAL, "invalid argument".

At this point I want that crda at least gives me errors in a readable
form. But maybe I want too little :-)

The kernel is current from wireless-testing.git.
CONFIG_WIRELESS_OLD_REGULATORY is disabled. CONFIG_CFG80211_REG_DEBUG
is disabled (I guess I'll try enabling it now). CONFIG_CFG80211 is
enabled. mac80211 is compiled into the kernel. The only modules are
wireless drivers (b43, hostap, rt61).

--
Regards,
Pavel Roskin

2008-12-23 06:20:21

by Pavel Roskin

[permalink] [raw]
Subject: Re: [PATCH] crda: use strerror() to report error code verbosely

Quoting "Luis R. Rodriguez" <[email protected]>:

> You don't need to build this unless you want to define your own rules.

I see.

> And if you do and want to use the signature stuff you need to copy the
> RSA public key into pubkeys/ directory of CRDA. Did you try that?

No, I just wanted to install the most current regulatory database.
Perhaps the error message should be more clear.

With both CONFIG_CFG80211_REG_DEBUG, CONFIG_WIRELESS_OLD_REGULATORY
enabled and modular mac80211 and cfg80211, regdomain is set correctly
from udev:

[ 7.642548] cfg80211: Using static regulatory domain info
[ 7.642551] cfg80211: Regulatory domain: US
[ 8.697261] cfg80211: Regulatory domain changed to country: US

However, changing it to anything doesn't work:

[root@ct proski]# COUNTRY=00 crda
Failed to set regulatory domain: -22
[root@ct proski]# COUNTRY=US crda
Failed to set regulatory domain: -22
[root@ct proski]# COUNTRY=DE crda
Failed to set regulatory domain: -22
[root@ct proski]#

Maybe it can only be set once? But then -EBUSY would be more reasonable.

--
Regards,
Pavel Roskin

2008-12-23 08:41:23

by Davide Pesavento

[permalink] [raw]
Subject: Re: [PATCH] crda: use strerror() to report error code verbosely

On Tue, Dec 23, 2008 at 07:20, Pavel Roskin <[email protected]> wrote:
> Quoting "Luis R. Rodriguez" <[email protected]>:
>
>> You don't need to build this unless you want to define your own rules.
>
> I see.
>
>> And if you do and want to use the signature stuff you need to copy the
>> RSA public key into pubkeys/ directory of CRDA. Did you try that?
>
> No, I just wanted to install the most current regulatory database. Perhaps
> the error message should be more clear.
>
> With both CONFIG_CFG80211_REG_DEBUG, CONFIG_WIRELESS_OLD_REGULATORY enabled
> and modular mac80211 and cfg80211, regdomain is set correctly from udev:
>
> [ 7.642548] cfg80211: Using static regulatory domain info
> [ 7.642551] cfg80211: Regulatory domain: US
> [ 8.697261] cfg80211: Regulatory domain changed to country: US
>
> However, changing it to anything doesn't work:
>
> [root@ct proski]# COUNTRY=00 crda
> Failed to set regulatory domain: -22
> [root@ct proski]# COUNTRY=US crda
> Failed to set regulatory domain: -22
> [root@ct proski]# COUNTRY=DE crda
> Failed to set regulatory domain: -22
> [root@ct proski]#
>
> Maybe it can only be set once? But then -EBUSY would be more reasonable.
>

AFAIK, you have to use `iw reg set <country>` to manually change it.

Regards,
Davide Pesavento

> --
> Regards,
> Pavel Roskin
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>