Skip to content

Commit

Permalink
[daemon] Add support for libbpf v1.0+
Browse files Browse the repository at this point in the history
  • Loading branch information
strang1ato committed Mar 9, 2023
1 parent bab6aca commit f800717
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions daemon/src/nhi.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,45 @@

char LICENSE[] SEC("license") = "GPL";

struct bpf_map_def SEC("maps") shells = {
.type = BPF_MAP_TYPE_ARRAY,
.key_size = 4,
.value_size = sizeof(struct shell),
.max_entries = SHELLS_MAX_ENTRIES,
};

struct bpf_map_def SEC("maps") children = {
.type = BPF_MAP_TYPE_ARRAY,
.key_size = 4,
.value_size = sizeof(struct child),
.max_entries = CHILDREN_MAX_ENTRIES,
};

struct bpf_map_def SEC("maps") ring_buffer = {
.type = BPF_MAP_TYPE_RINGBUF,
.max_entries = RING_BUFFER_MAX_ENTRIES,
};

struct bpf_map_def SEC("maps") __fdget_pos_pos = {
.type = BPF_MAP_TYPE_PERCPU_ARRAY,
.key_size = 4,
.value_size = sizeof(unsigned long),
.max_entries = 1,
};

struct bpf_map_def SEC("maps") ksys_write_event = {
.type = BPF_MAP_TYPE_PERCPU_ARRAY,
.key_size = 4,
.value_size = KSYS_WRITE_EVENT_SIZE,
.max_entries = 1,
};

struct bpf_map_def SEC("maps") ksys_write_d_inode = {
.type = BPF_MAP_TYPE_PERCPU_ARRAY,
.key_size = 4,
.value_size = sizeof(struct inode),
.max_entries = 1,
};
struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(key_size, 4);
__uint(value_size, sizeof(struct shell));
__uint(max_entries, SHELLS_MAX_ENTRIES);
} shells SEC(".maps");

struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(key_size, 4);
__uint(value_size, sizeof(struct child));
__uint(max_entries, CHILDREN_MAX_ENTRIES);
} children SEC(".maps");

struct {
__uint(type, BPF_MAP_TYPE_RINGBUF);
__uint(max_entries, RING_BUFFER_MAX_ENTRIES);
} ring_buffer SEC(".maps");

struct {
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
__uint(key_size, 4);
__uint(value_size, sizeof(unsigned long));
__uint(max_entries, 1);
} __fdget_pos_pos SEC(".maps");

struct {
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
__uint(key_size, 4);
__uint(value_size, KSYS_WRITE_EVENT_SIZE);
__uint(max_entries, 1);
} ksys_write_event SEC(".maps");

struct {
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
__uint(key_size, 4);
__uint(value_size, sizeof(struct inode));
__uint(max_entries, 1);
} ksys_write_d_inode SEC(".maps");

SEC("fentry/kill_something_info")
int BPF_PROG(kill_something_info, int sig, struct kernel_siginfo *info, pid_t pid)
Expand Down

0 comments on commit f800717

Please sign in to comment.