Skip to content

Commit cab53b8

Browse files
laoarKernel Patches Daemon
authored andcommitted
bpf: Enable bpf_cgrp_storage for cgroup1 non-attach case
In the current cgroup1 environment, associating operations between cgroups and applications in a BPF program requires storing a mapping of cgroup_id to application either in a hash map or maintaining it in userspace. However, by enabling bpf_cgrp_storage for cgroup1, it becomes possible to conveniently store application-specific information in cgroup-local storage and utilize it within BPF programs. Furthermore, enabling this feature for cgroup1 involves minor modifications for the non-attach case, streamlining the process. However, when it comes to enabling this functionality for the cgroup1 attach case, it presents challenges. Therefore, the decision is to focus on enabling it solely for the cgroup1 non-attach case at present. If attempting to attach to a cgroup1 fd, the operation will simply fail with the error code -EBADF. Signed-off-by: Yafang Shao <[email protected]> Acked-by: Tejun Heo <[email protected]> Acked-by: Yonghong Song <[email protected]>
1 parent 21e8702 commit cab53b8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/bpf/bpf_cgrp_storage.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static void *bpf_cgrp_storage_lookup_elem(struct bpf_map *map, void *key)
8282
int fd;
8383

8484
fd = *(int *)key;
85-
cgroup = cgroup_get_from_fd(fd);
85+
cgroup = cgroup_v1v2_get_from_fd(fd);
8686
if (IS_ERR(cgroup))
8787
return ERR_CAST(cgroup);
8888

@@ -101,7 +101,7 @@ static long bpf_cgrp_storage_update_elem(struct bpf_map *map, void *key,
101101
int fd;
102102

103103
fd = *(int *)key;
104-
cgroup = cgroup_get_from_fd(fd);
104+
cgroup = cgroup_v1v2_get_from_fd(fd);
105105
if (IS_ERR(cgroup))
106106
return PTR_ERR(cgroup);
107107

@@ -131,7 +131,7 @@ static long bpf_cgrp_storage_delete_elem(struct bpf_map *map, void *key)
131131
int err, fd;
132132

133133
fd = *(int *)key;
134-
cgroup = cgroup_get_from_fd(fd);
134+
cgroup = cgroup_v1v2_get_from_fd(fd);
135135
if (IS_ERR(cgroup))
136136
return PTR_ERR(cgroup);
137137

0 commit comments

Comments
 (0)