# More wpa_supplicant woes... madwifi issue [SOLVED]

## infernus

First off, thanks a lot to everyone who helped out with the network module error I made. wpa_supplicant starts up just fine at boot now. There is one problem, though. I can't seem to figure out why, but it seems if I don't maintain some sort of connection, the router seems to stop forwarding requests after a short period. I have to reset the connection before it will work again.. I wonder if sending some sort of keep-alive packet might help (but that should not be necessary)?

Anyway, here is my /etc/wpa_supplicant/wpa_supplicant.conf:

```
# The below line not be changed otherwise we refuse to work

ctrl_interface=/var/run/wpa_supplicant

# Ensure that only root can read the WPA configuration

ctrl_interface_group=wheel

# Let wpa_supplicant take care of scanning and AP selection

ap_scan=2

# Other shit

eapol_version=1

fast_reauth=1

############################

#         Networks         #

############################

# OTIS!

network={

        ssid="Otis Dick"

        scan_ssid=1

        proto=WPA

        key_mgmt=WPA-PSK

        pairwise=CCMP TKIP

        group=CCMP TKIP WEP104 WEP40

        psk=*snip*

        priority=5

}
```

and here is my /etc/conf.d/net:

```
modules=( "wpa_supplicant" "udhcpc" )

wpa_supplicant_ath0="-Dmadwifi"

config_ath0=( "dhcp" )

udhcpc_ath0="-q"

dhcp_ath0=( "nontp" )

config_eth0=( "dhcp" )

udhcpc_eth0="-q"
```

Is there any way I can have it stay connected the whole time without reconnecting? I don't think I messed anything up this time..  :Smile:  Thanks in advance for your help.

----------

## infernus

Sorry about the wait but I got some debugging output from wpa_supplicant.. It's a lot. (Hope it helps):

```
satellite ~ # wpa_supplicant -i ath0 -D madwifi -c /etc/wpa_supplicant/wpa_supplicant.conf -d

Initializing interface 'ath0' conf '/etc/wpa_supplicant/wpa_supplicant.conf' driver 'madwifi' ctrl_interface 'N/A' bridge 'N/A'

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

Reading configuration file '/etc/wpa_supplicant/wpa_supplicant.conf'

ctrl_interface='/var/run/wpa_supplicant'

ctrl_interface_group='wheel' (DEPRECATED)

ap_scan=2

eapol_version=1

fast_reauth=1

Priority group 5

   id=0 ssid='Otis Dick'

Initializing interface (2) 'ath0'

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

SIOCGIWRANGE: WE(compiled)=22 WE(source)=13 enc_capa=0xf

  capabilities: key_mgmt 0xf enc 0xf

WEXT: Operstate: linkmode=1, operstate=5

Own MAC address: 00:90:96:cb:6d:71

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

ctrl_interface_group=10 (from group name 'wheel')

Added interface ath0

RTM_NEWLINK: operstate=0 ifi_flags=0x1002 ()

Wireless event: cmd=0x8b06 len=8

Ignore event for foreign ifindex 4

RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])

RTM_NEWLINK, IFLA_IFNAME: Interface 'ath0' added

State: DISCONNECTED -> SCANNING

Trying to associate with SSID 'Otis Dick'

Cancelling scan request

WPA: clearing own WPA/RSN IE

Automatic auth_alg selection: 0x1

WPA: No WPA/RSN IE available from association info

WPA: Set cipher suites based on configuration

WPA: Selected cipher suites: group 30 pairwise 24 key_mgmt 2 proto 1

WPA: clearing AP WPA IE

WPA: clearing AP RSN IE

WPA: using GTK CCMP

WPA: using PTK CCMP

WPA: using KEY_MGMT WPA-PSK

WPA: Set own WPA IE default - hexdump(len=24): dd 16 00 50 f2 01 01 00 00 50 f2 04 01 00 00 50 f2 04 01 00 00 50 f2 02

No keys have been configured - skip key clearing

wpa_driver_madwifi_set_drop_unencrypted: enabled=1

State: SCANNING -> ASSOCIATING

wpa_driver_wext_set_operstate: operstate 0->0 (DORMANT)

WEXT: Operstate: linkmode=-1, operstate=5

wpa_driver_madwifi_associate

Setting authentication timeout: 60 sec 0 usec

EAPOL: External notification - EAP success=0

EAPOL: External notification - EAP fail=0

EAPOL: External notification - portControl=Auto

RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])

Wireless event: cmd=0x8b1a len=17

RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])

Wireless event: cmd=0x8b19 len=8

Received 414 bytes of scan results (2 BSSes)

Scan results: 2

RTM_NEWLINK: operstate=0 ifi_flags=0x11003 ([UP][LOWER_UP])

Wireless event: cmd=0x8b15 len=20

Wireless event: new AP: 00:11:50:d8:3e:ae

State: ASSOCIATING -> ASSOCIATED

wpa_driver_wext_set_operstate: operstate 0->0 (DORMANT)

WEXT: Operstate: linkmode=-1, operstate=5

Associated to a new BSS: BSSID=00:11:50:d8:3e:ae

No keys have been configured - skip key clearing

Network configuration found for the current AP

WPA: Using WPA IE from AssocReq to set cipher suites

WPA: Selected cipher suites: group 16 pairwise 16 key_mgmt 2 proto 1

WPA: clearing AP WPA IE

WPA: clearing AP RSN IE

WPA: using GTK CCMP

WPA: using PTK CCMP

WPA: using KEY_MGMT WPA-PSK

WPA: Set own WPA IE default - hexdump(len=24): dd 16 00 50 f2 01 01 00 00 50 f2 04 01 00 00 50 f2 04 01 00 00 50 f2 02

EAPOL: External notification - EAP success=0

EAPOL: External notification - EAP fail=0

EAPOL: External notification - portControl=Auto

Associated with 00:11:50:d8:3e:ae

WPA: Association event - clear replay counter

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: SUPP_BE entering state IDLE

Setting authentication timeout: 10 sec 0 usec

Cancelling scan request

RTM_NEWLINK: operstate=0 ifi_flags=0x11003 ([UP][LOWER_UP])

RTM_NEWLINK, IFLA_IFNAME: Interface 'ath0' added

RX EAPOL from 00:11:50:d8:3e:ae

Setting authentication timeout: 10 sec 0 usec

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

  EAPOL-Key type=254

  key_info 0x8a (ver=2 keyidx=0 rsvd=0 Pairwise Ack)

  key_length=16 key_data_length=0

  replay_counter - hexdump(len=8): 00 00 00 00 00 00 00 3e

  key_nonce - hexdump(len=32): e7 a7 bc 33 8c 0a 8d 5e 71 27 02 42 12 09 95 ea 1e 39 f9 c1 1e ad 88 34 5a 63 db 6d 54 ac 28 31

  key_iv - hexdump(len=16): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

  key_rsc - hexdump(len=8): 00 00 00 00 00 00 00 00

  key_id (reserved) - hexdump(len=8): 00 00 00 00 00 00 00 00

  key_mic - hexdump(len=16): 00 00 00 00 00 00 00 00 61 78 2d 61 67 65 3d 36

State: ASSOCIATED -> 4WAY_HANDSHAKE

WPA: RX message 1 of 4-Way Handshake from 00:11:50:d8:3e:ae (ver=2)

WPA: Renewed SNonce - hexdump(len=32): 6f c7 f4 e7 31 d8 e2 02 4b 30 71 4b f6 55 79 39 5f 57 79 0e 26 bc 25 91 0b 18 25 77 bc 6c 4b 58

WPA: PMK - hexdump(len=32): [REMOVED]

WPA: PTK - hexdump(len=64): [REMOVED]

WPA: WPA IE for msg 2/4 - hexdump(len=24): dd 16 00 50 f2 01 01 00 00 50 f2 04 01 00 00 50 f2 04 01 00 00 50 f2 02

WPA: Sending EAPOL-Key 2/4

RX EAPOL from 00:11:50:d8:3e:ae

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

  EAPOL-Key type=254

  key_info 0x1ca (ver=2 keyidx=0 rsvd=0 Pairwise Install Ack MIC)

  key_length=16 key_data_length=24

  replay_counter - hexdump(len=8): 00 00 00 00 00 00 00 3f

  key_nonce - hexdump(len=32): e7 a7 bc 33 8c 0a 8d 5e 71 27 02 42 12 09 95 ea 1e 39 f9 c1 1e ad 88 34 5a 63 db 6d 54 ac 28 31

  key_iv - hexdump(len=16): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

  key_rsc - hexdump(len=8): 00 00 00 00 00 00 00 00

  key_id (reserved) - hexdump(len=8): 00 00 00 00 00 00 00 00

  key_mic - hexdump(len=16): bd 08 0a ea a6 ec 12 14 0e 1f ad 3e ca e0 73 11

State: 4WAY_HANDSHAKE -> 4WAY_HANDSHAKE

WPA: RX message 3 of 4-Way Handshake from 00:11:50:d8:3e:ae (ver=2)

WPA: IE KeyData - hexdump(len=24): dd 16 00 50 f2 01 01 00 00 50 f2 04 01 00 00 50 f2 04 01 00 00 50 f2 02

WPA: No WPA/RSN IE for this AP known. Trying to get from scan results

WPA: set AP WPA IE - hexdump(len=24): dd 16 00 50 f2 01 01 00 00 50 f2 04 01 00 00 50 f2 04 01 00 00 50 f2 02

WPA: clearing AP RSN IE

WPA: Found the current AP from updated scan results

WPA: Sending EAPOL-Key 4/4

WPA: Installing PTK to the driver.

WPA: RSC - hexdump(len=6): 00 00 00 00 00 00

wpa_driver_madwifi_set_key: alg=CCMP key_idx=0 set_tx=1 seq_len=6 key_len=16

State: 4WAY_HANDSHAKE -> GROUP_HANDSHAKE

RX EAPOL from 00:11:50:d8:3e:ae

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

  EAPOL-Key type=254

  key_info 0x392 (ver=2 keyidx=1 rsvd=0 Group Ack MIC Secure)

  key_length=16 key_data_length=24

  replay_counter - hexdump(len=8): 00 00 00 00 00 00 00 40

  key_nonce - hexdump(len=32): 7c 1c 12 ea c6 8a 35 c4 d5 31 21 23 7f 7f f9 ff be 83 56 3e e3 39 88 25 e4 ac ff 8f 41 f4 5f 7e

  key_iv - hexdump(len=16): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

  key_rsc - hexdump(len=8): a0 02 00 00 00 00 00 00

  key_id (reserved) - hexdump(len=8): 00 00 00 00 00 00 00 00

  key_mic - hexdump(len=16): de 94 17 16 ec 2f d3 8e f8 44 d5 2d 20 58 f2 9c

WPA: RX message 1 of Group Key Handshake from 00:11:50:d8:3e:ae (ver=2)

State: GROUP_HANDSHAKE -> GROUP_HANDSHAKE

WPA: Group Key - hexdump(len=16): [REMOVED]

WPA: Installing GTK to the driver (keyidx=1 tx=0).

WPA: RSC - hexdump(len=6): a0 02 00 00 00 00

wpa_driver_madwifi_set_key: alg=CCMP key_idx=1 set_tx=0 seq_len=6 key_len=16

WPA: Sending EAPOL-Key 2/2

WPA: Key negotiation completed with 00:11:50:d8:3e:ae [PTK=CCMP GTK=CCMP]

Cancelling authentication timeout

State: GROUP_HANDSHAKE -> COMPLETED

CTRL-EVENT-CONNECTED - Connection to 00:11:50:d8:3e:ae completed (auth) [id=0 id_str=]

wpa_driver_wext_set_operstate: operstate 0->1 (UP)

WEXT: Operstate: linkmode=-1, operstate=6

EAPOL: External notification - portValid=1

EAPOL: External notification - EAP success=1

EAPOL: SUPP_PAE entering state AUTHENTICATING

EAPOL: SUPP_BE entering state SUCCESS

EAP: EAP entering state DISABLED

EAPOL: SUPP_PAE entering state AUTHENTICATED

EAPOL: SUPP_BE entering state IDLE

RTM_NEWLINK: operstate=1 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])

RTM_NEWLINK, IFLA_IFNAME: Interface 'ath0' added

EAPOL: startWhen --> 0

RTM_NEWLINK: operstate=1 ifi_flags=0x1043 ([UP][RUNNING])

Wireless event: cmd=0x8b15 len=20

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

Setting scan request: 0 sec 100000 usec

Added BSSID 00:11:50:d8:3e:ae into blacklist

CTRL-EVENT-DISCONNECTED - 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

State: COMPLETED -> DISCONNECTED

wpa_driver_wext_set_operstate: operstate 1->0 (DORMANT)

WEXT: Operstate: linkmode=-1, operstate=5

EAPOL: External notification - portEnabled=0

EAPOL: SUPP_PAE entering state DISCONNECTED

EAPOL: SUPP_BE entering state INITIALIZE

EAPOL: External notification - portValid=0

EAPOL: External notification - EAP success=0

RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])

RTM_NEWLINK, IFLA_IFNAME: Interface 'ath0' added

RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])

RTM_NEWLINK, IFLA_IFNAME: Interface 'ath0' added

State: DISCONNECTED -> SCANNING

Trying to associate with SSID 'Otis Dick'

Cancelling scan request

WPA: clearing own WPA/RSN IE

Automatic auth_alg selection: 0x1

WPA: No WPA/RSN IE available from association info

WPA: Set cipher suites based on configuration

WPA: Selected cipher suites: group 30 pairwise 24 key_mgmt 2 proto 1

WPA: clearing AP WPA IE

WPA: clearing AP RSN IE

WPA: using GTK CCMP

WPA: using PTK CCMP

WPA: using KEY_MGMT WPA-PSK

WPA: Set own WPA IE default - hexdump(len=24): dd 16 00 50 f2 01 01 00 00 50 f2 04 01 00 00 50 f2 04 01 00 00 50 f2 02

No keys have been configured - skip key clearing

wpa_driver_madwifi_set_drop_unencrypted: enabled=1

State: SCANNING -> ASSOCIATING

wpa_driver_wext_set_operstate: operstate 0->0 (DORMANT)

WEXT: Operstate: linkmode=-1, operstate=5

wpa_driver_madwifi_associate

Setting authentication timeout: 60 sec 0 usec

EAPOL: External notification - EAP success=0

EAPOL: External notification - EAP fail=0

EAPOL: External notification - portControl=Auto

RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])

Wireless event: cmd=0x8b1a len=17

Authentication with 00:00:00:00:00:00 timed out.

Added BSSID 00:00:00:00:00:00 into blacklist

State: ASSOCIATING -> DISCONNECTED

wpa_driver_wext_set_operstate: operstate 0->0 (DORMANT)

WEXT: Operstate: linkmode=-1, operstate=5

No keys have been configured - skip key clearing

EAPOL: External notification - portEnabled=0

EAPOL: External notification - portValid=0

Setting scan request: 0 sec 0 usec

State: DISCONNECTED -> SCANNING

Trying to associate with SSID 'Otis Dick'

Cancelling scan request

WPA: clearing own WPA/RSN IE

Automatic auth_alg selection: 0x1

WPA: No WPA/RSN IE available from association info

WPA: Set cipher suites based on configuration

WPA: Selected cipher suites: group 30 pairwise 24 key_mgmt 2 proto 1

WPA: clearing AP WPA IE

WPA: clearing AP RSN IE

WPA: using GTK CCMP

WPA: using PTK CCMP

WPA: using KEY_MGMT WPA-PSK

WPA: Set own WPA IE default - hexdump(len=24): dd 16 00 50 f2 01 01 00 00 50 f2 04 01 00 00 50 f2 04 01 00 00 50 f2 02

No keys have been configured - skip key clearing

wpa_driver_madwifi_set_drop_unencrypted: enabled=1

State: SCANNING -> ASSOCIATING

wpa_driver_wext_set_operstate: operstate 0->0 (DORMANT)

WEXT: Operstate: linkmode=-1, operstate=5

wpa_driver_madwifi_associate

Setting authentication timeout: 60 sec 0 usec

EAPOL: External notification - EAP success=0

EAPOL: External notification - EAP fail=0

EAPOL: External notification - portControl=Auto

RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])

Wireless event: cmd=0x8b1a len=17

Authentication with 00:00:00:00:00:00 timed out.

BSSID 00:00:00:00:00:00 blacklist count incremented to 2

State: ASSOCIATING -> DISCONNECTED

wpa_driver_wext_set_operstate: operstate 0->0 (DORMANT)

WEXT: Operstate: linkmode=-1, operstate=5

No keys have been configured - skip key clearing

EAPOL: External notification - portEnabled=0

EAPOL: External notification - portValid=0

Setting scan request: 0 sec 0 usec

State: DISCONNECTED -> SCANNING

Trying to associate with SSID 'Otis Dick'

Cancelling scan request

WPA: clearing own WPA/RSN IE

Automatic auth_alg selection: 0x1

WPA: No WPA/RSN IE available from association info

WPA: Set cipher suites based on configuration

WPA: Selected cipher suites: group 30 pairwise 24 key_mgmt 2 proto 1

WPA: clearing AP WPA IE

WPA: clearing AP RSN IE

WPA: using GTK CCMP

WPA: using PTK CCMP

WPA: using KEY_MGMT WPA-PSK

WPA: Set own WPA IE default - hexdump(len=24): dd 16 00 50 f2 01 01 00 00 50 f2 04 01 00 00 50 f2 04 01 00 00 50 f2 02

No keys have been configured - skip key clearing

wpa_driver_madwifi_set_drop_unencrypted: enabled=1

State: SCANNING -> ASSOCIATING

wpa_driver_wext_set_operstate: operstate 0->0 (DORMANT)

WEXT: Operstate: linkmode=-1, operstate=5

wpa_driver_madwifi_associate

Setting authentication timeout: 60 sec 0 usec

EAPOL: External notification - EAP success=0

EAPOL: External notification - EAP fail=0

EAPOL: External notification - portControl=Auto

RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])

Wireless event: cmd=0x8b1a len=17

*This is where I hit ctrl-c*

CTRL-EVENT-TERMINATING - signal 2 received

Removing interface ath0

State: ASSOCIATING -> DISCONNECTED

wpa_driver_wext_set_operstate: operstate 0->0 (DORMANT)

WEXT: Operstate: linkmode=-1, operstate=5

No keys have been configured - skip key clearing

EAPOL: External notification - portEnabled=0

EAPOL: External notification - portValid=0

wpa_driver_madwifi_set_drop_unencrypted: enabled=0

wpa_driver_madwifi_set_countermeasures: enabled=0

No keys have been configured - skip key clearing

Removed BSSID 00:00:00:00:00:00 from blacklist (clear)

Removed BSSID 00:11:50:d8:3e:ae from blacklist (clear)

Cancelling scan request

Cancelling authentication timeout

WEXT: Operstate: linkmode=0, operstate=6
```

I can't figure out why it blacklisted my router. Any ideas? Thanks again.

----------

## infernus

One more thing.. I'm not sure if I already mentioned the fact that it still appears as if it's connected, but after a while it just doesn't connect to anything anymore even though I still have an IP and it still appears to be up.. I wonder what this 00:00:00... is in there for? Right here:

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

Setting scan request: 0 sec 100000 usec

Added BSSID 00:11:50:d8:3e:ae into blacklist
```

I'll try and post some dmesg output if I can find any.... Thanks again.......

----------

## infernus

Wow, after many hours of researching on google and various sites I believe I have found the solution. Apparently, there is some sort of bug(?) in the madwifi drivers that prevents ap_scan=2 from working properly with wpa_supplicant. I changed it to ap_scan=1 and so far so good... I'll leave it on overnight and try to check my email in the morning. Cross your fingers  :Smile: 

----------

## infernus

That was definitely the problem. To anyone with wpa_supplicant and madwifi:

DO NOT USE ap_scan=2 in your wpa_supplicant.conf. Use ap_scan=1 instead.

ap_scan=2 will cause all sorts of connection issues. Unless you like reconnecting every couple minutes, use ap_scan=1.

Here is my wpa_supplicant.conf:

```
# The below line not be changed otherwise we refuse to work

ctrl_interface=/var/run/wpa_supplicant

# Ensure that only root can read the WPA configuration

ctrl_interface_group=0

# Let wpa_supplicant take care of scanning and AP selection

ap_scan=1

# Other shit

eapol_version=1

fast_reauth=1

############################

#         Networks         #

############################

# OTIS!

network={

        ssid="Otis Dick"

        proto=WPA

        key_mgmt=WPA-PSK

        pairwise=CCMP TKIP

        group=CCMP TKIP WEP104 WEP40

        psk=*snip*

        priority=5

}
```

wpa_supplicant -i ath0 -D madwifi -c /etc/wpa_supplicant/wpa_supplicant.conf   works just fine for me now. Hope that might help anyone else with the problem..

----------

