Skip to content
Snippets Groups Projects
Unverified Commit bc73aae2 authored by Vini's avatar Vini Committed by GitHub
Browse files

minimal: Split open and load in minimal.c as it creates issue in old Kernel version (#5)

Ensure my_pid is initialized before the load to make it work
on older kernels that don't support memory-mapped arrays,
which are necessary for updating global variables after BPF
program is loaded.
parent 2b2426e0
No related branches found
No related tags found
No related merge requests found
......@@ -35,16 +35,23 @@ int main(int argc, char **argv)
/* Bump RLIMIT_MEMLOCK to allow BPF sub-system to do anything */
bump_memlock_rlimit();
/* Load and verify BPF application */
skel = minimal_bpf__open_and_load();
/* Open BPF application */
skel = minimal_bpf__open();
if (!skel) {
fprintf(stderr, "Failed to open and load BPF skeleton\n");
fprintf(stderr, "Failed to open BPF skeleton\n");
return 1;
}
/* ensure BPF program only handles write() syscalls from our process */
skel->bss->my_pid = getpid();
/* Load & verify BPF programs */
err = minimal_bpf__load(skel);
if (err) {
fprintf(stderr, "Failed to load and verify BPF skeleton\n");
goto cleanup;
}
/* Attach tracepoint handler */
err = minimal_bpf__attach(skel);
if (err) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment