libbpf / bpftool

Automated upstream mirror for bpftool stand-alone build.
Other
398 stars 71 forks source link

Cannot list programs attached to cgroup #149

Closed Werkov closed 4 months ago

Werkov commented 4 months ago

Expected beheavior

$ bpftool cgroup list /sys/fs/cgroup/init.scope/
(list of progs or empty list

Actual behavior

$ bpftool cgroup list /sys/fs/cgroup/init.scope/
Error: can't query bpf programs attached to /sys/fs/cgroup/init.scope/: No such device or address

Info

kernel 6.9.3-1-default, openSUSE Tumbleweed bpftool-7.4.0-2.2.x86_64

It looks like bpftool probes for various programs and cannot recover from ENXIO:

strace bpftool cgroup list /sys/fs/cgroup/init.scope/
execve("/sbin/bpftool", ["bpftool", "cgroup", "list", "/sys/fs/cgroup/init.scope/"], 0x7ffc2d9602e8 /* 56 vars */) = 0
...
bpf(BPF_PROG_QUERY, {query={target_fd=3, attach_type=BPF_TCX_EGRESS, query_flags=0, attach_flags=0, prog_ids=NULL, prog_cnt=0}, ...}, 64) = 0
bpf(BPF_PROG_QUERY, {query={target_fd=3, attach_type=BPF_TRACE_UPROBE_MULTI, query_flags=0, attach_flags=0, prog_ids=NULL, prog_cnt=0}}, 64) = -1 EINVAL (Invalid argument)
bpf(BPF_PROG_QUERY, {query={target_fd=3, attach_type=BPF_CGROUP_UNIX_CONNECT, query_flags=0, attach_flags=0, prog_ids=NULL, prog_cnt=0}}, 64) = 0
bpf(BPF_PROG_QUERY, {query={target_fd=3, attach_type=BPF_CGROUP_UNIX_SENDMSG, query_flags=0, attach_flags=0, prog_ids=NULL, prog_cnt=0}}, 64) = 0
bpf(BPF_PROG_QUERY, {query={target_fd=3, attach_type=BPF_CGROUP_UNIX_RECVMSG, query_flags=0, attach_flags=0, prog_ids=NULL, prog_cnt=0}}, 64) = 0
bpf(BPF_PROG_QUERY, {query={target_fd=3, attach_type=BPF_CGROUP_UNIX_GETPEERNAME, query_flags=0, attach_flags=0, prog_ids=NULL, prog_cnt=0}}, 64) = 0
bpf(BPF_PROG_QUERY, {query={target_fd=3, attach_type=BPF_CGROUP_UNIX_GETSOCKNAME, query_flags=0, attach_flags=0, prog_ids=NULL, prog_cnt=0}}, 64) = 0
bpf(BPF_PROG_QUERY, {query={target_fd=3, attach_type=BPF_NETKIT_PRIMARY, query_flags=0, attach_flags=0, prog_ids=NULL, prog_cnt=0}}, 64) = -1 ENXIO (No such device or address)
write(2, "Error: ", 7Error: )                  = 7
write(2, "can't query bpf programs attache"..., 90can't query bpf programs attached to /sys/fs/cgroup/init.scope/: No such device or address) = 90
qmonnet commented 4 months ago

Thanks for the report!

This should be fixed with https://patchwork.kernel.org/project/netdevbpf/patch/20240607111704.6716-1-tadakentaso@gmail.com/, not merged yet

qmonnet commented 4 months ago

Alexei just merged it, it will land in this repo at the next sync.