pin link to a path and load from it

This commit is contained in:
2023-08-19 19:35:44 +08:00
parent 72ead3f149
commit 6989232973
4 changed files with 66 additions and 10 deletions

View File

@ -31,6 +31,7 @@ struct {
__uint(max_entries, FILE_PROTECT_MAX);
__type(key, file_protect_state);
__type(value, __u64);
__uint(pinning, LIBBPF_PIN_BY_NAME);
} states SEC(".maps");
struct {
@ -38,6 +39,7 @@ struct {
__uint(max_entries, 256);
__type(key, unsigned long);
__type(value, __u8);
__uint(pinning, LIBBPF_PIN_BY_NAME);
} roots SEC(".maps");
struct {
@ -45,6 +47,7 @@ struct {
__uint(max_entries, 1024 * 1024);
__type(key, unsigned long);
__type(value, __u64);
__uint(pinning, LIBBPF_PIN_BY_NAME);
} banned_access SEC(".maps");
#define MAX_PATH_FRAGEMENTS 256
@ -123,6 +126,8 @@ int BPF_PROG(check_file_open, struct file *file, int ret) {
data.need_to_be_checked = 1;
bpf_for_each_map_elem(&states, check_service_status, &data, 0);
// TODO: write perf data
if (!data.need_to_be_checked) {
return 0;
}