# Help with wpa_supplicant

## grant123

I had my Netgear PCMCIA card set up via the madwifi instructions here:

https://forums.gentoo.org/viewtopic.php?t=122435

but it started working only intermittently after a baselayout upgrade.  I'd like to set it up via wpa_supplicant now.  I've made the necessary changes to my router's config, and set up my wpa_supplicant.conf file like this:

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=0

eapol_version=1

ap_scan=1

network={

        ssid="network1"

        proto=WPA

        key_mgmt=WPA-PSK

        psk="mypassword"

}

If I try to run wpa_supplicant manually I get:

system4 ~ # wpa_supplicant -w -d -c/etc/wpa_supplicant.conf -iath0 -Dmadwifi

Configuration file '/etc/wpa_supplicant.conf' -> '/etc/wpa_supplicant.conf'

Reading configuration file '/etc/wpa_supplicant.conf'

ctrl_interface='/var/run/wpa_supplicant'

ctrl_interface_group=0

eapol_version=1

ap_scan=1

Priority group 0

  id=0 ssid='network1'

EAPOL: SUPP_PAE entering state DISCONNECTED

EAPOL: KEY_RX entering state NO_KEY_RECEIVE

EAPOL: SUPP_BE entering state INITIALIZE

EAP: EAP entering state DISABLED

EAPOL: External notification - portEnabled=0

EAPOL: External notification - portValid=0

wpa_driver_madwifi_set_wpa: enabled=1

wpa_driver_madwifi_del_key: keyidx=0

wpa_driver_madwifi_del_key: keyidx=1

wpa_driver_madwifi_del_key: keyidx=2

wpa_driver_madwifi_del_key: keyidx=3

wpa_driver_madwifi_set_countermeasures: enabled=0

wpa_driver_madwifi_set_drop_unencrypted: enabled=1

Setting scan request: 0 sec 100000 usec

l2_packet_receive - recv: Network is down

Starting AP scan (broadcast SSID)

RTM_NEWLINK, IFLA_IFNAME: Interface 'ath0' added

RTM_NEWLINK, IFLA_IFNAME: Interface 'ath0' added

Wireless event: cmd=0x8b1a len=12

Wireless event: cmd=0x8b19 len=12

Received 0 bytes of scan results (0 BSSes)

Scan results: 0

Selecting BSS from priority group 0

No suitable AP found.

Setting scan request: 5 sec 0 usec

Signal 2 received - terminating

and it continues like that.  Can anyone help me figure this out?  I

can double up on the debugging output if anyone thinks it will be useful.

- Grant

----------

## UberLord

Looks like it cannot find the AP

Ensure that it's broadcasting its SSID

----------

## grant123

Hi UberLord, thanks for all your help thus far.

I have this in my Netgear router's config:

Enable Wireless Radio: Yes

Enable SSID Broadcast: Yes

Fragmentation Threshold: 2346

CTS/RTS Threshold: 2346

Preamble Mode: Automatic

Does that seem right?

- Grant

----------

## grant123

I should also mention that I'm currently online with that other set of wireless instructions of your's with the router set to no encryption.  It must be broadcasting right?

- Grant

----------

## UberLord

Try this wpa_supplicant config

```

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=0

ap_scan=1

network={

ssid="network1"

psk="mypassword"

}
```

----------

## grant123

YEAH!  The output looks pretty damn good.  The only thing is if I try to run '/etc/init.d/wpa_supplicant start' I get:

* Starting wpa_supplicant ...

*   eth1 ...

eth1: unknown interface: No such device   [ ok ]

The contents of /var/run/wpa_supplicant are as follows:

srwxrwx---  1 root root 0 Mar 23 07:13 eth1

I think I need to get it to use ath0 instead.  How can I do that?

- Grant

----------

## grant123

Also I don't seem to be able to reach the Internet.  Here's the output without debugging:

system4 ~ # wpa_supplicant -c/etc/wpa_supplicant.conf -iath0 -Dmadwifi

l2_packet_receive - recv: Network is down

Trying to associate with the:address (SSID='network1' freq=2422 MHz)

Associated with the:address

Trying to associate with the:address (SSID='network1' freq=2422 MHz)

Associated with the:address

WPA: Key negotiation completed with the:address

- Grant

----------

## UberLord

Why don't you try baselayout-1.11.10-r3 as it has wpa_supplicant support?

1) emerge baselayout-1.11.10-r3 and unstable versions of bash, sys-libs/readline and sysvinit

2) remove wpa_supplicant from the default runlevel

```

rc-update del wpa_supplicant

rc

```

3) configure /etc/conf.d/net for wpa_supplicant

```

modules=( "wpa_supplicant" )

wpa_supplicant_ath0="-Dmadwifi"

```

4) Go!

```

/etc/init.d/net.ath0 start

```

----------

## grant123

UberLord, YOU ARE THE MAN.

I'm using ~x86 baselayout, bash, readline, and sysvinit.  I added what you specified to my blank /etc/conf.d/net and issued 'rc'.  ath0 came right up.  This is too great.

What does 'rc' do?  Does it just make sure everything is running that's supposed to be running based on 'rc-update -s'?

Do I still need madwifi-driver and wireless-tools?

- Grant

----------

## UberLord

 *grant123 wrote:*   

> UberLord, YOU ARE THE MAN.

 

Yes, I know  :Cool: 

 *Quote:*   

> What does 'rc' do?  Does it just make sure everything is running that's supposed to be running based on 'rc-update -s'?

 

exactly that

 *Quote:*   

> 
> 
> Do I still need madwifi-driver and wireless-tools?
> 
> 

 

You still need madwifi-driver.

You only need wireless tools if you're only going to use wpa_supplicant.

----------

## grant123

Damn.  I rebooted to watch everything come up fresh, but now I always get:

*    Starting wpa_supplicant on ath0 ...  [ ok ]

*       timed out   [ !! ]

The only thing I changed before rebooting was upgrading sysvinit from 2.85-r1 to 2.6.  I have since emerged back to the latter with no luck.

I've been doing all of this in 2.6.7, and when I to boot 2.6.11 I get an 'ath0 does not exist' error instead of the above.  That's the same thing I was getting before I started working on wpa_supplicant.  I'm not sure why those two kernels would have different configs for ath0.

- Grant

----------

## nichocouk

Have you reinstalled the necessary tools against your new kernel? It looks like your drivers need to be recompiled:

```
emerge madwifi-tools madwifi-driver
```

It's probably not a bad idea to do the same with wpa_supplicant, wireless-tools, baselayout, etc... (although I'm not sure if it is absolutely needed)

----------

## UberLord

 *grant123 wrote:*   

> I'm not sure why those two kernels would have different configs for ath0.

 

They don't - however only one kernel has the ath0 driver!

I suggest booting a 2.6.11 kernel, ensure that /usr/src/linux points to 2.6.11 sources and then re-emerge madwifi-driver

Reboot and you should be working

----------

## grant123

I've tried booting into 2.6.11, making sure /usr/src/linux points to the right source, emerging madwifi-driver and madwifi-tools, and rebooting but I get the same errors as before.  Two of these are printed:

ath0: error fetching interface information: device not found

followed by:

ath0 does not exist

a couple lines later.

I've also tried booting into 2.6.7, changing /usr/src/linux to point to that source, emerging madwifi-driver and madwifi-tools, and rebooting but it does this as before:

* Starting wpa_supplicant on ath0 ... [ ok ]

* timed out [ !! ]

Running wpa_supplicant manually gives me the same output from my first post.  What could the problem be?

- Grant

----------

## grant123

All of my packages and etc files are now updated and this problem persists.  I have also unmerged all kernels builds, rm -rf 'ed them, emerged hardened-dev-sources (2.6.11), re-emerged madwifi-driver and madwifi-tools, and restarted, but the results are the same.  Here is where I'm at:

system4 ~ # rc

 * Starting ath0

 *    Bringing up ath0

 *       Configuration not set for ath0 - assuming dhcp

 *       dhcp

 *          ath0 does not exist   [ !! ]

What can I do to make ath0 exist?

- Grant

----------

## UberLord

Add ath_pci to /etc/modules.autoload.d

You may need to add wlan_tkip (for wpa) and/or wlan_wep (for wep) *after* ath_pci

----------

## grant123

I do have ath_pci in /etc/modules.autoload.d/kernel-2.6 and it always loads at startup without any errors.

system4 ~ # modprobe wlan_tkip

system4 ~ # rc

 * Starting ath0

 *    Bringing up ath0

 *       Configuration not set for ath0 - assuming dhcp

 *       dhcp

 *          ath0 does not exist

- Grant

----------

## grant123

Make that:

system4 ~ # modprobe wlan_tkip wlan_wep

system4 ~ # rc

 * Starting ath0

 *    Bringing up ath0

 *       Configuration not set for ath0 - assuming dhcp

 *       dhcp

 *          ath0 does not exist

- Grant

----------

## grant123

Here's what I'm getting trying to run wpa_supplicant manually:

system4 ~ # wpa_supplicant -ddw -c/etc/wpa_supplicant.conf -Dmadwifi -iath0

Configuration file '/etc/wpa_supplicant.conf' -> '/etc/wpa_supplicant.conf'

Reading configuration file '/etc/wpa_supplicant.conf'

ctrl_interface='/var/run/wpa_supplicant'

ctrl_interface_group=0

ap_scan=1

Line: 187 - start of a new network block

SSID - hexdump_ascii(len= :Cool: :

     sensitive?                           network1

PSK (ASCII passphrase) - hexdump_ascii(len= :Cool: :

     sensitive?                           mypassword

PSK (from passphrase) - hexdump(len=32): sensitive?

Priority group 0

   id=0 ssid='network1'

Using existing control interface directory.

EAPOL: SUPP_PAE entering state DISCONNECTED

EAPOL: KEY_RX entering state NO_KEY_RECEIVE

EAPOL: SUPP_BE entering state INITIALIZE

EAP: EAP entering state DISABLED

EAPOL: External notification - portEnabled=0

EAPOL: External notification - portValid=0

ioctl[SIOCGIFINDEX]: No such device

Waiting for interface..

ioctl[SIOCGIFINDEX]: No such device

Waiting for interface..

ioctl[SIOCGIFINDEX]: No such device

Waiting for interface..

- Grant

----------

## UberLord

Everything you've posted says you don't have the correct kernel module installed

```

uberpc roy # dmesg | grep ath

ath_hal: module license 'Proprietary' taints kernel.

ath_hal: 0.9.14.9 (AR5210, AR5211, AR5212, RF5111, RF5112, RF2413)

ath_rate_onoe: 1.0

ath_pci: 0.9.4.12 (EXPERIMENTAL)

ath0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps

ath0: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps

ath0: mac 5.6 phy 4.1 radio 1.7

ath0: 802.11 address: 00:09:5b:84:88:7d

ath0: Use hw queue 0 for WME_AC_BE traffic

ath0: Use hw queue 1 for WME_AC_BK traffic

ath0: Use hw queue 2 for WME_AC_VI traffic

ath0: Use hw queue 3 for WME_AC_VO traffic

ath0: Atheros 5212: mem=0xf0120000, irq=201

ath0: no IPv6 routers present

```

If you don't get anything like that after modprobe ath_pci then you probably do not have an atheros wifi chipset.

Maybe post the output of lspic?

----------

## grant123

system4 ~ # dmesg |grep ath

ath_hal: module license 'Proprietary' taints kernel.

ath_hal: 0.9.14.9 (AR5210, AR5211, AR5212, RF5111, RF5112, RF2413)

ath_rate_onoe: 1.0

ath_pci: 0.9.4.12 (EXPERIMENTAL)

It was working 100% of the time before a baselayout update a while back, and about 50% of the time after that until I tried to change over to wpa_supplicant.

The problem seems to be with 2.6.11 grabbing the driver.  I just fixed my /etc/make.profile link and 'emerge -pDu world' now wants to install linux-headers-2.6 for the first time.  I'm hoping that, re-emerging madwifi-driver, and restarting gets this moving.

----------

## nichocouk

Hello there,

I'm also getting some trouble with my wifi... I used to connect with just WEP 128 bit encryption  and it worked fine. As I understand that WPA is better, I have configured my router for WPA with PSK. I mean that I have left all the settings regarding WEP untouched (so I still have a 128 bit key defined), and I enabled WPA with PSK (TKIP), and defined a lovely password (are there any forbidden characters in the password? it's all ascii anyway)

My problem is that I don't manage to connect now. 

My wpa_supplicant. conf file is:

```

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=0

eapol_version=1

ap_scan=1

network={

        ssid="myssid"

        #key_mgmt=NONE

        key_mgmt=WPA-PSK

        psk="my-psk-phrase"

        pairwise=TKIP

        group=TKIP

        wep_key0=mywepkey

}

```

I've tried with/without the wep_key0 field but it never works.

If I manually run wpa_supplicant I get this: (with some editing for the keys and stuff)

```

Configuration file '/etc/wpa_supplicant.conf' -> '/etc/wpa_supplicant.conf'

Reading configuration file '/etc/wpa_supplicant.conf'

ctrl_interface='/var/run/wpa_supplicant'

ctrl_interface_group=0

eapol_version=1

ap_scan=1

Line: ... - start of a new network block

SSID - hexdump_ascii(len=NN):

     blah blah                  myssid

key_mgmt: 0x2

PSK (ASCII passphrase) - hexdump_ascii(len=NN):

     blah blah                  mypskphrase

pairwise: 0x8

group: 0x8

wep_key0 - hexdump(len=NN): blah blah

PSK (from passphrase) - hexdump(len=NN): blah blah

Priority group 0

   id=0 ssid='myssid'

EAPOL: SUPP_PAE entering state DISCONNECTED

EAPOL: KEY_RX entering state NO_KEY_RECEIVE

EAPOL: SUPP_BE entering state INITIALIZE

EAP: EAP entering state DISABLED

EAPOL: External notification - portEnabled=0

EAPOL: External notification - portValid=0

wpa_driver_madwifi_set_wpa: enabled=1

wpa_driver_madwifi_del_key: keyidx=0

wpa_driver_madwifi_del_key: keyidx=1

wpa_driver_madwifi_del_key: keyidx=2

wpa_driver_madwifi_del_key: keyidx=3

wpa_driver_madwifi_set_countermeasures: enabled=0

wpa_driver_madwifi_set_drop_unencrypted: enabled=1

Setting scan request: 0 sec 100000 usec

Starting AP scan (broadcast SSID)

Wireless event: cmd=0x8b1a len=12

EAPOL: Port Timers tick - authWhile=0 heldWhile=0 startWhen=0 idleWhile=0

Wireless event: cmd=0x8b19 len=12

Received 260 bytes of scan results (1 BSSes)

Scan results: 1

Selecting BSS from priority group 0

0: 00:05:b4:07:e9:91 ssid='myssid' wpa_ie_len=26 rsn_ie_len=0

   selected

Trying to associate with 00:05:b4:07:e9:91 (SSID='myssid' freq=2437 MHz)

Cancelling scan request

WPA: using IEEE 802.11i/D3.0

WPA: Own WPA IE - hexdump(len=NN): blah blah

wpa_driver_madwifi_del_key: keyidx=0

wpa_driver_madwifi_del_key: keyidx=1

wpa_driver_madwifi_del_key: keyidx=2

wpa_driver_madwifi_del_key: keyidx=3

wpa_driver_madwifi_del_key: keyidx=0

wpa_driver_madwifi_set_drop_unencrypted: enabled=1

wpa_driver_madwifi_associate

Setting authentication timeout: 5 sec 0 usec

EAPOL: External notification - EAP success=0

EAPOL: External notification - EAP fail=0

EAPOL: External notification - portControl=Auto

Wireless event: cmd=0x8b1a len=23

Wireless event: cmd=0x8b15 len=20

Wireless event: new AP: 00:05:b4:07:e9:91

Association event - clear replay counter

Associated to a new BSS: BSSID=00:05:b4:07:e9:91

wpa_driver_madwifi_del_key: keyidx=0

wpa_driver_madwifi_del_key: keyidx=1

wpa_driver_madwifi_del_key: keyidx=2

wpa_driver_madwifi_del_key: keyidx=3

wpa_driver_madwifi_del_key: keyidx=0

Associated with 00:05:b4:07:e9:91

EAPOL: External notification - portEnabled=0

EAPOL: External notification - portValid=0

EAPOL: External notification - EAP success=0

EAPOL: External notification - portEnabled=1

EAPOL: SUPP_PAE entering state CONNECTING

EAPOL: txStart

WPA: drop TX EAPOL in non-IEEE 802.1X mode (type=1 len=0)

EAPOL: SUPP_BE entering state IDLE

EAP: EAP entering state INITIALIZE

EAP: EAP entering state IDLE

Setting authentication timeout: 10 sec 0 usec

RTM_NEWLINK, IFLA_IFNAME: Interface 'ath0' added

EAPOL: Port Timers tick - authWhile=0 heldWhile=0 startWhen=29 idleWhile=59

EAPOL: Port Timers tick - authWhile=0 heldWhile=0 startWhen=28 idleWhile=58

EAPOL: Port Timers tick - authWhile=0 heldWhile=0 startWhen=27 idleWhile=57

RX EAPOL from 00:05:b4:07:e9:8e

RX EAPOL - hexdump(len=NN): blah blah

Setting authentication timeout: 10 sec 0 usec

EAPOL: Ignoring WPA EAPOL-Key frame in EAPOL state machines

IEEE 802.1X RX: version=1 type=3 length=95

  EAPOL-Key type=254

WPA: RX EAPOL-Key - hexdump(len=NN): blah blah

WPA: RX message 1 of 4-Way Handshake from 00:05:b4:07:e9:8e (ver=1)

WPA: WPA IE for msg 2/4 - hexdump(len=NN): blah blah

WPA: Renewed SNonce - hexdump(len=NN): blah blah

WPA: PMK - hexdump(len=NN): blah blah

WPA: PTK - hexdump(len=NN): blah blah

WPA: EAPOL-Key MIC - hexdump(len=NN): blah blah

WPA: Sending EAPOL-Key 2/4

WPA: TX EAPOL-Key 2/4 - hexdump(len=NN): blah blah

EAPOL: Port Timers tick - authWhile=0 heldWhile=0 startWhen=26 idleWhile=56

EAPOL: Port Timers tick - authWhile=0 heldWhile=0 startWhen=25 idleWhile=55

EAPOL: Port Timers tick - authWhile=0 heldWhile=0 startWhen=24 idleWhile=54

RX EAPOL from 00:05:b4:07:e9:8e

RX EAPOL - hexdump(len=NN): blah blah

EAPOL: Ignoring WPA EAPOL-Key frame in EAPOL state machines

IEEE 802.1X RX: version=1 type=3 length=95

  EAPOL-Key type=254

WPA: RX EAPOL-Key - hexdump(len=NN): blah blah

WPA: RX message 1 of 4-Way Handshake from 00:05:b4:07:e9:8e (ver=1)

WPA: WPA IE for msg 2/4 - hexdump(len=NN): blah blah

WPA: PMK - hexdump(len=NN): blah blah

WPA: PTK - hexdump(len=NN): blah blah

WPA: EAPOL-Key MIC - hexdump(len=NN): blah blah

WPA: Sending EAPOL-Key 2/4

WPA: TX EAPOL-Key 2/4 - hexdump(len=NN): blah blah

EAPOL: Port Timers tick - authWhile=0 heldWhile=0 startWhen=23 idleWhile=53

EAPOL: Port Timers tick - authWhile=0 heldWhile=0 startWhen=22 idleWhile=52

EAPOL: Port Timers tick - authWhile=0 heldWhile=0 startWhen=21 idleWhile=51

RX EAPOL from 00:05:b4:07:e9:8e

RX EAPOL - hexdump(len=NN): blah blah

EAPOL: Ignoring WPA EAPOL-Key frame in EAPOL state machines

IEEE 802.1X RX: version=1 type=3 length=95

  EAPOL-Key type=254

WPA: RX EAPOL-Key - hexdump(len=NN): blah blah

WPA: RX message 1 of 4-Way Handshake from 00:05:b4:07:e9:8e (ver=1)

WPA: WPA IE for msg 2/4 - hexdump(len=NN): blah blah

WPA: PMK - hexdump(len=NN): blah blah

WPA: PTK - hexdump(len=NN): blah blah

WPA: EAPOL-Key MIC - hexdump(len=NN): blah blah

WPA: Sending EAPOL-Key 2/4

WPA: TX EAPOL-Key 2/4 - hexdump(len=NN): blah blah

EAPOL: Port Timers tick - authWhile=0 heldWhile=0 startWhen=20 idleWhile=50

EAPOL: Port Timers tick - authWhile=0 heldWhile=0 startWhen=19 idleWhile=49

EAPOL: Port Timers tick - authWhile=0 heldWhile=0 startWhen=18 idleWhile=48

RX EAPOL from 00:05:b4:07:e9:8e

RX EAPOL - hexdump(len=NN): blah blah

EAPOL: Ignoring WPA EAPOL-Key frame in EAPOL state machines

IEEE 802.1X RX: version=1 type=3 length=95

  EAPOL-Key type=254

WPA: RX EAPOL-Key - hexdump(len=NN): blah blah

WPA: RX message 1 of 4-Way Handshake from 00:05:b4:07:e9:8e (ver=1)

WPA: WPA IE for msg 2/4 - hexdump(len=NN): blah blah

WPA: PMK - hexdump(len=NN): blah blah

WPA: PTK - hexdump(len=NN): blah blah

WPA: EAPOL-Key MIC - hexdump(len=NN): blah blah

WPA: Sending EAPOL-Key 2/4

WPA: TX EAPOL-Key 2/4 - hexdump(len=NN): blah blah

Wireless event: cmd=0x8b15 len=20

Wireless event: new AP: 00:00:00:00:00:00

Setting scan request: 0 sec 100000 usec

EAPOL: External notification - portEnabled=0

EAPOL: SUPP_PAE entering state DISCONNECTED

EAPOL: SUPP_BE entering state INITIALIZE

EAP: EAP entering state DISABLED

EAPOL: External notification - portValid=0

EAPOL: External notification - EAP success=0

Disconnect event - remove keys

wpa_driver_madwifi_del_key: keyidx=0

wpa_driver_madwifi_del_key: keyidx=1

wpa_driver_madwifi_del_key: keyidx=2

wpa_driver_madwifi_del_key: keyidx=3

wpa_driver_madwifi_del_key: keyidx=0

... it goes on and on

```

I abbreviated it since it doesn't stop by itself.

Any hint? Should I just go back to WEP??!

Thanks a lot.

----------

## grant123

No such luck.  Still getting the same 'ath0 not found'.  What do I need to look at to see why that error is coming up?  Everything is in place.

- Grant

----------

## grant123

OK, the kernel issue is fixed.  It turns out I didn't have any PCMCIA support built in to my 2.6.11.  Sorry about that.

I'm back to the point where trying to start the net.ath0 daemon times out and running wpa_supplicant manually says there is "No suitable AP found."  What can I do from here?

- Grant

----------

## UberLord

Ensure that your AP is broadcasting it's SSID.

Also, if you have wireless-tools installed, check if it can find it

```

ifconfig ath0 up

iwlist ath0 scan

```

----------

## grant123

Hey UberLord,

It just so happens that I have two of these wireless cards (identical).  I slapped the other one in there and it worked.  Then I tried the first one again and it worked.

I did run into a similar situation when they were both working in their systems under your "Wireless the Gentoo way" instructions.  Whenever my laptop would die from lack of power, the wireless card wouldn't work when it was brought back up unless it was first brought back up with the other wireless card inserted.  After that the original card would work if put back in.

What is this all about?  Could it be some type of a firmware issue?  I don't know what to make of it and it could be a real problem if it happened on the road.

- Grant

----------

## UberLord

That's spooky - I really don't know what would be causing that :/

----------

