Monday, December 22, 2008

Getting WPA-PSK working on PS3 - YellowDog 6.1

I recently got YDL 6.1 going and was struggling with getting WPA encryption working when connecting to my WiFi router.

I found that it worked for me when I ran the wpa_supplicant command as follows, and left it running:
[root@ps3ydl devices]# wpa_supplicant -dd -Dwext -iwlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf &

Then when I did a restart of networking with "service network restart", now everything stayed connected. So I found that the best way for me to get my wifi connecting correctly at boot time, was by modifying the startup script for the wpa_supplicant service.

When using "ps" to list processes with "wpa" as part of their name, I saw:
[root@ps3ydl devices]# ps -ef |grep wpa
root 16427 1 0 00:33 ? 00:00:00 wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -B -u -f /var/log/wpa_supplicant.log
root
17223 29728 0 00:35 pts/1 00:00:00 wpa_supplicant -dd -Dwext -iwlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf

That first one (process ID 16427 above) was started by the /etc/init.d/wpa_supplicant script (this is effectively the same as running: service wpa_supplicant restart )

While the second process (17223) is clearly the one I executed myself and left running.

But the moment I reboot my machine, I obviously only have a process like that first one (i.e. 16427) and the wireless LAN connection keeps failing to connect properly.

So I modified the "daemon" line in the "start()" section of my /etc/init.d/wpa_supplicant file so that it creates a process with options like the one I ran manually.
This is what the "daemon" line in the "start()" section was BEFORE I changed it:
daemon $prog -c $conf $INTERFACES $DRIVERS -B $OTHER_ARGS

This is what it looks like now:
daemon $prog -Dwext -iwlan0 -c $conf $INTERFACES $DRIVERS -B $OTHER_ARGS

And now when I list the processes I get:
[root@ps3ydl devices]# ps -ef |grep wpa
root 20247 1 0 00:42 ? 00:00:00 wpa_supplicant -Dwext -iwlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -B -u -f /var/log/wpa_supplicant.log

== I also had to set the wpa_supplicant service to start at boot time in the two primary runlevels (3 for normal multi-user mode, without graphics; and 5 for full graphical multi-user mode - this is the init default mode):
-- 1. Created the startup link in runlevel 3 startup rc folder - I chose to start it at number 60 because if I started it too early, it didn't seem to work (the default starting number for networking is 10 - but I changed that to start later too):
[root@ps3ydl ~]# cd /etc/rc3.d/
[root@ps3ydl rc3.d]# ln -s ../init.d/wpa_supplicant S60wpa_supplicant
[root@ps3ydl rc3.d]# ls -l S60wpa_supplicant
lrwxrwxrwx 1 root root 24 Dec 21 16:39 S60wpa_supplicant -> ../init.d/wpa_supplicant
[root@ps3ydl rc3.d]#

-- 2. I moved the startup script for Networking, from starting at number 10, to rather starting later, in this case at number 99:
2008-12-31 Edit: Initially I had set this to start at number 61, i.e. as S61network, but I do get my wireless / wifi networking to start up more reliably if I have it set to start even later during the boot sequence, i.e. rather as S99network
[root@ps3ydl rc3.d]# ls -l S10network
lrwxrwxrwx 1 root root 17 Dec 21 14:00 S10network -> ../init.d/network
[root@ps3ydl rc3.d]# mv S10network S99network
[root@ps3ydl rc3.d]# ls -l S99network
lrwxrwxrwx 1 root root 17 Dec 21 14:00 S99network -> ../init.d/network
[root@ps3ydl rc3.d]#

-- 3. Similarly, for runlevel 5, I created a startup link to get wpa_supplicant started:
[root@ps3ydl rc3.d]# cd ../rc5.d/
[root@ps3ydl rc5.d]# ln -s ../init.d/wpa_supplicant S60wpa_supplicant
[root@ps3ydl rc5.d]# ls -l S60wpa_supplicant
lrwxrwxrwx 1 root root 24 Dec 21 16:40 S60wpa_supplicant -> ../init.d/wpa_supplicant
[root@ps3ydl rc5.d]#

-- 4. And moved the networking to start after the wpa_supplicant service:
[root@ps3ydl rc5.d]# ls -l S10network
lrwxrwxrwx 1 root root 17 Dec 21 14:00 S10network -> ../init.d/network
[root@ps3ydl rc5.d]# mv S10network S99network
[root@ps3ydl rc5.d]# ls -l S99network
lrwxrwxrwx 1 root root 17 Dec 21 14:00 S99network -> ../init.d/network
[root@ps3ydl rc5.d]#

== This is my wpa_supplicant.conf file ("wifi pre shared key" is obviously not my real WPA key):
[root@ps3ydl ~]# cat /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel
network={
ssid="BeBox"
scan_ssid=1
key_mgmt=WPA-PSK
#proto=WPA2
#pairwise=TKIP
#group=TKIP
psk="wifi pre shared key"
}

[root@ps3ydl ~]#

== In my ifcfg-eth0 I told the system to not start up the eth0 (ethernet LAN port) at boot time, coz without a cable plugged in it wastes time waiting to receive an IP address to be received, by setting this value / option: ONBOOT=no

== My ifcfg-wlan0 looks like this:
[root@ps3ydl ~]# cat /etc/sysconfig/networking/devices/ifcfg-wlan0
DEVICE=wlan0
BOOTPROTO=dhcp
ESSID=BeBox
HWADDR=00:19:C5:A1:B2:C3
IPADDR=
IPV6ADDR=
IPV6PREFIX=
IPV6_AUTOCONF=yes
ONBOOT=yes
DHCP_HOSTNAME=ps3ydl
DOMAIN=
NETMASK=
TYPE=Wireless
USERCTL=no
IPV6INIT=no
PEERDNS=yes
CHANNEL=1
#MODE=Master
MODE=Auto
RATE=Auto

[root@ps3ydl ~]#

== My keys-wlan0 has the same network password. It doesn't look like i need that IWPRIV line, so that is why it is commented out (there are no spaces in my actual pre shared key value!):
[root@ps3ydl ~]# cat /etc/sysconfig/networking/devices/keys-wlan0
KEY=s:wifi pre shared key
#IWPRIV="set_alg 2"
[root@ps3ydl ~]#

== now when I restart the wpa_supplicant service I see this:
[root@ps3ydl ~]# service wpa_supplicant restart
Stopping wpa_supplicant: [ OK ]
Starting wpa_supplicant: /etc/wpa_supplicant/wpa_supplicant[ OK ]

[root@ps3ydl ~]#

== and then when I restart networking I see this at the command line - not sure why I see all those lines of error messages.. but at least I now get an "OK" and no longer get a "FAILED" for the "Determining IP info..." line:
[root@ps3ydl ~]# service network restart
Shutting down interface wlan0: [ OK ]
Shutting down loopback interface: [
OK ]
Bringing up loopback interface: [
OK ]
Bringing up interface wlan0: Error for wireless request "Set Mode" (8B06) :
SET failed on device wlan0 ; Operation not supported.
Error for wireless request "Set Frequency" (8B04) :
SET failed on device wlan0 ; Operation not supported.
Error for wireless request "Set Bit Rate" (8B20) :
SET failed on device wlan0 ; Operation not supported.


Determining IP information for wlan0... done.
[
OK ]

== While making the changes above, I was monitoring my system messages file in a different terminal window using: tail -f /var/log/messages

== These are some of the interesting lines of log messages I saw during the execution of "service wpa_supplicant restart":
..
Dec 22 01:14:55 ps3ydl avahi-daemon[4085]: Interface wlan0.IPv4 no longer relevant for mDNS.
..
Dec 22 01:14:55 ps3ydl avahi-daemon[4085]: Withdrawing address record for 192.168.1.69 on wlan0.
Dec 22 01:14:56 ps3ydl avahi-daemon[4085]: New relevant interface wlan0.IPv4 for mDNS.
..
Dec 22 01:14:56 ps3ydl avahi-daemon[4085]: Registering new address record for 192.168.1.69 on wlan0.
Dec 22 01:14:57 ps3ydl kernel: gelic_eurus_sync_cmd_worker: cmd issue failed
..
Dec 22 01:14:58 ps3ydl kernel: gelic_eurus_sync_cmd_worker: cmd issue failed
Dec 22 01:14:58 ps3ydl kernel: gelic_eurus_sync_cmd_worker: cmd issue failed
Dec 22 01:14:59 ps3ydl kernel: gelic_wl_associate_bss: connected


== before doing the network restart, i see the network is down:
[root@ps3ydl ~]# ping google.com
connect: Network is unreachable
[root@ps3ydl ~]#

== And then when doing a network restart with "service network restart" I saw the following interesting system messages:
..
Dec 22 01:25:19 ps3ydl avahi-daemon[4085]: Withdrawing address record for 192.168.1.69 on wlan0.
..
Dec 22 01:25:19 ps3ydl avahi-daemon[4085]: iface.c: interface_mdns_mcast_join() called but no local address available.
Dec 22 01:25:19 ps3ydl avahi-daemon[4085]: Interface wlan0.IPv4 no longer relevant for mDNS.
..
Dec 22 01:25:19 ps3ydl avahi-daemon[4085]: iface.c: interface_mdns_mcast_join() called but no local address available.
..
Dec 22 01:25:24 ps3ydl kernel: gelic_wl_assoc_worker: no bss matched. association failed
Dec 22 01:25:24 ps3ydl kernel: gelic_wl_assoc_worker: no bss matched. association failed
Dec 22 01:25:24 ps3ydl kernel: gelic_wl_associate_bss: connected
Dec 22 01:25:25 ps3ydl dhclient: DHCPREQUEST on wlan0 to 255.255.255.255 port 67
Dec 22 01:25:25 ps3ydl dhclient: DHCPACK from 192.168.1.254
Dec 22 01:25:25 ps3ydl avahi-daemon[4085]: New relevant interface wlan0.IPv4 for mDNS.
..
Dec 22 01:25:25 ps3ydl avahi-daemon[4085]: Registering new address record for 192.168.1.69 on wlan0.
Dec 22 01:25:25 ps3ydl NET[427]: /sbin/dhclient-script : updated /etc/resolv.conf
Dec 22 01:25:25 ps3ydl
dhclient: bound to 192.168.1.69 -- renewal in 39187 seconds.

== and finally when I ping google I get a response.. confirming my wifi network is up and working:
[root@ps3ydl ~]# ping google.com
PING google.com (74.125.45.100) 56(84) bytes of data.
64 bytes from yx-in-f100.google.com (74.125.45.100): icmp_seq=1 ttl=243 time=113 ms


P.S. I originally started adding this as a comment to the following blog post, but decided to publish it here too, with additional details. This one may be helpful in providing you with further background or suggestions if you are having troubles like I was having: http://dachaac.blogspot.com/2007/08/guide-to-get-wpa-psk-working-on-ps3-ydl.html