wpa_supplicant isn't killed on unplug

Bug #135909 reported by Alan Jenkins
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ifupdown (Ubuntu)
Expired
Wishlist
Unassigned

Bug Description

Binary package hint: wpasupplicant

I have a USB wireless wireless adaptor. I have a use case which is not well suited to NetworkManager - single AP and with a multi-user system. So I set it up using "wpa-" options in /etc/network/interfaces instead, and added a "mapping hotplug" section in case a user should unplug the adaptor and replug it for some reason :-).

So AFAIK what should happen is a copy of wpa_supplicant is started when the device is detected, and killed when it is removed. The first bit works, and I have wonderful hotplug goodness.

Unfortunately the killing on removal doesn't seem to work properly. For me it's mainly a matter of tidyness and correctness. However the surplus process is consuming resources: in particular it shows up on powertop as being responsible for 3 wakeups per second - and the target for efficient idling is somewhere under 10 per second.

I know which scripts (ifupdown hooks) are supposed to be taking care of this , but I haven't debugged it. Any hints on debugging this sort of thing would be appreciated.

Revision history for this message
Reinhard Tartler (siretart) wrote :

confirming the problem. however, there isn't much we can do on the wpasupplicant side.
There are limitiations in ifupdown which do not allow this to be implemented.

lets better help getting netconf in shape for this.

Changed in wpasupplicant:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Alan Jenkins (aj504) wrote :

I don't understand you. I found a wpasupplicant script in if-down.d. It looked like it was intended to kill wpa_supplicant, and I didn't find anything commented out or disabled. That was my bug report - I'm not bothered that I can't use NetworkManager and have to set up config files by hand, even though it would be nice to have more friendly support for the "single family computer using wireless broadband" usecase.

Oops. Um, I should mention that in order to get the hot-unplug working, I had to use the workaround for #130437. But that's marked as "New, Undecided", so I assume you're not talking about that.

What requirement of wpa_supplicant does ifupdown not meet? Ah. "ifdown wlan0" manually works fine. So you're saying that ifdown has limitations which prevent the if-down.d/wpasupplicant script working properly on hot-unplug, is that correct?

Revision history for this message
mrsuicide (mrsuicide) wrote :

This is really nasty and should be fixed.

What limitations do you mean, Reinhard?

Revision history for this message
Ignacy Gawędzki (iazz) wrote :

I happen to have a pretty similar problem with ifupdown and hostapd on Ubuntu 11.04. I've tracked down the source of the problem as being the following:

When you call ifdown on some interface that's of type "static" (this may also apply to other types, depending on the configuration mechanisms), you have declared at least an "address" and a "netmask". This means that as an "up" action, ifup will call ifconfig on this interface to set its address/netmask and put it up, and as a "down" action, ifdown will call ifconfig on this interface to set it down. When you hot-unplug an interface, the ifconfig down will fail since there's no such interface anymore. It just happens that ifupdown will then *not* run any other down or at least post-down commands in that case. Consequently neither a running wpa_supplicant, nor a hostapd will be properly terminated.

This should clearly be fixed somehow. I suppose either failing commands on down should not make the remaining commands to be skipped, or at least some kind of configurability should be present in this regard.

There is a workaround though, by setting the type to manual and running ifconfig explicitly using "up" and "down" options.

Revision history for this message
Ignacy Gawędzki (iazz) wrote :

Of course, I forgot to mention that it is then essential to specify

  down ifconfig wlanX down || true

otherwise the result will be no better than the actual static behavior.

Revision history for this message
Stéphane Graber (stgraber) wrote :

Can you test that with 11.10 or ideally 12.04 LTS? ifupdown changed the way it deals with interfaces quite a bit since then.
I honestly doubt the bug was fixed in the process, but it might be a bit different.

Changed in ifupdown (Ubuntu):
status: Confirmed → Incomplete
Revision history for this message
Alan Jenkins (aj504) wrote :

Hmm. I'm not using the same setup now, but I'm still able to test it.

"allow-hotplug" seems to have stopped working completely in Ubuntu 12.04, despite being still mentioned in the man page. I.e. the interface is not brought up automatically when I plug the hardware in. Maybe it didn't get tested because everyone uses NetworkManager. (I certainly do nowadays :).

I compared debian with ubuntu 12.04. Hotplug works on debian 6.0. It seems to work through /lib/udev/net.agent, although I can't see where its called from. Current debian unstable also has net.agent. In both cases it's provided by the udev package.

On Ubuntu 12.04, there's no net.agent. "grep -r ifup /lib/udev/" finds "bridge-network-interface", but nothing else. "apt-file seach net.agent" shows that no package contains this file.

If someone else needs to report this as a separate bug, feel free. You can simulate unplug / hotplug easily enough. Use "modprobe -r <your-network-driver>; modprobe <you-network-driver>". (To find the driver, check "ls -l /sys/class/net/*/device/driver/module"). Just remember you need set the interface up using /etc/network/interfaces.

The absence of net.agent in ubuntu, compared to debian unstable, looks like a smoking gun to me. Ubuntu has changed something from upstream, so the question is why. If something else is supposed to do the same job, then where is that something?

Revision history for this message
Stéphane Graber (stgraber) wrote :

Ubuntu uses upstart for hotplug networking.

auto <interface>
iface <interface> inet <mode>
    ....

Will make it apply to the interface whenever <interface> shows up and be brought down whenever it disappears. The network-* rules in /etc/init/ are doing that.

Revision history for this message
Alan Jenkins (aj504) wrote :

Heh, that's going to get confusing (v.s. debian and the documention still in Ubuntu).

It works when I plug it in with "auto / allow-auto". It still works after unplugging and replugging again, which is good.

Unplugging still leaves wpa_supplicant running, so this bug still exists.

Revision history for this message
Alan Jenkins (aj504) wrote :

"Will make it apply to the interface whenever <interface> shows up"

 - also confused me a bit. It's *not* equivalent to allow-hotplug. auto/allow-auto blocks the boot process if the interface is unplugged when you reboot.

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for ifupdown (Ubuntu) because there has been no activity for 60 days.]

Changed in ifupdown (Ubuntu):
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.