eeebuntu tip: wireless with hal and NetworkManager
I've been away from Linux for quite a while, off in Mac-land, where things generally just work. I was delighted to notice, upon my return, that the community (and RedHat in particular) noticed that manually configuring your wireless interfaces is lame, and built a solution: NetworkManager.
NetworkManager is built atop hal, a daemon that interrogates hardware and makes the information available over a dbus interface. (dbus is a simple mechanism for interprocess messaging and procedure call, similar to DCOP, but more general.)
If you install Ubuntu and subsequently bring up your network using a panel applet, you're using NetworkManager -- and boy, is it nice. Unfortunately, most instructions for getting the eee's wireless working on Ubuntu revolve around the "old-world" configuration mechanism in
NetworkManager and hal are really poorly documented. (No offense to the authors intended; the tech is impressive, and I understand that sometimes precious little time is left over to write a design document.) I don't understand the system well enough to write a general tutorial, so here's a specific one: how to get NetworkManager and hal playing nice with the binary Atheros drivers on "eeebuntu" -- Ubuntu 7.10 using the ASUS-compatible 2.6.21.4 kernel I described in my last post.
The Atheros wireless drivers create two network interfaces:
hal, by default, sees the wlan0 interface as an 802.e interface, and does not see ath0 at all. What we want is for hal to ignore wlan0 and treat ath0 as an 802.11 interface. hal supports policy files (written in XML, which surprised me in a Linux tool) that rewrite its view of devices -- and that's what we'll use to fix this.
But first -- we need ath0 created automatically when wlan0 appears. A simple script suffices. I've put mine in a file called
Notice that the script takes its input, not from a command-line parameter, but from an environment variable named
Now, we convince hal to invoke our script when wlan0 appears or disappears. Create a file named
This adds our script as a "callout" for wlan0 -- hal's notion of an event handler. hal will invoke our script when wlan0 comes or goes, and set HALD_ACTION appropriately.
Restart hal (or
For NetworkManager to configure an interface, a few conditions must be met:
First things first. Modify the
Note: special thanks to "Triarm" on the eeeuser forums for pointing out this approach.
Line by line, this does the following:
To sum up, at this point we have:
Bring NetworkManager down, restart or HUP hald, and bring NetworkManager back up. (The control script for NetworkManager on Ubuntu 7.10 is at
Assuming I haven't forgotten anything, NetworkManager should now offer to configure your wireless, and the interface should show up in configurators like
If it doesn't work, try rebooting. (I know it's lame to say that, but the Atheros drivers are incredibly sensitive and can get into weird states that make your interface stop working, usually after you remove/readd them or suspend/resume. I have a magic dance that repairs the driver, but it's lengthy so I'll post it in a followup.)
NetworkManager is built atop hal, a daemon that interrogates hardware and makes the information available over a dbus interface. (dbus is a simple mechanism for interprocess messaging and procedure call, similar to DCOP, but more general.)
If you install Ubuntu and subsequently bring up your network using a panel applet, you're using NetworkManager -- and boy, is it nice. Unfortunately, most instructions for getting the eee's wireless working on Ubuntu revolve around the "old-world" configuration mechanism in
/etc/network/interfaces
. While Ubuntu has graphical configurators that generate this file, using it prevents you from applying the full power of NetworkManager. (Fun fact: NetworkManager will silently ignore any interfaces that are configured in /etc/network/interfaces
.)NetworkManager and hal are really poorly documented. (No offense to the authors intended; the tech is impressive, and I understand that sometimes precious little time is left over to write a design document.) I don't understand the system well enough to write a general tutorial, so here's a specific one: how to get NetworkManager and hal playing nice with the binary Atheros drivers on "eeebuntu" -- Ubuntu 7.10 using the ASUS-compatible 2.6.21.4 kernel I described in my last post.
Getting hal to create ath0 automatically
The Atheros wireless drivers create two network interfaces:
wlan0
by default, which seems to be good for very little, and ath0
on demand, which is what you actually use to speak to the intarweb. You have to explicitly request creation of the ath0
interface like so:wlanconfig ath0 create wlandev wlan0 wlanmode sta
hal, by default, sees the wlan0 interface as an 802.e interface, and does not see ath0 at all. What we want is for hal to ignore wlan0 and treat ath0 as an 802.11 interface. hal supports policy files (written in XML, which surprised me in a Linux tool) that rewrite its view of devices -- and that's what we'll use to fix this.
But first -- we need ath0 created automatically when wlan0 appears. A simple script suffices. I've put mine in a file called
/etc/hal/callouts/eee-wifi
for reasons that will become apparent in the next step. The script need only contain:
#!/bin/sh
case $HALD_ACTION in
add)
sleep 1 # May be unnecessary, experiment
/sbin/wlanconfig ath0 create wlandev wlan0 wlanmode sta
sleep 1
;;
remove)
/sbin/wlanconfig ath0 destroy
;;
esac
Notice that the script takes its input, not from a command-line parameter, but from an environment variable named
HALD_ACTION
. This will make sense in a minute. For now, you can test the script thusly:
# Should create ath0 if wlan0 exists and drivers are loaded
env HALD_ACTION=add /etc/hal/callouts/eee-wifi
# Should remove ath0
env HALD_ACTION=remove /etc/hal/callouts/eee-wifi
Now, we convince hal to invoke our script when wlan0 appears or disappears. Create a file named
/etc/hal/fdi/policy/10-networking-ath0.fdi
containing the following:
<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
<device>
<match key="net.interface" string="wlan0">
<append key="info.callouts.add" type="strlist">/etc/hal/callouts/eee-wifi</append>
</match>
</device>
</deviceinfo>
This adds our script as a "callout" for wlan0 -- hal's notion of an event handler. hal will invoke our script when wlan0 comes or goes, and set HALD_ACTION appropriately.
Restart hal (or
killall -HUP hald
) and try loading or unloading the Atheros drivers. ath0 should be created and destroyed automatically. (Make sure the ath0 interface is down when you do this.)Letting NetworkManager configure ath0
For NetworkManager to configure an interface, a few conditions must be met:
- hal must see the interface and recognize it correctly (e.g. seeing ath0 as a wired Ethernet connection is not good);
- The interface must not be configured in
/etc/network/interfaces
. If you currently have a stanza configuring ath0 or wlan0, remove it.
First things first. Modify the
10-networking-ath0.fdi
policy we created in the last step by adding the code marked below:
<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
<device>
<match key="net.interface" string="wlan0">
<append key="info.callouts.add" type="strlist">/etc/hal/callouts/eee-wifi</append>
<merge key="info.capabilities" type="strlist">net</merge>
<append key="info.capabilities" type="strlist">net.80211</append>
<merge key="info.category" type="string">net.80211</merge>
<merge key="net.interface" type="string">ath0</merge>
<merge key="net.80211.mac_address" type="copy_property">net.80203.mac_address</merge>
<remove key="net.80203.mac_address"></remove>
<merge key="linux.sysfs_path" type="string">/sys/class/net/ath0</merge>
</match>
</device>
</deviceinfo>
Note: special thanks to "Triarm" on the eeeuser forums for pointing out this approach.
Line by line, this does the following:
- Replaces wlan0's
info.capabilities
property with the single item "net", indicating that it's a network interface. - Appends "net.80211", indicating that it's a wireless interface.
- Changes the device's category, again to indicate that it's a wireless interface.
- Switches the entry to refer to ath0, instead of wlan0.
- Copies the 802.3 (wired Ethernet) MAC address to the 802.11 MAC address (I'm surprised that these are separate).
- Removes the old 802.3 MAC address.
- Rewrites the entry's sysfs path to point to ath0's.
To sum up, at this point we have:
- Instructed hal to invoke our callout when wlan0 is added or removed, thereby automagically creating/destroying ath0.
- Rewritten the device descriptor for wlan0 to describe ath0 (which is unfortunately not picked up automatically by hal).
- Removed wlan0/ath0 configuration from
/etc/network/interfaces
. (You remembered that, right?)
Bring NetworkManager down, restart or HUP hald, and bring NetworkManager back up. (The control script for NetworkManager on Ubuntu 7.10 is at
/etc/dbus-1/event.d/25NetworkManager
.)Assuming I haven't forgotten anything, NetworkManager should now offer to configure your wireless, and the interface should show up in configurators like
nm-applet
.If it doesn't work, try rebooting. (I know it's lame to say that, but the Atheros drivers are incredibly sensitive and can get into weird states that make your interface stop working, usually after you remove/readd them or suspend/resume. I have a magic dance that repairs the driver, but it's lengthy so I'll post it in a followup.)
19 Comments:
Great tutorial. Thanks a lot.
Note that I had to replace wlan0 by wifi0 for it work with my setup.
I had no idea hal was so easy to configure.
By Ben, at 1:15 AM
This comment has been removed by the author.
By Cliff L. Biffle, at 9:33 AM
[ reposting with an edit ]
Curious! The eeeuser post that pointed out the 'merge' policy solution was also written in terms of wifi0, but my kernel always calls the interface wlan0. I wonder if we're using slightly different modules?
By Cliff L. Biffle, at 9:34 AM
My eee-pc is white. so there may be more than color changes in the black one ;-)
By Ben, at 11:14 AM
I use Gutsy and I had to put the script in /usr/lib/hal/ for it to work. otherwise, it would not be called (for security reasons, I guess).
By Ben, at 9:41 PM
This is complete package. You write briefly in this article. These both blog entry totally informative for readers.
Hadoop Training Institute in Noida
By ciitnoida, at 11:51 PM
شركة شفط بيارات بالاحساء شركة شفط بيارات بالاحساء
شركة تنظيف فلل بالدمام شركة تنظيف فلل بالدمام
شركة مكافحة النمل الابيض بالدمام شركة مكافحة النمل الابيض بالدمام
شركة تنظيف بيارات بالدمام شركة تنظيف بيارات بالدمام
شركة تنظيف كنب بالدمام شركة تنظيف كنب بالدمام
شركة تنظيف موكيت بالدمام شركة تنظيف موكيت بالدمام
شركة مكافحة النمل الابيض بالاحساء شركة مكافحة النمل الابيض بالاحساء
شركة تنظيف كنب بالاحساء شركة تنظيف كنب بالاحساء
By jojo, at 2:14 PM
hotmail sign up login
login hotmail
By linda, at 1:08 AM
Thank you for sharing this informative post.MyAssignmenthelp.co.uk is giving assignment help to students.we are already trusted by thousands of students who struggle to write their academic papers and also by those students who simply want it management assignment help to save their time and make life easy.
By MyAssignmentHelp, at 3:28 AM
Incredible Information sharing I am exceptionally glad to peruse this article. Much obliged for giving us experience data. I value your work.
Assignment Help
Dissertation Writing Service
By rose, at 12:50 AM
special thanks to Guest Posting Blog
By DR AQ, at 1:25 AM
INTERACT SOLUTIONS offers a Voice call service provider in India, can be used by any company or individual to promote or advertise a product or brand, or services.
By pawan, at 6:42 AM
If you are looking
IVR Service provider, it is also important to choose the right IVR Service provider for long-term growth. IVR Guru has been the leading IVR Service provider all over India. IVR Guru has been providing quality IVR Services with the best pricing. Check out the prices or call us at +91-9015350505
By IVR Guru, at 9:43 PM
Thank you for share this interesting blog, myassignmenthelp have qualified and experienced faculty.
By My Assignment Help Online, at 6:53 PM
We globalassignmentexpert have a team of highly experienced and dedicated experts. If you want any kind of help in engineering assignments then we are the best at providing assignments all over the world. Our support team is always at your service. We have also a live chat facility to solve your problems. So, hurry up and place the order.
By Shira, at 11:27 PM
the telephone call and help you in the greatest possible way so that Lifestyle Write For Us
By DR AQ, at 2:05 AM
Enhance your brand awareness through our voice call marketing. Bulk Voice call service can aid you in the successful promotion of your business. Visit our website www.ivrguru.com, For Free Demo call us at +91-9015350505
By Housing Buddha, at 4:31 AM
Title: Assignment Helpers In USA | Professional Assignment Help USA
Description: Assignment helpers at oddylabs provides professional assignment help to students in USA, Canada, Australia and many more countries across the globe.
Name: Anand
Email id : oddylabsdm@gmail.com
Tags : Assignments,Essay,USa,Thesis,Dissertation
website:www.oddylabs.com
By Unknown, at 9:24 PM
best logo design service company in weatherfordu will love this website..
By tom, at 1:22 AM
Post a Comment
<< Home