]> git.baikalelectronics.ru Git - kernel.git/commit
tools: bpftool: reset errno for "bpftool cgroup tree"
authorQuentin Monnet <quentin.monnet@netronome.com>
Fri, 12 Apr 2019 13:29:35 +0000 (14:29 +0100)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 16 Apr 2019 08:13:21 +0000 (10:13 +0200)
commit38825a72a9ab63aca4687d919644a5848f78e335
treeb318904a88052a611c234269b6b7dc3176ef34f7
parent1da5798e010124afa354af185d80e4f0d2353134
tools: bpftool: reset errno for "bpftool cgroup tree"

When trying to dump the tree of all cgroups under a given root node,
bpftool attempts to query programs of all available attach types. Some
of those attach types do not support queries, therefore several of the
calls are actually expected to fail.

Those calls set errno to EINVAL, which has no consequence for dumping
the rest of the tree. It does have consequences however if errno is
inspected at a later time. For example, bpftool batch mode relies on
errno to determine whether a command has succeeded, and whether it
should carry on with the next command. Setting errno to EINVAL when
everything worked as expected would therefore make such command fail:

        # echo 'cgroup tree \n net show' | \
                bpftool batch file -

To improve this, reset errno when its value is EINVAL after attempting
to show programs for all existing attach types in do_show_tree_fn().

Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/bpf/bpftool/cgroup.c