Sunday, February 05, 2006

FreeBSD Wireless Changes

At my desk I connect to the rest of my wireless network with a Netgear WGE111 54 Mbps Wireless Game Adapter (don't ask). I usually don't use the SMC EZ Connect 802.11b Wireless PCMCIA card, model SMC 2632W v.1 I have nearby. While watching "the big game" I decided to check email, so I tried using this wireless card with my FreeBSD 6.0 laptop. I saw this error:

orr:/home/richard$ sudo ifconfig wi0 inet 192.168.2.5 netmask 255.255.255.0 ssid
shaolin wepkey 0xmykey wepmode on
ifconfig: SIOCS80211: Invalid argument

What the heck is this? I took a look at dmesg output and saw the following:

ieee80211_load_module: load the wlan_wep module by hand for now.

This is a change reported in the release notes. Luckily wlan_wep is available as a kernel module, so I was able to load it easily.

orr:/home/richard$ kldstat
Id Refs Address Size Name
1 10 0xc0400000 63072c kernel
2 2 0xc0a31000 74b0 snd_csa.ko
3 3 0xc0a39000 1d408 sound.ko
4 1 0xc0a57000 c3a4 r128.ko
5 2 0xc0a64000 eeec drm.ko
6 16 0xc0a73000 568dc acpi.ko

orr:/home/richard$ sudo kldload wlan_wep

orr:/home/richard$ kldstat
Id Refs Address Size Name
1 12 0xc0400000 63072c kernel
2 2 0xc0a31000 74b0 snd_csa.ko
3 3 0xc0a39000 1d408 sound.ko
4 1 0xc0a57000 c3a4 r128.ko
5 2 0xc0a64000 eeec drm.ko
6 16 0xc0a73000 568dc acpi.ko
7 1 0xc1fa8000 3000 wlan_wep.ko

There it is. Now let's try that configuration again.

orr:/home/richard$ sudo ifconfig wi0 inet 192.168.2.5 netmask 255.255.255.0 ssid
shaolin wepkey 0xmykey wepmode on

No errors -- so far so good. Let's see ifconfig output.

orr:/home/richard$ ifconfig wi0
wi0: flags=8843 mtu 1500
inet 192.168.2.5 netmask 0xffffff00 broadcast 192.168.2.255
inet6 fe80::204:e2ff:fe29:3bba%wi0 prefixlen 64 scopeid 0x4
ether 00:04:e2:29:3b:ba
media: IEEE 802.11 Wireless Ethernet autoselect (DS/11Mbps)
status: associated
ssid shaolin channel 6 bssid 00:13:10:65:2f:ad
stationname "FreeBSD WaveLAN/IEEE node"
authmode OPEN privacy MIXED deftxkey UNDEF wepkey 1:104-bit txpowmax 100

Nothing too odd here. The deftxkey UNDEF looks new, but that shouldn't matter? Let me ping a host.

orr:/home/richard$ ping -c 1 www.google.com

Nothing. I sniff on the wi0 interface and see my host ARP for the gateway, but that's it. (By the way, I added a default route.)

I poke around a bit and decide to see if I can get any useful information about this problem from the kernel.

orr:/home/richard$ sysctl -a | grep wlan
net.wlan.debug: 0
net.wlan.0.%parent: wi0
net.wlan.0.debug: 0
net.wlan.0.inact_run: 300
net.wlan.0.inact_probe: 30
net.wlan.0.inact_auth: 180
net.wlan.0.inact_init: 30
net.wlan.0.driver_caps: 67329

I see the wlan man page mentions setting a mask to enable wlan debugging, so I try doing that with all 1s. This is just a wild guess, but it shouldn't break anything.

orr:/home/richard$ sudo sysctl net.wlan.0.debug=0x11111111
net.wlan.0.debug: 0 -> 286331153

Now I start to see messages like the following:

wi0: [ff:ff:ff:ff:ff:ff] no default transmit key (ieee80211_encap) deftxkey 65535
wi0: [33:33:ff:29:3b:ba] no default transmit key (ieee80211_encap) deftxkey 65535

The deftxkey UNDEF is important after all. It isn't mentioned in the ifconfig man page. I initially decide to try setting it to my WEP key, but that doesn't work. Next I try setting it to 1.

orr:/home/richard$ sudo ifconfig wi0 deftxkey 1
orr:/home/richard$ ifconfig wi0
wi0: flags=8847 mtu 1500
inet 192.168.2.5 netmask 0xffffff00 broadcast 192.168.2.255
inet6 fe80::204:e2ff:fe29:3bba%wi0 prefixlen 64 scopeid 0x4
ether 00:04:e2:29:3b:ba
media: IEEE 802.11 Wireless Ethernet autoselect (DS/2Mbps)
status: associated
ssid shaolin channel 6 bssid 00:13:10:65:2f:ad
stationname "FreeBSD WaveLAN/IEEE node"
authmode OPEN privacy MIXED deftxkey 1 wepkey 1:104-bit txpowmax 100
bintval 100

Let's see what new messages I get.

wi0: ieee80211_timeout_stations: station scangen 1
wi0: ieee80211_timeout_stations: station scangen 2
wi0: ieee80211_ref_node (ieee80211_send_mgmt:1063) 0xc1b66000<00:13:10:65:2f:ad> refcnt 3
wi0: _ieee80211_crypto_delkey: NONE keyix 65535 flags 0x3 rsc 0 tsc 0 len 0
wi0: link state changed to DOWN
wi0: ieee80211_node_table_reset scan table
wi0: ieee80211_free_allnodes_locked: free all nodes in scan table
wi0: node_reclaim: remove 0xc1b66000<00:13:10:65:2f:ad> from scan table, refcnt 1
wi0: ieee80211_node_table_reset station table
wi0: ieee80211_free_allnodes_locked: free all nodes in station table
wi0: ieee80211_setup_node 0xc1b60c00<00:04:e2:29:3b:ba> in scan table
wi0: _ieee80211_free_node 0xc1b66000<00:13:10:65:2f:ad> in table
wi0: _ieee80211_crypto_delkey: NONE keyix 65535 flags 0x3 rsc 0 tsc 0 len 0
wi0: ieee80211_newstate: invalid transition

That did something. Can I ping a host?

orr:/home/richard$ ping -c 1 192.168.2.1
PING 192.168.2.1 (192.168.2.1): 56 data bytes
64 bytes from 192.168.2.1: icmp_seq=0 ttl=64 time=8.093 ms

--- 192.168.2.1 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev = 8.093/8.093/8.093/0.000 ms

Alright, we're working. In fact, I'm posting using the card now. I've added 'kldload wlan_wep' along with 'deftxkey 1' in ifconfig to the script I use to manually enable wi0 on FreeBSD.

I have a new 802.11b/g card en route, so when I get that and use it successfully I'll report it here.

6 comments:

Anonymous said...

I think you wanted 0xffffffff for "all 1s"

Richard Bejtlich said...

orr:/home/richard$ sudo sysctl net.wlan.0.debug=0xffffffff
net.wlan.0.debug: 0 -> 2147483647

Anonymous said...

Hi Richard,

Have you attempted to get WPA/WPA2 working with FreeBSD?

Thanks,
- Ryan

Anonymous said...

Hi Richard,
I am a FreeBSD newbie with a bit of Linux experence. I was getting the same error you were and your post helped me get my laptop up and running. Thank you!

Mike

Anonymous said...

Yeah, same here, that kldload trick worked a treat! i can ping locally but for some reason can't get google, DNS settings problems! how do I change my DNS?

Anonymous said...

stuff it, i used DHCP and it all works now! Cheers

I CAN PING GOOGLE YAY