[systemd-devel] Ensuring that a unit starts before any networking
Simon McVittie
smcv at collabora.com
Tue Jun 30 12:55:45 UTC 2020
On Tue, 30 Jun 2020 at 12:59:54 +0100, Mark Rogers wrote:
> On Tue, 30 Jun 2020 at 12:13, Simon McVittie <smcv at collabora.com> wrote:
> >
> > I would have expected this to be done in some "larger" network management
> > component that is responsible for bringing up network interfaces according
> > to your configuration, rather than necessarily dhcpcd.service itself.
>
> In which case one would expect dhcpcd to depend on that instead
I meant the other way around, actually: a larger network management
component like ifupdown (which has policy, not just mechanism) tells
dhcpcd to start managing an interface, and that larger component
conceptually depends on dhcpcd. (It might not be an explicit dependency
because of automatic activation.)
Adding After=network-pre.target to dhcpcd.service is probably also not
a bad idea. It isn't clear to me whether dhcpcd brings up interfaces of
its own accord just because you start it as a systemd unit, or whether
it brings up interfaces only when specifically requested by something
like ifupdown or NetworkManager, or some mixture. If it can be configured
to bring up interfaces on its own, independent of things like ifupdown,
then it is taking on at least part of the role of a network management
component itself, in which case it does need After=network-pre.target.
> > Typically server-class systems will use either ifupdown or
> > systemd-networkd, which are ideal for relatively static network
> > configurations that are set up by a sysadmin.
>
> It's definitely not systemd-networkd, to my untrained eye it looks
> like ifupdown is there but how do I confirm?
Your unit in
https://lists.freedesktop.org/archives/systemd-devel/2020-June/044784.html
(which I missed when replying earlier) refers to networking.service,
which is part of ifupdown.
Depending on precisely what configuration you're writing out from your
database in your use-case-specific unit, you might be configuring
ifupdown to do things (in which case ifupdown's After=network-pre.target
should be enough), or you might be configuring dhcpcd to go behind
ifupdown's back to do things (in which case your use-case-specific unit
needs to happen before dhcpcd), or something else entirely. You'll need
to look at and understand the overall system you have set up.
You mentioned wanting to make your unit network-stack-agnostic, but
adding an extra layer of abstraction cannot solve all problems, and in
particular it cannot solve the problem "too many layers of abstraction".
At some point someone or something has to make a decision and actually
do something concrete :-)
smcv
More information about the systemd-devel
mailing list