From a42232a18c5716f69efc67c779dd2ef6c4b9d6c2 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Tue, 30 Nov 2021 23:49:33 +0000 Subject: [PATCH 1/2] cgroup: don't emit BPF firewall warning when manager is in test mode Support for BPF might not have been checked, since it's not necessary in test mode (eg: running offline analysis of units). This causes an assert: Assertion '(_error) != 0' failed at src/core/bpf-firewall.c:914, function emit_bpf_firewall_warning(). Aborting. Export SYSTEMD_LOG_LEVEl=debug in TEST-65-ANALYZE is enough to trigger this assert while doing an offline analysis of a unit that has some firewall/network restrictions set. Skip the warning if the manager is in test mode. --- src/core/bpf-firewall.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/bpf-firewall.c b/src/core/bpf-firewall.c index 2c202f1ea6..8da71805fc 100644 --- a/src/core/bpf-firewall.c +++ b/src/core/bpf-firewall.c @@ -908,7 +908,10 @@ int bpf_firewall_supported(void) { void emit_bpf_firewall_warning(Unit *u) { static bool warned = false; - if (!warned) { + assert(u); + assert(u->manager); + + if (!warned && !MANAGER_IS_TEST_RUN(u->manager)) { bool quiet = bpf_firewall_unsupported_reason == -EPERM && detect_container() > 0; log_unit_full_errno(u, quiet ? LOG_DEBUG : LOG_WARNING, bpf_firewall_unsupported_reason, From cb94244406559469ececfc9288490375057932c6 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Tue, 30 Nov 2021 23:49:58 +0000 Subject: [PATCH 2/2] test: run commands with debug level logs in TEST-65-ANALYZE --- test/units/testsuite-65.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/units/testsuite-65.sh b/test/units/testsuite-65.sh index 245f74c5d9..867a77a1b7 100755 --- a/test/units/testsuite-65.sh +++ b/test/units/testsuite-65.sh @@ -4,6 +4,7 @@ set -eux systemd-analyze log-level debug +export SYSTEMD_LOG_LEVEL=debug mkdir -p /tmp/img/usr/lib/systemd/system/ mkdir -p /tmp/img/opt/