bpf, selftests: Use single cgroup helpers for both test_sockmap/progs
Nearly every user of cgroup helpers does the same sequence of API calls. So push these into a single helper cgroup_setup_and_join. The cases that do a bit of extra logic are test_progs which currently uses an env variable to decide if it needs to setup the cgroup environment or can use an existingi environment. And then tests that are doing cgroup tests themselves. We skip these cases for now. Signed-off-by: John Fastabend <john.fastabend@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Andrii Nakryiko <andriin@fb.com> Link: https://lore.kernel.org/bpf/159623335418.30208.15807461815525100199.stgit@john-XPS-13-9370
This commit is contained in:

committed by
Alexei Starovoitov

parent
ffba964e4d
commit
4939b2847d
@@ -1963,23 +1963,9 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (!cg_fd) {
|
||||
if (setup_cgroup_environment()) {
|
||||
fprintf(stderr, "ERROR: cgroup env failed\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
cg_fd = create_and_get_cgroup(CG_PATH);
|
||||
if (cg_fd < 0) {
|
||||
fprintf(stderr,
|
||||
"ERROR: (%i) open cg path failed: %s\n",
|
||||
cg_fd, strerror(errno));
|
||||
cg_fd = cgroup_setup_and_join(CG_PATH);
|
||||
if (cg_fd < 0)
|
||||
return cg_fd;
|
||||
}
|
||||
|
||||
if (join_cgroup(CG_PATH)) {
|
||||
fprintf(stderr, "ERROR: failed to join cgroup\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
cg_created = 1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user