Today, udev and hotplug are stupid

2005 July 6
by darkness

Things are frequently stupid. Don’t take it personally.

Sometimes I want to unload my wireless card driver. It’s the only way I’ve found to apparently turn it off (or, at least, the LED turns off). Maybe I should check out documentation, or /proc or /sys for some controls. Regardless, sometimes you want to unload a module.

Unfortunately, on my FC4 system, every time I rmmod ipw2100 it gets loaded again a few seconds. Turns out this is a combination of udev and hotplug.

I first suspected udev. Into /etc/udev/rules.d/10-darkness.rules I put:

DRIVER=="ipw2100",                      OPTIONS="ignore_device,last_rule"
BUS=="pci", ID=="02:02.0",              OPTIONS="ignore_device,last_rule"

They are redundant, but I hoped maybe one would work where the other didn’t. (For example, the kernel somehow didn’t know the driver name at the time it sent events to udev.) This had absolutely zero effects.

To get useful (bordering on too verbose) debugging information from udev, you actually have to rebuild the RPM, after changing %define debug false to true. After searching through the debug log, it looks like it’s correctly parsing my rules. Then it just goes and runs /etc/hotplug.d/default/default.hotplug net. I read the source, and it turns out that there’s some logic in udev that says “if this isn’t a device that’s going to go in /dev, I don’t care about it, so just short circuit and send it to hotplug.” This is, of course, before it does the if (ignore_device) kind of check.

So now I dig through hotplug. I’ve got HOTPLUG=no in /etc/sysconfig/network-scripts/ifcfg-wlan0 (and, incidentally, ifcfg-eth1, since the device is called eth1 before nameif runs) but clearly this is having no effect. HOTPLUG is checked in /etc/sysconfig/network-scripts/ifup. But then I look at /etc/hotplug/net.agent a bit more and see that it does some sort of dorky things:

  • It tries to use ip link show on the device to get its MAC, which it in turn uses to try and find a config file for the device (i.e., so it can see HOTPLUG=no).
  • When it goes to remove the device, it calls ifdown, and somehow that was triggering a modprobe of the device.

That last, especially, makes me think I just wasn’t removing this device correctly. So if anyone knows the right way I can conserve power when not using my Mini-PCI ipw2100 card, please let me know.

In the meantime, I just put some things before *) in /etc/hotplug.d/net.agent, along the lines of:

eth1|wlan0)
    debug_mesg darkness: no ifup wireless
    exit 0
    ;;

I put that in both the cases for add|register and for remove|unregister. Now I can rmmod ipw2100 and it stays unloaded, but service waproamd start will still cause the module to load.

No Comments

Leave A Comment

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS