Skip to content

Commit

Permalink
bpftool: Change pid_iter.bpf.c to comply with the change of bpf_link_…
Browse files Browse the repository at this point in the history
…fops.

To support epoll, a new instance of file_operations, bpf_link_fops_poll,
has been added for links that support epoll. The pid_iter.bpf.c checks
f_ops for links and other BPF objects. The check should fail for struct_ops
links without this patch.

Acked-by: Quentin Monnet <[email protected]>
Signed-off-by: Kui-Feng Lee <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Martin KaFai Lau <[email protected]>
  • Loading branch information
ThinkerYzu1 authored and qmonnet committed Jun 4, 2024
1 parent 3432403 commit 820fac6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/skeleton/pid_iter.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ enum bpf_link_type___local {
};

extern const void bpf_link_fops __ksym;
extern const void bpf_link_fops_poll __ksym __weak;
extern const void bpf_map_fops __ksym;
extern const void bpf_prog_fops __ksym;
extern const void btf_fops __ksym;
Expand Down Expand Up @@ -84,7 +85,11 @@ int iter(struct bpf_iter__task_file *ctx)
fops = &btf_fops;
break;
case BPF_OBJ_LINK:
fops = &bpf_link_fops;
if (&bpf_link_fops_poll &&
file->f_op == &bpf_link_fops_poll)
fops = &bpf_link_fops_poll;
else
fops = &bpf_link_fops;
break;
default:
return 0;
Expand Down

0 comments on commit 820fac6

Please sign in to comment.