]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: fix bpf-foreign cg controller realization
authorJulia Kartseva <hex@fb.com>
Fri, 5 Nov 2021 01:52:02 +0000 (18:52 -0700)
committerJulia Kartseva <hex@fb.com>
Thu, 11 Nov 2021 05:00:25 +0000 (21:00 -0800)
Requiring /sys/fs/bpf path to be a mount point at the moment of cgroup
controllers realization does more harm than good, because:
* Realization happens early on boot, the mount point may not be ready at
the time. That happens if mounts are made by a .mount unit (the issue we
encountered).
* BPF filesystem may be mounted on another point.

Remove the check. Instead verify that path provided by BPFProgram= is
within BPF fs when unit properties are parsed.

Split in two commits for simple backport.

src/core/bpf-foreign.c
src/core/bpf-foreign.h

index 6b93b9785fb5e1344ab4e297c55a3fd07ac67529..686c14ce1f18403ee6f8dc2e97cf2e78bb1e566e 100644 (file)
@@ -111,16 +111,6 @@ static int bpf_foreign_prepare(
         return 0;
 }
 
-int bpf_foreign_supported(void) {
-        int r;
-
-        r = cg_all_unified();
-        if (r <= 0)
-                return r;
-
-        return path_is_mount_point("/sys/fs/bpf", NULL, 0);
-}
-
 int bpf_foreign_install(Unit *u) {
         _cleanup_free_ char *cgroup_path = NULL;
         CGroupBPFForeignProgram *p;
index 9559cd79812b914f8dbb7f68c5175f064cb8f455..e387b1b1d3897a42ab065cf231685a393f6f0247 100644 (file)
@@ -4,7 +4,10 @@
 
 #include "unit.h"
 
-int bpf_foreign_supported(void);
+static inline int bpf_foreign_supported(void) {
+        return cg_all_unified();
+}
+
 /*
  * Attach cgroup-bpf programs foreign to systemd, i.e. loaded to the kernel by an entity
  * external to systemd.