FS#59304 - [netctl] netctl-ifplugd@.service should be changed to Type=notify

Attached to Project: Arch Linux
Opened by Dimitrios Apostolou (jimis) - Wednesday, 11 July 2018, 21:14 GMT
Last edited by Jouke Witteveen (jouke) - Tuesday, 07 August 2018, 15:51 GMT
Task Type Bug Report
Category Arch Projects
Status Closed
Assigned To Jouke Witteveen (jouke)
Architecture x86_64
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

In file `/usr/lib/systemd/system/netctl-ifplugd@.service` we see that `NotifyAccess=all`.

However, doing `systemctl show netctl-ifplugd@eth0.service` we see that `Type=simple` which means that systemd automatically considers the service as active just right after the ifplugd process has started, without waiting for any notification.

Things misbehave: other services start without netctl's DHCP client being finished; netctl's `WaitOnline` directive has no effect, etc.

Solution is to apply the following patch:


--- /usr/lib/systemd/system/netctl-ifplugd@.service.orig 2018-07-12 00:12:36.401435013 +0300
+++ /usr/lib/systemd/system/netctl-ifplugd@.service 2018-07-12 00:12:58.069435016 +0300
@@ -5,6 +5,7 @@
After=sys-subsystem-net-devices-%i.device network-pre.target

[Service]
+Type=notify
NotifyAccess=all
ExecStart=/usr/bin/ifplugd -i %I -r /etc/ifplugd/netctl.action -bfIns

This task depends upon

Closed by  Jouke Witteveen (jouke)
Tuesday, 07 August 2018, 15:51 GMT
Reason for closing:  Not a bug
Comment by Jouke Witteveen (jouke) - Wednesday, 25 July 2018, 13:13 GMT
Type=simple is correct for netctl-ifplugd. As we cannot be sure that a cable is plugged in, we should not delay any other units. The NotifyAccess=all setting is so that the status line of the unit can be set.
In other words, netctl-ifplugd is not compatible with network-online.target, but the current state of the network can be read from its status line.
Comment by Dimitrios Apostolou (jimis) - Monday, 30 July 2018, 15:34 GMT
> As we cannot be sure that a cable is plugged in, we should not delay any other units.

Why not? Especially if the user is trying exactly that, by setting "WaitOnline" in netctl? This is not default behaviour.

systemd expects that services are up when they are finished, and suggests the use of "notify" type in order to achieve this. Otherwise things misbehave in really subtle ways.

For example network-dependent services fail on boot and spit errors to syslog, get retried and succeed later. It took me a while to find out that other services that depend on them never even get started not even once, because of "unsatisfied dependencies".
Comment by Jouke Witteveen (jouke) - Monday, 30 July 2018, 15:45 GMT
The idea of ifplugd is to be functional with the cable plugged and without the cable plugged. Your use-case (expect the cable to be plugged) is covered by ordinary netctl usage (`netctl enable <profile>` and `netctl start <profile>`).
Comment by Dimitrios Apostolou (jimis) - Tuesday, 31 July 2018, 12:20 GMT
My use case is that services should be stopped when network is disconnected, and network should be re-configured when it is connected back. Because an address obtained through DHCP the second time might very well be different. That is why I use ifplugd.

So you are saying that the reason it is "simple" type service is to avoid delaying boot. Is there anyone using ifplugd that really wants the network services to be started even without network? It's not like the system is not booting properly, the console (serial or tty) should come up despite the network being down.

I have customised my system to suit my needs, the reason I submitted the patch here is to fix upstream and save trouble for others. So if you think there is no problem feel free to close this.
Comment by Jouke Witteveen (jouke) - Tuesday, 31 July 2018, 12:29 GMT
> My use case is that services should be stopped when network is disconnected, and network should be re-configured when it is connected back. Because an address obtained through DHCP the second time might very well be different. That is why I use ifplugd.

I am afraid that is not how network.target works. Using network-online.target this way is bound to get you in trouble with time-outs.

> So you are saying that the reason it is "simple" type service is to avoid delaying boot. Is there anyone using ifplugd that really wants the network services to be started even without network? It's not like the system is not booting properly, the console (serial or tty) should come up despite the network being down.

It is 'simple' because it cannot be anything else with systemd. It certainly cannot be 'notify' with ifplugd, as it would time-out when no cable is plugged in, taking the entire system with it. What you want is a daemon monitoring for a connection to go down. Such a daemon may be nice to have, but it is not netctl-ifplugd. In particular, netctl-ifplugd services are not stopped when a cable is pulled. They should not be, because they are waiting for a cable to be plugged in again!

Loading...