-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bpf, selftests: Add cgroup v1 net_cls classid helpers
Minimal set of helpers for net_cls classid cgroupv1 management in order to set an id, join from a process, initiate setup and teardown. cgroupv2 helpers are left as-is, but reused where possible. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20210913230759.2313-2-daniel@iogearbox.net
- Loading branch information
Daniel Borkmann
authored and
Alexei Starovoitov
committed
Sep 13, 2021
1 parent
8520e22
commit d8079d8
Showing
2 changed files
with
141 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef __CGROUP_HELPERS_H | ||
#define __CGROUP_HELPERS_H | ||
|
||
#include <errno.h> | ||
#include <string.h> | ||
|
||
#define clean_errno() (errno == 0 ? "None" : strerror(errno)) | ||
#define log_err(MSG, ...) fprintf(stderr, "(%s:%d: errno: %s) " MSG "\n", \ | ||
__FILE__, __LINE__, clean_errno(), ##__VA_ARGS__) | ||
|
||
|
||
/* cgroupv2 related */ | ||
int cgroup_setup_and_join(const char *path); | ||
int create_and_get_cgroup(const char *path); | ||
unsigned long long get_cgroup_id(const char *path); | ||
|
||
int join_cgroup(const char *path); | ||
|
||
int setup_cgroup_environment(void); | ||
void cleanup_cgroup_environment(void); | ||
unsigned long long get_cgroup_id(const char *path); | ||
|
||
#endif | ||
/* cgroupv1 related */ | ||
int set_classid(unsigned int id); | ||
int join_classid(void); | ||
|
||
int setup_classid_environment(void); | ||
void cleanup_classid_environment(void); | ||
|
||
#endif /* __CGROUP_HELPERS_H */ |