Re: Issues with suspend-to-ram (netctl)
Roy Marples
Sun Aug 16 19:11:05 2020
On 14/08/2020 11:25, Jouke Witteveen wrote:
The original poster of the netctl issue did some more experiments and
found out that a very similar issue occurs when the device disappears.
With a USB network adapter, this can happen when the adapter is
unplugged. I guess that may be easier to simulate in a VM than a
suspend.
# ./dhcpcd -dB tap0
dhcpcd-9.1.4 starting
spawned privileged actioneer on PID 4398
spawned network proxy on PID 4399
spawned controller proxy on PID 4400
DUID 00:01:00:01:26:4d:67:88:fa:73:78:00:00:11
chrooting to `/var/chroot/dhcpcd' as _dhcpcd
tap0: executing `/libexec/dhcpcd-run-hooks' PREINIT
tap0: executing `/libexec/dhcpcd-run-hooks' NOCARRIER
tap0: waiting for carrier
tap0: carrier acquired
tap0: executing `/libexec/dhcpcd-run-hooks' CARRIER
tap0: IAID 86:ec:08:8b
tap0: adding address fe80::3e5f:fd7b:9f12:44b7
tap0: pltime infinity, vltime infinity
ipv6_addaddr1: No such device
tap0: delaying IPv6 router solicitation for 0.7 seconds
tap0: delaying IPv4 for 1.4 seconds
tap0: carrier lost
tap0: executing `/libexec/dhcpcd-run-hooks' NOCARRIER
tap0: interface departed
tap0: removing interface
tap0: executing `/libexec/dhcpcd-run-hooks' DEPARTED
dhcpcd exited
I removed the tap0 interface and it exited cleanly. I don't know why the carrier
came up though - lol.
I repeated this numerous times, everything worked fine.
It is pretty warm at my place, so I don't spend too much time behind a
computer, but here is another hypothesis on why some people are seeing
their systemd services time out and killing dhcpcd forcefully. Could
it be that in some cases dhcpcd spans multiple system processes and
does not kill all of them in case of an error? If one process reports
'dhcpcd exited', but other processes remain, then systemd is right to
infer that the service as a whole has not exited.
Yes, dhcpcd does man multiple processes these days thanks it's privilege
separation. The expectation is that just the master process is sent SIGTERM or
the user runs `dhcpcd -x` to cause dhcpcd to exit.
If the priviledged process is terminated before the master process, this would
explain the errors.
I don't intend to fix that because system cleanup may need to be performed at
exist, which the master process needs the privledged process to perform.
From the logs, it's clear that something is asking dhcpcd to exit - now this
something kills all dhcpcd proceesses, this would be bad and it should stop.
I am uncertain if igoring SIGTERM in the non master processes is a good thing or
not. I've attached a patch which does this though - does it help at all?
Roy
diff --git a/src/privsep-bpf.c b/src/privsep-bpf.c
index 6892bf2a..fde3fe1a 100644
--- a/src/privsep-bpf.c
+++ b/src/privsep-bpf.c
@@ -171,14 +171,10 @@ ps_bpf_start_bpf(void *arg)
}
static void
-ps_bpf_signal_bpfcb(int sig, void *arg)
+ps_bpf_signal_bpfcb(__unused int sig, __unused void *arg)
{
- struct dhcpcd_ctx *ctx = arg;
- if (sig != SIGTERM)
- return;
-
- eloop_exit(ctx->eloop, EXIT_SUCCESS);
+ /* This space left intentionally blank. */
}
ssize_t
diff --git a/src/privsep-control.c b/src/privsep-control.c
index 306ab58f..6ab84555 100644
--- a/src/privsep-control.c
+++ b/src/privsep-control.c
@@ -96,15 +96,10 @@ ps_ctl_recvmsg(void *arg)
}
static void
-ps_ctl_signalcb(int sig, void *arg)
+ps_ctl_signalcb(__unused int sig, __unused void *arg)
{
- struct dhcpcd_ctx *ctx = arg;
-
- if (sig != SIGTERM)
- return;
- shutdown(ctx->ps_control_fd, SHUT_RDWR);
- eloop_exit(ctx->eloop, EXIT_SUCCESS);
+ /* This space left intentionally blank. */
}
ssize_t
diff --git a/src/privsep-inet.c b/src/privsep-inet.c
index 8bc0c2ea..690d5fc5 100644
--- a/src/privsep-inet.c
+++ b/src/privsep-inet.c
@@ -292,15 +292,10 @@ ps_inet_recvmsg(void *arg)
}
static void
-ps_inet_signalcb(int sig, void *arg)
+ps_inet_signalcb(__unused int sig, __unused void *arg)
{
- struct dhcpcd_ctx *ctx = arg;
-
- if (sig != SIGTERM)
- return;
- shutdown(ctx->ps_inet_fd, SHUT_RDWR);
- eloop_exit(ctx->eloop, EXIT_SUCCESS);
+ /* This space left intentionally blank. */
}
ssize_t
diff --git a/src/privsep-root.c b/src/privsep-root.c
index fe6b1aa6..482280fb 100644
--- a/src/privsep-root.c
+++ b/src/privsep-root.c
@@ -693,22 +693,13 @@ ps_root_startcb(void *arg)
}
static void
-ps_root_signalcb(int sig, void *arg)
+ps_root_signalcb(int sig, __unused void *arg)
{
- struct dhcpcd_ctx *ctx = arg;
if (sig == SIGCHLD) {
while (waitpid(-1, NULL, WNOHANG) > 0)
;
- return;
}
-
- if (sig != SIGTERM)
- return;
-
- shutdown(ctx->ps_root_fd, SHUT_RDWR);
- shutdown(ctx->ps_data_fd, SHUT_RDWR);
- eloop_exit(ctx->eloop, EXIT_SUCCESS);
}
int (*handle_interface)(void *, int, const char *);
Archive administrator: postmaster@marples.name