[systemd-devel] networkd D-Bus API for link up/down?

Kevin P. Fleming kevin at km6g.us
Thu Sep 22 16:21:30 UTC 2022


On Thu, Sep 22, 2022 at 9:45 AM Lennart Poettering
<lennart at poettering.net> wrote:
>
> On Mi, 21.09.22 06:48, Kevin P. Fleming (kevin at km6g.us) wrote:
>
> > When the D-Bus API for systemd-networkd was added there were
> > indications that it could be used for bringing links up and down.
> > However, when I review the API docs at:
> >
> > https://www.freedesktop.org/software/systemd/man/org.freedesktop.network1.html#
> >
> > I don't see any methods for doing those operations. networkctl uses
> > netlink messages for these operations as well.
> >
> > I want to create a cluster resource agent for Pacemaker which can
> > manage networkd links, and using D-Bus would be easier than using
> > netlink since there is already D-Bus support in the resource agent for
> > systemd units.
>
> This is currently not available. But do note that you can use
> ActivationPolicy= in a .network file and then simply toggle the IFF_UP flag
> on the net device, and networkd is happy.
>
> If you don#t want to bother with rtnetlink for that you could even use
> the old BSD ioctls, i.e. SIOCSIFFLAGS.

Thanks! I'm already using ActivationPolicy=manual in the .network file
since networkd can't know when the interface should be up or down.

For now I will use an OCF-style resource agent (fancy shell script)
which uses 'networkctl' to do the work, but later I'll consider making
something more 'native'. My primary motivation for having a 'native'
RA is reducing the cost (time and CPU) of the regular monitoring
operations; launching a shell script which sources many files of
functions and has to parse 'networkctl --json' output is much more
costly than using an ioctl to check the status of the interface
directly. It's possible that using 'ip link' instead of 'networkctl'
will be more efficient, so I may pursue that option too.


More information about the systemd-devel mailing list