I ran into this bug as well. I'm trying to set up an automatic WiFi AP with
hostap so that plugging in a WiFi dongle starts hostap and unplugging stops
it. The stopping is supposed to be done with an if-post-down.d script.
The problem is exactly what Vasilis Vasaitis describes, ifdown fails if the
dongle is already removed and the interface is gone.
Code in ifupdown.nw:2730 exits early, because down() method fails:
if (!iface->method->down(iface,doit)) return 0;
...
if (!execute_scripts(iface,doit,"post-down")) return 0;
The down() method executes:
ip -4 addr flush dev wlan1 label wlan1
which fails because wlan1 is gone.
Is there a problem with the fix suggested by Vasilis? Run post-down scripts
even if down() fails. I guess it would be a bit cleaner to make down()
succeed if the interface is gone. I could work on the patch. Andrew, what
do you think?
Would be nice to fix this, it's been open for 8 years.