Am 03.07.2012 13:44, schrieb Jouke Witteveen:
Instead, why not remodel this to use the same logic as net-auto-wireless? Create the right wpa_supplicant configuration, start wpa_s and let wpa_actiond bring up the interface? This seems much better than hardcoded timeouts and wait loops inside shell scripts. And you do not have to write much new code, everything's there.
In that case, we should depend on and maintain wpa_actiond, which is not a bash script. I think it is possible to rewrite connections/wireless in a more netcfg way, that is: using plain scripting. Ideally, I see netcfg as just that: a collection of scripts to automate networking routines based on simple profile definitions.
The problem I saw here was this: Wireless connections can go up and down all the time, and you have to act accordingly. What netcfg currently does is this: - Is the network there? No -> Fail - Start the supplicant. - wpa_cli status -> Are we connected? No -> Sleep and Repeat - After a timeout: Fail. It does not handle the case where connecting takes longer than the timeout (for example, you are out of range and then move closer). It does not handle the case where you lose the connection (although dhcpcd re-acquires the lease nowadays, this was not always the case). In short, netcfg may fail in cases where it shouldn't. When writing net-auto-wireless (or its predecessor autowifi), I considered the following: wpa_supplicant knows when the connection state changes and has mechanisms to notify us. Let's use those mechanisms. Sadly, 'wpa_cli -a' was not suited for this, as disconnecting and reconnecting immediately lead to annoying race conditions (which happened with my wireless constantly at the time). wpa_actiond is simply a more clever version of 'wpa_cli -a'. I don't really understand why anyone would prefer manually selecting the wireless profile instead of running net-auto-wireless to automatically choose. But even if you want to do that, you should not have all those race conditions that result from the half-baked connection logic I mentioned in the beginning.