mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-29 01:04:14 -04:00
Adding tests for the rollback code when the tracing_multi
link won't get attached, covering 2 reasons:
- wrong btf id passed by user, where all previously allocated
trampolines will be released
- trampoline for requested function is fully attached (has already
maximum programs attached) and the link fails, the rollback code
needs to release all previously link-ed trampolines and release
them
We need the bpf_fentry_test* unattached for the tests to pass,
so the rollback tests are serial.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20260606123955.345967-30-jolsa@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
44 lines
655 B
C
44 lines
655 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <vmlinux.h>
|
|
#include <bpf/bpf_helpers.h>
|
|
#include <bpf/bpf_tracing.h>
|
|
|
|
char _license[] SEC("license") = "GPL";
|
|
|
|
int pid = 0;
|
|
|
|
__u64 test_result_fentry = 0;
|
|
__u64 test_result_fexit = 0;
|
|
|
|
SEC("?fentry.multi")
|
|
int BPF_PROG(test_fentry)
|
|
{
|
|
if (bpf_get_current_pid_tgid() >> 32 != pid)
|
|
return 0;
|
|
|
|
test_result_fentry++;
|
|
return 0;
|
|
}
|
|
|
|
SEC("?fexit.multi")
|
|
int BPF_PROG(test_fexit)
|
|
{
|
|
if (bpf_get_current_pid_tgid() >> 32 != pid)
|
|
return 0;
|
|
|
|
test_result_fexit++;
|
|
return 0;
|
|
}
|
|
|
|
SEC("?fentry/bpf_fentry_test1")
|
|
int BPF_PROG(extra)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
SEC("?fentry/bpf_fentry_test10")
|
|
int BPF_PROG(filler)
|
|
{
|
|
return 0;
|
|
}
|