[Nix-dev] unifying networking related triggers

Mathijs Kwik mathijs at bluescreen303.nl
Mon Feb 20 13:56:36 CET 2012


Hi all,

In recent commits, I saw that ifplugd got cleaned up a bit and now has
configurable commands to execute when connected.
I submitted a patch with the same functionality for wicd, and probably
someday someone will do the same for NetworkManager.

On top of the physical connection, there are choices for setting the
ip address: dhclient, the new dhcpcd, static, or through
wicd/NetworkManager.
Then after an ip address is assigned, some services need to (re)start.

I think we should decide on a unified way to handle these stages, so
the components can be swapped easily.
Personally, I would prefer to plug stuff together using upstart
triggers (or someday systemd), but generic "networking.events" config
options are fine too. Upstart triggers integrate well with
starting/stopping services, but are still easy enough to just run a
few commands (tasks). Triggers support arguments as well (like the
name of a network interface that came up, or which wifi access point
got connected).

I propose the following events:

if-up: (iface name, ESSID)
cable plugged in / wifi bound to AP. Still needs an IP.

ip-up: (iface name, ESSID)
interface fully configured

internet-up: (iface name, ESSID)
some services need to know when there is an internet connection (as
opposed to just any interface up).
By having a networking.internetInterfaces config option (defaulting to
eth0 / wlan0), this can be found out.
The event triggers when the first internet interface is up only.
Second+ interfaces don't re-trigger.

internet-stopping (iface name, ESSID)
last available internet interface requests to go down (is still up),
shutdown/goodbye gracefully

internet-down(iface name, ESSID, forced)
all internet interfaces are down. "forced" parameter indicates if this
was scheduled or as a result of a network error / expired lease

ip-stopping (iface name, ESSID)
interface requests to go down (is still up), shutdown/goodbye gracefully

ip-down (iface name, ESSID, forced)
interface lost IP. "forced" parameter indicates if this was scheduled
or as a result of a network error / expired lease

if-stopping(iface name, ESSID)
not really useful I think, just for completeness

if-down(iface name, ESSID, forced)
interface fully down.


Not every module will support all of these (especially the "stopping"
ones are probably just for wicd/NetworkManager).
Wicd also supports pre-up (starting), but I can't see a usecase for that.

Perhaps we can extend this some more in the future, or simplify
something on top of it.

I would love to hear suggestions/thoughts about this. Especially from
laptop users and other setups with dynamic/multiple interfaces. Would
this suffice? Would it be too much? Is upstart the right choice to
coordinate these events?

Thanks,
Mathijs


More information about the nix-dev mailing list