Skip to content

Commit

Permalink
selftest: fix set-attach test
Browse files Browse the repository at this point in the history
After libbpf commit 3fd6eebb2d4 ("libbpf: disassociate section handler
on explicit bpf_program__set_type() call"):

 If user explicitly overrides programs's type with
 bpf_program__set_type() API call, we need to disassociate whatever
 SEC_DEF handler libbpf determined initially based on program's SEC()
 definition, as it's not goind to be valid anymore and could lead to
 crashes and/or confusing failures.

The eBPF fentry program macro should only have the "fentry" keyword.
  • Loading branch information
rafaeldtinoco committed May 2, 2023
1 parent eba93d9 commit 8b6fa9e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion selftest/set-attach/main.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct {
} events SEC(".maps");
long ringbuffer_flags = 0;

SEC("fentry/FUNC")
SEC("fentry")
int BPF_PROG(foobar)
{
int *process;
Expand Down
1 change: 1 addition & 0 deletions selftest/set-attach/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func main() {

prog.SetProgramType(bpf.BPFProgTypeTracing)
prog.SetAttachType(bpf.BPFAttachTypeTraceFentry)

err = prog.SetAttachTarget(0, "__x64_sys_mmap")
if err != nil {
fmt.Fprintln(os.Stderr, err)
Expand Down

0 comments on commit 8b6fa9e

Please sign in to comment.