]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit - tools/bpf/bpftool/common.c
tools: bpftool: try to mount bpffs if required for pinning objects
authorQuentin Monnet <quentin.monnet@netronome.com>
Wed, 25 Oct 2017 03:11:28 +0000 (20:11 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 26 Oct 2017 08:52:59 +0000 (17:52 +0900)
commit3fc27b71b894f5e2ad611297d5817b6092c96626
tree874ab256c51d7e7372d05a4a81f5eed6c85eb5a6
parente233df01576bba9f5bafacccd571353b72152bd5
tools: bpftool: try to mount bpffs if required for pinning objects

One possible cause of failure for `bpftool {prog|map} pin * file FILE`
is the FILE not being in an eBPF virtual file system (bpffs). In this
case, make bpftool attempt to mount bpffs on the parent directory of the
FILE. Then, if this operation is successful, try again to pin the
object.

The code for mnt_bpffs() is a copy of function bpf_mnt_fs() from
iproute2 package (under lib/bpf.c, taken at commit 4b73d52f8a81), with
modifications regarding handling of error messages.

Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/bpf/bpftool/common.c
tools/bpf/bpftool/main.h