udev: String substitutions can be done in ENV, too
[systemd_ALT.git] / src / core / bpf-util.c
blob6fe229e32dbcab3fcd5c393bcd84f954f17ad604
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
3 #include "bpf-dlopen.h"
4 #include "bpf-util.h"
5 #include "cgroup-util.h"
6 #include "initrd-util.h"
7 #include "log.h"
9 bool cgroup_bpf_supported(void) {
10 static int supported = -1;
11 int r;
13 if (supported >= 0)
14 return supported;
16 r = cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER);
17 if (r < 0) {
18 log_warning_errno(r, "Can't determine whether the unified hierarchy is used: %m");
19 return (supported = false);
22 if (r == 0) {
23 log_info_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
24 "Not running with unified cgroup hierarchy, disabling cgroup BPF features.");
25 return (supported = false);
28 r = dlopen_bpf();
29 if (r < 0) {
30 log_full_errno(in_initrd() ? LOG_DEBUG : LOG_INFO,
31 r, "Failed to open libbpf, cgroup BPF features disabled: %m");
32 return (supported = false);
35 return (supported = true);