From f7fa5cc14583fafb091cdb4c997bb11f60c1fd90 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Tue, 20 Jun 2023 11:34:18 +0200 Subject: [PATCH] basic.target: Pull network Currently, the network is started more or less by chance, because a few services have dependencies on network.target, which in fact is even wrong. Following the systemd.special(7) and bootup(7) logic, network.target should be a passive unit and no units should have a Wants or Requires dependencies on it. A unit which really wants or requires network connectivity should depend on network-online.target, on the other hand, typicall service units really don't need network connectivity. However, Mariux64 is kind of special in some ways: - We have services started on dedicated IP addresses and vlan interfaces. For the bind to work, the vlan interfaces have to exist and also the ip addreses must be configured, unless the service uses the IP_FREEBIND socket option or we globally enable ip_nonlocal_bind. - We have a global filesystem namespace using automounted remote filesystems. Services, cron-jobs and user sessions might all require the network to be available to access the files which happen to be on a remote systems. So in fact we shouldn't start normal user processses via mxstartup or cron or login sessions before we tried our best to provide network connectivity. So for Mariux64, which havenly depends on the network, make the attempt to start the network part of the basic os service, available with basic-target. After this change, all normal services can assume, that the ip interfaces are available, the ip addresses have been configured (if not done by mxstartup), we've waited a reasonable time for the link to come up, the default route has been set, automount-paths are available, name resolution works and important services like the default nameserver or mxshadow are available. At least in the realm of the local systems responsibility, of course, things will still fail if the network or the peer server have issues. --- install.sh | 2 ++ .../systemd/system/basic.target.d/want-network.conf | 4 ++++ misc_systemd_units/ip6.service | 2 ++ misc_systemd_units/mxvlan.service | 2 ++ 4 files changed, 10 insertions(+) create mode 100644 misc_etc_files/systemd/system/basic.target.d/want-network.conf diff --git a/install.sh b/install.sh index d58444c..8a41287 100755 --- a/install.sh +++ b/install.sh @@ -265,6 +265,8 @@ install_data misc_etc_files/request-key.d/id_resolver.conf \ "$DESTDIR$sysconfdir/request-key.d/id_resolver.conf" install_symlink /etc/local/access.conf "$DESTDIR$sysconfdir/security/access.conf" install_data misc_etc_files/cups/client.conf "$DESTDIR$sysconfdir/cups/client.conf" +install_data misc_etc_files/systemd/system/basic.target.d/want-network.conf \ + "$DESTDIR$sysconfdir/systemd/system/basic.target.d/want-network.conf" postinstall exit diff --git a/misc_etc_files/systemd/system/basic.target.d/want-network.conf b/misc_etc_files/systemd/system/basic.target.d/want-network.conf new file mode 100644 index 0000000..a66db22 --- /dev/null +++ b/misc_etc_files/systemd/system/basic.target.d/want-network.conf @@ -0,0 +1,4 @@ +[Unit] + +Wants=network.target +After=network-online.target diff --git a/misc_systemd_units/ip6.service b/misc_systemd_units/ip6.service index 775eaba..37ee473 100644 --- a/misc_systemd_units/ip6.service +++ b/misc_systemd_units/ip6.service @@ -1,5 +1,7 @@ [Unit] +DefaultDependencies=no + Wants=startup-tags.service After=startup-tags.service ConditionPathExists=/node/tags/ip6 diff --git a/misc_systemd_units/mxvlan.service b/misc_systemd_units/mxvlan.service index 5459a4c..78b7f57 100644 --- a/misc_systemd_units/mxvlan.service +++ b/misc_systemd_units/mxvlan.service @@ -1,5 +1,7 @@ [Unit] +DefaultDependencies=no + Wants=network.service After=network.service Before=network.target