# DHCPCD timeout using madwifi & wpa_supplicant

## bryanb

Hi,

I am using a D-Link DWL-G650 to connect my Tecra 8100 to a safecom SWBR-5400 wireless router.  Everything worked fine with no encryption using the madwifi driver (just to test it worked!), but now that I have merged and setup wpa_supplicant the DHCPCD client hits the timeout (1 minute A.T.M.) 'waiting for a valid DHCP response from the server'

Any ideas?  Config file snippets as follows...

/etc/conf.d/net

```

#-----------------------------------------------------------------------------

# WIRELESS (802.11 support)

# Wireless can be provided by iwconfig or wpa_supplicant

...

...

# wpa_supplicant

# emerge net-wireless/wpa-supplicant

# Wireless options are held in /etc/wpa_supplicant.conf

# Consult the sample file /etc/wpa_supplicant.conf.example for instructions

# To choose wpa_supplicant over iwconfig

modules=( "wpa_supplicant" )

# To configure wpa_supplicant

wpa_supplicant_ath0="-dddd -Dmadwifi" # For Atheros based cards

# Consult wpa_supplicant for more drivers

# By default we give wpa_suppliant 60 seconds to associate and authenticate

wpa_timeout_ath0=60

```

/etc/conf.d/wireless

```

# You can also override the interface settings found in /etc/conf.d/net

# per ESSID - which is very handy if you use different networks a lot

config_brewery=( "dhcp" )

dhcpcd_brewery="-d -S -t 60"

```

(EDIT - I have tried with and without the dhcpcd -S and -r switches)

/etc/wpa_supplicant.conf

```

network={

        ssid="brewery"

        proto=WPA

        key_mgmt=WPA-PSK

        #psk="A3c5B10g9C6b5E5f9B"

        psk=9B6DCEB83DD838E042E0DDC61fA7A9C9574005DEB1995B7863E3CA9DF6763C1E

        pairwise=CCMP TKIP

        group=CCMP TKIP WEP104 WEP40

        priority=2

}

```

I have check the PSK and it matches on the router, and as far as I can tell wpa_supplicant is starting up fine.  The only debug info I get from DHCPCD is the mac address before it times out.

I have these merged :

*  net-wireless/madwifi-driver

      Latest version installede: 0.1_pre20050106

*  net-wireless/madwifi-tools

      Latest version installed: 0.1_pre20050106

*  net-wireless/wpa_supplicant

      Latest version installed: 0.3.3

*  sys-apps/baselayout

      Latest version installed: 1.11.8

The base layout has the patch from this bug applied...

https://bugs.gentoo.org/show_bug.cgi?id=74637

Another interesting side effect is that once this has failed my router is locked up and refuses to route for an wired machine already setup, I have to turn it off/on to get it working again!   :Rolling Eyes: 

Thanks in advance for your help.

----------

## UberLord

Try using another dhcp client - we support 3 others  :Smile: 

----------

## bryanb

Ha, typical!  I had merged udhcp last night - I thought I had tried it, but in my sleepiness I must have not   :Embarassed: 

Sending this using wireless, thanks UberLord.  One last question tho :

I have this in my /etc/conf.d/wireless (forgot to include it in my last post)

```

preferred_aps=( "brewery" )

associate_order="any"

```

I thought this would mean that the scripts would attempt to connect to 'brewery' before anything else.

However, i have connected and gained an IP address :

```

kronenbourg ~ # ifconfig ath0

ath0      Link encap:Ethernet  HWaddr 00:0F:3D:A9:A4:0C

          inet addr:192.168.2.9  Bcast:192.168.2.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:100 errors:257 dropped:0 overruns:0 frame:257

          TX packets:114 errors:42 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:199

          RX bytes:74875 (73.1 Kb)  TX bytes:12669 (12.3 Kb)

          Interrupt:11 Memory:d0e80000-d0e90000

kronenbourg ~ # iwconfig ath0

ath0      IEEE 802.11g  ESSID:"belkin54g"  Nickname:"belkin54g"

          Mode:Managed  Frequency:2.462 GHz  Access Point: 00:11:50:3D:BF:E9

          Bit Rate:36 Mb/s   Tx-Power:50 dBm   Sensitivity=0/3

          Retry:off   RTS thr:off   Fragment thr:off

          Encryption key:off

          Power Management:off

          Link Quality=2/94  Signal level=-93 dBm  Noise level=-95 dBm

          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0

          Tx excessive retries:42  Invalid misc:42   Missed beacon:9

```

This is telling me I have connected to my neighbours (presumably unsecure) access point, isn't it?  What should I do to force connection to 'brewery' before any other available APs?

Cheers, Bry.

Better see if I can find out whose got the unsecure AP too (maybe)

 :Twisted Evil: 

----------

## bryanb

Right, it appears the reason that udhcpc was working was because it was attaching to an alternative AP.  I've set it to only use the preferred (my) AP and now udhcp fails with 'No lease, failing'.

Time for a web-browse methinks...

----------

## UberLord

That sounds like it's either refusing a connect to your AP or there's a problem with your DHCP server.

Try setting RC_VERBOSE=yes in /etc/conf.d/rc and seeing what happens - you get a more detailed output when starting net.ethx scripts.

----------

## bryanb

Bah!  Have managed to break my installation after updating to kernel 2.6.10 (really should try fixing one thing at a time)  The wireless networking will have to go hiatus f.t.m.   :Crying or Very sad: 

No doubt I'll be hassling you over this in about a weeks time...thanks for your time.

----------

## UberLord

Please note that wpa_supplicant uses it's own configuration - /etc/wpa_supplicant.conf

It does not use anything from /etc/conf.d/wireless

----------

## bryanb

Hmm, I knew that wpa_suplicant had its own configuration file - I was assuming that both the conf.d/wireless and wpa_supplicant.conf would need to be configure for my wirelss to work correctly, is this not the case?  Do I only need wpa_supplicant.conf?

----------

## UberLord

 *bryanb wrote:*   

> Do I only need wpa_supplicant.conf?

 

Yes

You can configure network settings per ESSID though

```
config_WPA_AccessPoint=( "192.168.0.2/24" )
```

for example - but blacklisting, preferred_aps, etc have zero affect

----------

## mOjO_420

same exact issue here...

btw to bryanb,

(theres a patch for 2.6.10-r4 on the forums somewhere to get madwifi drivers working again, i didnt bookmark it though) 

although i get kernel panics every now and then so i'm probably going to go back to latest 2.6.9 until a new madwifi ver. comes out.

but about this dhcp thing... 

starting wpa_supplicant init script works fine but i then have to type 'dhcpcd ath0' and it pulls an IP fine.  i have the exact same card DWL-G650 (but a DWL-2100AP) and the drivers get loaded by hotplug just fine.  i've got latest masked baselayout version.

i'll try setting debug option in /etc/rc and see what i get.

----------

## mOjO_420

heres attempt to start with debug options set in /etc/conf.d/rc and also wpa_supplicant is getting run in debug mode.

```
mingus ~ # /etc/init.d/net.ath0 restart

 * Starting ath0

 *    Loading networking modules for ath0

 *       modules: wpa_supplicant essidnet iptunnel ifconfig dhcpcd apipa

 *          wpa_supplicant provides wireless

 *          ifconfig provides interface

 *          dhcpcd provides dhcp

 *    Running preup function

 *    Starting wpa_supplicant on ath0 ...

Initializing interface 'ath0' conf '/etc/wpa_supplicant.conf' driver 'madwifi'

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=100 (from group name 'users')

eapol_version=2

ap_scan=1

fast_reauth=1

Line: 68 - start of a new network block

ssid - hexdump_ascii(len=7):

     6d 6f 6a 6f 6e 65 74                              mojonet

PSK (ASCII passphrase) - hexdump_ascii(len=8): [REMOVED]

priority=5 (0x5)

PSK (from passphrase) - hexdump(len=32): [REMOVED]

Priority group 5

   id=0 ssid='mojonet'

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

Own MAC address: 00:11:95:49:b1:a6

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

Daemonize..

 *       Waiting for association

 *       timed out

 *       [ !! ]

mingus ~ #

```

/var/log/messages only shows "rc-scripts: timed out"

interesting thing is that it IS associating and authenticating fine, because i can set the timeout really high and switch to a different VC and run wpa_cli and do a status and it said this (this is while the init script is hanging on "waiting for association" forever.)

```
mingus ~ # wpa_cli

wpa_cli v0.3.2 - Copyright (c) 2004, Jouni Malinen <jkmaline@cc.hut.fi>

This program is free software. You can distribute it and/or modify it

under the terms of the GNU General Public License version 2.

Alternatively, this software may be distributed under the terms of the

BSD license. See README and COPYING for more details.

Selected interface 'ath0'

Interactive mode

> status

bssid=00:0f:3d:ac:3b:f0

ssid=mojonet

pairwise_cipher=CCMP

group_cipher=TKIP

key_mgmt=WPA-PSK

wpa_state=COMPLETED

Supplicant PAE state=AUTHENTICATED

suppPortStatus=Authorized

EAP state=SUCCESS

>

mingus ~ #

```

also if i switch to another console and run 'dhcpcd ath0'  it will pull an IP.

or i can kill the init script with CTRL-C and it leaves the ath0 interface up so i can run 'dhcpcd ath0' and it works fine.  meaning that there is no problem with wpa_supplicant.  it seems the init script just isnt quite figuring out that wpa_supplicant is associated so maybe its not moving on to the next step of running dhcp

any suggestions?

i'm going to emerge sync and look for newer baselayout and wpa_supplicant now.. just realized that its been a few days.

----------

## mOjO_420

there was a newer ver. of wpa_supplicant so i emerged it.  didnt fix the problem but now i get a whole bunch of additional errors when i try to start net.ath0

```
*     Waiting for association

Failed to connect to wpa_supplicant - wpa_ctrl_open: No such file or directory

(then it has like 50 more of these and then)

*     timed out                       [!!]

```

i cant find any wpa_ctrl_open file anywhere... and i grepped /etc/init.d/* for that string and got no hits either.

----------

## mOjO_420

OK.. thanks to some other posts pointing me towards what files to look at i got it resolved.

seems to be that your not getting the expected results from your wpa_cli results in wpa_supplicant_associated() function in /lib/rcscripts/net.modules.d/wpa_supplicant

i added the line:

```
wpa_cli -i${1} status | awk -F='/^key_mgmt|^wpa_state|^decision/ { print $2 }' > /root/wpa_error
```

to that function and got this in /root/wpa_error:

```
# cat /root/wpa_error

WPA-PSK

COMPLETED
```

so i modified it to be the following and it worked great.

```

wpa_supplicant_associated() {

        local -a status=( $( wpa_cli -i${1} status | awk -F='/^key_mgmt|^wpa_state|^decision/ { print $2 }' ) )

        if [[ ${status[0]} == NONE ]]; then

                [[ ${status[1]} == ASSOCIATED ]]

        else

#               [[ ${status[2]} == COND_SUCC ]]

                [[ ${status[1]} == COMPLETED ]]

        fi

        return $?

}

```

i'm sure you'd rather handle that more elegantly so please post what i should alter it to.

thanks.

----------

## bryanb

'friad that doesn't seem to be my problem.  Here's the output...

```

kronenbourg net.modules.d # /etc/init.d/net.ath0 restart

 * Starting ath0

 *    Loading networking modules for ath0

 *       modules: wpa_supplicant essidnet iptunnel ifconfig dhcpcd apipa

 *          wpa_supplicant provides wireless

 *          ifconfig provides interface

 *          dhcpcd provides dhcp

 *    Starting wpa_supplicant on ath0 ...

Initializing interface 'ath0' conf '/etc/wpa_supplicant.conf' driver 'madwifi'

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

Line: 242 - start of a new network block

ssid - hexdump_ascii(len=7):

     62 72 65 77 65 72 79                              brewery

proto: 0x1

key_mgmt: 0x2

PSK - hexdump(len=32): [REMOVED]

pairwise: 0x18

group: 0x1e

priority=2 (0x2)

Priority group 2

   id=0 ssid='brewery'

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

Own MAC address: 00:0f:3d:a9:a4:0c

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

Daemonize..

 *       Waiting for association                                                                    [ ok ]

 *       ath0 connected to "brewery" at 00:50:18:32:98:10

 *       using WPA-PSK/TKIP

 *    Configuring ath0 for "brewery" ...                                                            [ ok ]

 *    Bringing up ath0

 *       Configuration not set for ath0 - assuming dhcp

 *       dhcp

 *          Running dhcpcd ...                                                                      [ !! ]

```

It is associating okay but timing out on the  DHCP.  I'm going to try static addresses to see if that works, it'll either show the problem is at DHCP level and get my wireless working, or show that it is not DHCP at all.

----------

## bryanb

Right have finally made some time for this.  I've tried the following combinations and have come to the conclusion that wpa_supplicant is not playing ball in some way :

No encryption + DHCP    => works

No encryption + Static IP => works

128 WEP + DHC              => works

128 WEP + Static IP        => works

WPA + DHCP                  => not work   :Crying or Very sad: 

WPA + Static IP               => not work   :Crying or Very sad: 

Either wpa_supplicant isn't working with madwif or it doesn't like my AP (or vice versa).

Any ideas?  I'll post on the wpa_supplicant forum also.

Thanks for the help so far!

----------

## UberLord

You guys may find the patch on the below bug of interest

https://bugs.gentoo.org/show_bug.cgi?id=78367

----------

## bryanb

Hmm, my router went pop recently and I've replaced it with a D-Link DI-624+.  WPA is working fine with thihs combination!  Thanks for your input guys.

----------

## kenyon

I'm having the exact same problem as mOjO_420 above in post https://forums.gentoo.org/viewtopic-p-1982718.html#1982718 except I'm using the latest stable baselayout, version 1.11.14-r7.

If I use the ctrl-c trick like mojo explained, then manually run dhcpcd, I can get an IP and the interface works fine.  Here's the output of wpa_cli status after that:

```
# wpa_cli status

Selected interface 'ath0'

bssid=00:0f:b5:98:7d:11

ssid=radium

pairwise_cipher=TKIP

group_cipher=TKIP

key_mgmt=WPA-PSK

wpa_state=COMPLETED

ip_address=192.168.0.103
```

----------

## UberLord

 *kenyon wrote:*   

> except I'm using the latest stable baselayout, version 1.11.14-r7

 

Should be fixed in 1.11.14-r8

----------

## windy

There are a couple of know bugs/fixes for this in madwifi and wpa_supplicant.

http://hostap.epitest.fi/bugz/show_bug.cgi?id=63

http://article.gmane.org/gmane.linux...ifi.devel/1275

For whatever reason madwifi is not decoding the encrypted dchp reply.

----------

