[systemd-devel] Unit to test if a domain is reachable

Tom Gundersen teg at jklm.no
Fri Jul 18 05:10:52 PDT 2014


On Fri, Jul 18, 2014 at 1:37 PM, Colin Guthrie <gmane at colin.guthr.ie> wrote:
> 'Twas brillig, and Moviuro at 17/07/14 11:41 did gyre and gimble:
>> On Thursday 17 July 2014 12:12:22 you wrote:
>>> Why not just use network-online.target?
>>> http://www.freedesktop.org/software/systemd/man/systemd.special.html#network
>>> -online.target
>> o If it succeeds, the unit that needs to reach %i gets launched and my
>> reachable-retry@ *does not* enter SUCCESS or whatever "good" state you can
>> think of: it just stays asleep until someone else wants to recheck later if
>> the domain is still reachable (e.g. domain goes down, my ISP goes crazy, I
>> suspend my computer...).
>>
>> network-online.target does not fulfill these requirements. It stays in
>> "SUCCESS" across suspend/resume cycles. Therefore, it is *not* a correct
>> indicator.
>
> I don't think any kind of unit is the right approach here. You need
> something "active" that listens to events from devices and determines
> the best course of action thereafter.
>
> I think anything you glue together with systemd units here will be a bit
> of a hack, but perhaps others will disagree.


I agree. Any unit/target will necessarily just be a best-effort to try
to give an estimate about when we are "reasonably online". Hopefully
what we have should be sufficient to satisfy legacy users that cannot
be updated to do something saner.

However, for a real daemon, you really want to be listening for events
and reacting appropriately, depending on what your precise
requirements are. You could have a look at the internals of either
systemd-networkd-wait-online, systemd-resolved or systemd-timesyncd to
get a few examples of how this could be achieved.

You'll probably want to listen to both rtnetlink (to get kernel
events) and sd-networkd (to get networkd events). The latter is not
yet exported, but any early feedback would be useful. If you are not
using networkd, you should hook into whatever daemon is running,
NetworkManager has a dbus interface you probably can use.

Cheers,

Tom


More information about the systemd-devel mailing list