# WPA+ Ath9k + cfg80211: Calling CRDA to update

## turtles

If I am using encrypted internet I can hardly connect at all.

 my dmesg fills up with these:

```
[78692.055918] wlan0: RX AssocResp from e0:46:9a:3b:07:9e (capab=0x431 status=0 aid=1)

[78692.055931] wlan0: associated

[78692.059988] cfg80211: Pending regulatory request, waiting for it to be processed...

[78789.619396] cfg80211: All devices are disconnected, going to restore regulatory settings

[78789.619413] cfg80211: Restoring regulatory settings

[78789.619446] cfg80211: Calling CRDA to update world regulatory domain

[78790.421671] wlan0: authenticate with e0:46:9a:3b:07:9e (try 1)

[78790.423622] wlan0: authenticated

[78790.423699] wlan0: associate with e0:46:9a:3b:07:9e (try 1)

[78790.427127] wlan0: deauthenticating from e0:46:9a:3b:07:9e by local choice (reason=3)

[78790.466636] wlan0: authenticate with e0:46:9a:3b:07:9e (try 1)

[78790.468825] wlan0: authenticated

[78790.479254] wlan0: associate with e0:46:9a:3b:07:9e (try 1)

[78790.483275] wlan0: RX AssocResp from e0:46:9a:3b:07:9e (capab=0x431 status=0 aid=1)

[78790.483288] wlan0: associated

[78790.488669] wlan0: deauthenticating from e0:46:9a:3b:07:9e by local choice (reason=3)

[78790.497453] wlan0: authenticate with e0:46:9a:3b:07:9e (try 1)

[78790.497497] wlan0: deauthenticating from e0:46:9a:3b:07:9e by local choice (reason=3)

[78838.676054] wlan0: authenticate with e0:46:9a:3b:07:9e (try 1)

[78838.678682] wlan0: authenticated

[78838.678772] wlan0: associate with e0:46:9a:3b:07:9e (try 1)

[78838.683423] wlan0: RX AssocResp from e0:46:9a:3b:07:9e (capab=0x431 status=0 aid=1)

[78838.683437] wlan0: associated

[78838.688702] cfg80211: Pending regulatory request, waiting for it to be processed...

[78904.552322] cfg80211: All devices are disconnected, going to restore regulatory settings

[78904.552337] cfg80211: Restoring regulatory settings

[78904.552369] cfg80211: Calling CRDA to update world regulatory domain

```

My udev adm:

```

KERNEL[1313161320.552737] change   /devices/platform/regulatory.0 (platform)

UDEV_LOG=3

ACTION=change

DEVPATH=/devices/platform/regulatory.0

SUBSYSTEM=platform

MODALIAS=platform:regulatory

COUNTRY=00

SEQNUM=3945

UDEV  [1313161320.570639] change   /devices/platform/regulatory.0 (platform)

UDEV_LOG=3

ACTION=change

DEVPATH=/devices/platform/regulatory.0

SUBSYSTEM=platform

MODALIAS=platform:regulatory

COUNTRY=00

SEQNUM=3945

KERNEL[1313161322.653607] change   /devices/platform/regulatory.0 (platform)

UDEV_LOG=3

ACTION=change

DEVPATH=/devices/platform/regulatory.0

SUBSYSTEM=platform

MODALIAS=platform:regulatory

COUNTRY=00

SEQNUM=3946

```

I have tried updating to latest:

wicd, kernel, wpa_supplicant etc.

any one else experiencing this?

I am not opposed to just commenting cdra out of cfg80211.

EDIT: I was able to disable security on the network and can fonfirm that is not related to WPA(2).

Looks like there is an old patch here:

http://patches.aircrack-ng.org/ath9k_regdomain_override.patch

It references main.c but I have those lines in init.c

I get errors with this part:

 #define CHAN2G(_freq, _idx)  { \

@@ -1588,6 +1593,14 @@

 	if (error != 0)

 		return error;

+	if (modparam_override_eeprom_regdomain != -1) {

+		printk(KERN_ERR "ath9k: DANGER! You're overriding EEPROM-defined regulatory domain.\n");

+		printk(KERN_ERR "ath9k: Your card was not certified to operate on the domain you choosed.\n");

+		printk(KERN_ERR "ath9k: This might result in a violation of your local regulatory rules.\n");

+		printk(KERN_ERR "ath9k: Do not ever do that unless you really know what you do!\n");

+		sc->common.regulatory.current_rd = modparam_override_eeprom_regdomain;

+	}

+

My define CHAN2G(_freq, _idx) looks like:

#define CHAN2G(_freq, _idx)  { \

	.band = IEEE80211_BAND_2GHZ, \

	.center_freq = (_freq), \

	.hw_value = (_idx), \

	.max_power = 20, if (modparam_override_eeprom_regdomain != -1) {

		printk(KERN_ERR "ath9k: Danger! You're overriding EEPROM-defined regulatory domain.\n");

		sc->common.regulatory.current_rd = modparam_override_eeprom_regdomain;

	}\ }

----------

## cach0rr0

ath9k has been off and on for me (I have AR928x)

with 2.6.37 it seems to be very stable

2.6.35 and prior it was a bit dodgy, and would just flat crap out under any kind of load. Now I at least consistently get the top end of Wireless-G speeds, Wireless-N another animal (that's been so buggy on all my cards, I said to hell with it a while back)

I found changing the channels on my wireless router helped as well

If it helps, this is how I have things set up within ddwrt - http://ompldr.org/vOXZjZQ/wrtchansettings.png

knowing your kernel version would be helpful I reckon. lspci -n output as well useful so we can see what chipset

----------

## turtles

Hey thanks for the reply!

```
Linux lapcat 3.0.0-git5 #6 SMP Wed Aug 10 20:08:54 PDT 2011 i686 Mobile Intel(R) Pentium(R) 4 CPU 3.33GHz GenuineIntel GNU
```

udev  164-r2

net-wireless/wireless-tools 29

net-wireless/wpa_supplicant 0.7.3-r5

 It really seems like it does not like the default regulatory domain of my card and when it gets network packets that say I am in the US it disconnects. 

I have emerged iw and net-wireless/wireless-regdb I dont even know if they are related to ath9k.

----------

## cach0rr0

 *turtles wrote:*   

> Hey thanks for the reply!
> 
> ```
> Linux lapcat 3.0.0-git5 #6 SMP Wed Aug 10 20:08:54 PDT 2011 i686 Mobile Intel(R) Pentium(R) 4 CPU 3.33GHz GenuineIntel GNU
> ```
> ...

 

net-wireless/iw is definitely needed for the new nl80211 interface 

wireless-tools is...not completely dead, just not all that useful with some of the newer tools

from your logs it does look like it gets past the regulatory domain bit - it actually associates AND authenticates just fine 

I don't know if the wicd logs are of any help. Have you killed off wicd, just run wpa_supplicant from the command-line by hand, and seen how that fares? If it's successful from the CLI, you will off course need to fire off a "dhcpcd wlan0' to get an IP, test browsing, etc. 

With the 3.0 kernel though honestly, I must admit it's completely foreign territory to me. I've kept up pretty well with the state of ath9k on the 2.6 kernels, but haven't the foggiest idea the state of affairs in 3.0, or if it's even changed. 

These rapid connect/disconnect/connect/disconnect just look a lot like what I get when there's either heaps of interference, or the signal is weak. I'm hesitant to jump to that conclusion, though, because I know the dodgy history of Wireless-N under linux. 

I don't imagine much of what I've typed is all that helpful, my only real ideas:

-test wpa_supplicant from the command-line

-fiddling with channel settings on the wireless router

I just really don't think it's the regulatory issue, but I could certainly be wrong there.

----------

## turtles

 *cach0rr0 wrote:*   

> my only real ideas:
> 
> -test wpa_supplicant from the command-line
> 
> -fiddling with channel settings on the wireless router
> ...

 

Thanks i am always up for an exercise like that. I moved to wicd years ago because I am on a production work laptop moving from network to network all day. I should be able to fall back to CLI WPA configuration but never got it to work.

So this time I did get it to work however; Same issues.

```

wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf

Trying to associate with 00:1b:63:20:de:25 (SSID='JNet' freq=2417 MHz)

Associated with 00:1b:63:20:de:25

WPA: Key negotiation completed with 00:1b:63:20:de:25 [PTK=CCMP GTK=CCMP]

CTRL-EVENT-CONNECTED - Connection to 00:1b:63:20:de:25 completed (auth) [id=1 id_str=]

CTRL-EVENT-DISCONNECTED bssid=00:1b:63:20:de:25 reason=0

Trying to associate with 00:1b:63:20:de:25 (SSID='JNet' freq=2417 MHz)

Associated with 00:1b:63:20:de:25

WPA: Key negotiation completed with 00:1b:63:20:de:25 [PTK=CCMP GTK=CCMP]

CTRL-EVENT-CONNECTED - Connection to 00:1b:63:20:de:25 completed (reauth) [id=1 id_str=]

CTRL-EVENT-DISCONNECTED bssid=00:1b:63:20:de:25 reason=0

Trying to associate with 00:1b:63:20:de:25 (SSID='JNet' freq=2417 MHz)

Associated with 00:1b:63:20:de:25

```

From dmesg:

```
 297.120547] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA

[  970.265822] wlan0: authenticate with 00:1b:63:20:de:25 (try 1)

[  970.267716] wlan0: authenticated

[  970.267765] wlan0: associate with 00:1b:63:20:de:25 (try 1)

[  970.270594] wlan0: RX AssocResp from 00:1b:63:20:de:25 (capab=0x411 status=0 aid=3)

[  970.270601] wlan0: associated

[ 1031.933315] cfg80211: All devices are disconnected, going to restore regulatory settings

[ 1031.933332] cfg80211: Restoring regulatory settings

[ 1031.933348] cfg80211: Calling CRDA for country: CO

[ 1153.159950] wlan0: authenticate with 00:1b:63:20:de:25 (try 1)

[ 1153.161881] wlan0: authenticated

[ 1153.161928] wlan0: associate with 00:1b:63:20:de:25 (try 1)

[ 1153.164769] wlan0: RX AssocResp from 00:1b:63:20:de:25 (capab=0x411 status=0 aid=3)

[ 1153.164776] wlan0: associated

[ 1185.017200] cfg80211: All devices are disconnected, going to restore regulatory settings

```

 Right there! "All devices are disconnected, going to restore regulatory settings"

Reading the source of the kernel I think it wants to disassociate because the Dlink chips are not pre programed with a  regulatory setting.

Here is the udev monitor:

```

KERNEL[1313210397.974375] change   /devices/platform/regulatory.0 (platform)

UDEV_LOG=3

ACTION=change

DEVPATH=/devices/platform/regulatory.0

SUBSYSTEM=platform

MODALIAS=platform:regulatory

COUNTRY=00

SEQNUM=1423

UDEV  [1313210397.978993] change   /devices/platform/regulatory.0 (platform)

UDEV_LOG=3

ACTION=change

DEVPATH=/devices/platform/regulatory.0

SUBSYSTEM=platform

MODALIAS=platform:regulatory

COUNTRY=00

SEQNUM=1423

```

cat /sys/kernel/debug/ieee80211/phy0/ath9k/regval:

```
 0xdeadbeef
```

cat /sys/kernel/debug/ieee80211/phy0/ath9k/regidx 

```
0x00000000
```

When i am online my 

cat regval  =

```
0x00000000
```

I also rolled back my kernel to:

Linux 2.6.39-rc6-git4 #8 SMP Sun Jun 19 10:17:13 PDT 2011 i686 Mobile Intel(R) Pentium(R) 4 CPU 3.33GHz GenuineIntel GNU/Linux

EDIT:

Interesting twist, if i stream something it will not drop the connection for a wile.

and another interesting item is :

```
grep CONFIG_CFG80211_INTERNAL_REGDB /usr/src/linux/.config

# CONFIG_CFG80211_INTERNAL_REGDB is not set
```

I cant even find this option in menuconfig.

It is in the file.

----------

## turtles

Downgrading to 2.6.39-rc6-git4 made it more stable.

I am not getting the udev regulatory domain messages.

EDIT: I am going to post a bug when the bugs.kernel.org website is back up.

----------

## cach0rr0

 *turtles wrote:*   

> 
> 
> EDIT: I am going to post a bug when the bugs.kernel.org website is back up.

 

probably the best route for anyone patient enough to do so

my experience with wireless has been rocky. it's like dealing with a bloody wine connoisseur, "ah yes, the grape harvest from 1994 was a particularly good one, however 1995 the soil was too acidic and the grapes..."

so goes wireless under linux. Things were fine for me under 2.6.29, 2.6.30-32 had issues, 2.6.33 was somewhat stable but would die under heavy load, finally 2.6.36 seemed to be rock solid, thus far 2.6.37 solid. Of course, that's for ath9k

For my iwlagn  (iwl 1000) it's been the same story, but different versions of course. It'll break for a while, be stable for a while, then oh shit, new firmware is buggy, have to run it in G mode, let's see what compat-wireless does - shit, the new firmware is even worse, oh well, i wont use that laptop for a while, then try the 9999 package for linux-firmware again in a month; ah ok, that looks better, I'll just upgrade my kernel now and...dammit, new iwlagn bug

...oh, and joy, now we have nl80211, so i have to update my userspace tools

Conclusion: find a combination that's actually stable, and for the love of all that is holy, never, ever, ever upgrade the kernel or firmware if applicable, until you absolutely must, because you're going to be playing whack-a-mole for the next few releases until you get a decent batch of grapes.

----------

