};
_cleanup_free_ char *path = NULL;
- uint32_t flags;
int r;
if (!prog) {
if (r < 0)
return log_error_errno(r, "Failed to determine cgroup path: %m");
- flags = (u->type == UNIT_SLICE || unit_cgroup_delegate(u)) ? BPF_F_ALLOW_MULTI : 0;
- /* Unref the old BPF program (which will implicitly detach it) right before attaching the new program. */
- u->bpf_device_control_installed = bpf_program_unref(u->bpf_device_control_installed);
-
- r = bpf_program_cgroup_attach(prog, BPF_CGROUP_DEVICE, path, flags);
+ r = bpf_program_cgroup_attach(prog, BPF_CGROUP_DEVICE, path, BPF_F_ALLOW_MULTI);
if (r < 0)
return log_error_errno(r, "Attaching device control BPF program to cgroup %s failed: %m", path);
+ /* Unref the old BPF program (which will implicitly detach it) right before attaching the new program. */
+ u->bpf_device_control_installed = bpf_program_unref(u->bpf_device_control_installed);
+
/* Remember that this BPF program is installed now. */
u->bpf_device_control_installed = bpf_program_ref(prog);