bpf: Print error message for bpftool cgroup show
authorHechao Li <hechaol@fb.com>
Tue, 24 Dec 2019 01:17:42 +0000 (17:17 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Feb 2020 07:36:40 +0000 (08:36 +0100)
commit4783bf08f8d24bd4b36ec4328dd173ccbb0ef5b2
tree2f4fe624dcd7c2270ea9c97a7143a29c9090a9bd
parent8a7aa4feeaeabc12181e1997a298eb73d2ed2d65
bpf: Print error message for bpftool cgroup show

[ Upstream commit 1162f844030ac1ac7321b5e8f6c9badc7a11428f ]

Currently, when bpftool cgroup show <path> has an error, no error
message is printed. This is confusing because the user may think the
result is empty.

Before the change:

$ bpftool cgroup show /sys/fs/cgroup
ID       AttachType      AttachFlags     Name
$ echo $?
255

After the change:
$ ./bpftool cgroup show /sys/fs/cgroup
Error: can't query bpf programs attached to /sys/fs/cgroup: Operation
not permitted

v2: Rename check_query_cgroup_progs to cgroup_has_attached_progs

Signed-off-by: Hechao Li <hechaol@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20191224011742.3714301-1-hechaol@fb.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/bpf/bpftool/cgroup.c