Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Slackware This Forum is for the discussion of Slackware Linux.


  Search this Thread
Old 08-23-2008, 01:37 AM   #1
LQ Newbie
Registered: Aug 2008
Posts: 1

Rep: Reputation: 0
How I finally got wireless/wpa_supplement to work consistently in Slackware 12.1

If you are having issues with wpa_supplicant not connecting consistently on boot, this post may help you. I spent quite a bit of time digging through the rc.scripts and in debug mode in wpa_supplicant to catch all of these, but here is what I have come up with.

One problem I discovered that will be an issue that is common to all wireless configurations is related to DHCP configured interfaces in rc.inet1.conf.

In short, with a wireless connection you must specify a DHCP_TIMEOUT (ie DHCP_TIMEOUT[4]=30) for your wireless interface.

If you do not, the rc.inet1 script has some nice code which will down your interface after your rc.wireless/wpa_supplicant has indicated that it is associated and connected. See the following code snippet from rc.inet1:

echo "Polling for DHCP server on interface ${1}:"
# If you set a timeout, you get one, even if the kernel doesn't think that
# your device is connected, in case /sys isn't right (which it usually isn't
# except right after the device is loaded, when it usually is):
if [ "${DHCP_TIMEOUT[$i]}" = "" ]; then
ifconfig ${1} up && sleep 1
CONNSTATUS="$(cat /sys/class/net/${1}/carrier 2> /dev/null)"
ifconfig ${1} down
if [ "$CONNSTATUS" = "0" ]; then
# The kernel has just told us the cable isn't even plugged in, but we will
# give any DHCP server a short chance to reply anyway:
echo "No carrier detected on ${1}. Reducing DHCP timeout to 10 seconds."
# 30 seconds should be a reasonable default DHCP timeout. 60 was too much. :-)
echo "/etc/rc.d/rc.inet1: /sbin/dhcpcd -d -t ${DHCP_TIMEOUT[$i]:-30} ${DHCP_OPTIONS} ${1}" | $LOGGER
/sbin/dhcpcd -d -t ${DHCP_TIMEOUT[$i]:-30} ${DHCP_OPTIONS} ${1}

This code executes after it calls rc.wireless, so without a specified timeout all the work done by rc.wireless to ensure that the connection is associated/complete with your access point will be lost by the "ifconfig ${1} down". This means that after rc.wireless has configured the connection and connected to your access point, rc.inet1 drops that connection and then calls dhcpcd. This means that the connection has to be re-established (which it sometimes does) before dhcpcd times out.


The second issue I found appears to be related to wpa_supplicant. In the rc.wireless script the code loops for XX seconds to wait for wpa_cli status to indicate "wpa_state=COMPLETED". The problem I found in my setup, and I don't know if this is a common problem, is that this state may happen several times and be dropped before a good connection is actually established. The difference between a good and bad connection can be determined by checking an additional variable in the status, but was not checked by rc.wireless. In truth I don't see this as a bug in rc.wireless, but I made some small changes to the script to catch these bogus "wpa_state=COMPLETED" messages. In watching my wpa_cli in debug, I noticed that the associated bssid was 00:00:00:00:00:00 when it was a completed connection that would soon drop. I simply added an additional check in rc.wireless to test the bssid, as well as the wpa_state before deciding I had a good connection. The code snipet with my changes is as follows:

# Buy wpa_supplicant some time to authenticate before bringing the
# interface back up... but we don't wait forever:
# You can increase this value in rc.inet1.conf (WLAN_WPAWAIT) or rc.wireless.conf (WPAWAIT)
# if your card takes longer to associate:
while [ $wi -lt $WPAWAIT ]; do
wi=$(($wi+1)); sleep 1
if (grep -q "^ctrl_interface=" ${WPACONF}); then
if (LC_ALL=C ${SUPPATH}/wpa_cli -i$INTERFACE status|grep -q "^wpa_state=COMPLETED"); then
if (LC_ALL=C ${SUPPATH}/wpa_cli -i$INTERFACE status|grep -q "^bssid=00:00:00:00:00:00"); then
echo "Invalid wpa_state=COMPLETED with bssid=00:00:00:00:00:00";
if (LC_ALL=C ${IWCOMMAND}|grep -Eq "Encryption key:....-"); then break; fi

Sorry this is not in the form of a patch, but a search for wpa_state=COMPLETED in rc.wireless should find you the right place to cut this code change into your script. Basically, this prevents DHCP from being launched to early and timing out.

Just for reference, I am using a D-Link DWL-G520 ver: B3 with madwifi drivers and wpa_supplicant in this configuration. My hub is not broadcasting its ssid, which also may be part of the problem. I am not sure if the same bssid issue occurs with other cards and configurations, but I saw similar wpa_cli logs showing the same bad connects I was seeing in some of threads I read while researching this problem.

I hope this post is helpful in getting some peoples connections working. Good luck.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
getting wireless lan to work on Slackware 11.0 adityavpratap Slackware 10 07-29-2007 11:06 AM
Making Broadcom wireless adapters work under Slackware. pappy_mcfae Slackware 0 05-07-2007 01:24 AM
Getting athero wireless card on SLED 10 to work consistently w/linksys router rcoury Linux - Newbie 0 01-01-2007 08:27 AM
Wireless usb card does not work on Slackware 11 Zuicis Linux - Wireless Networking 1 11-09-2006 08:13 AM
whats the RIGHT way to work wireless in slackware ftgow Slackware 6 05-08-2005 04:41 AM > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:38 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration