Skip to content

Commit

Permalink
bpftool: Mount bpffs when pinmaps path not under the bpffs
Browse files Browse the repository at this point in the history
[ Upstream commit da5f8fd ]

As Quentin said [0], BPF map pinning will fail if the pinmaps path is not
under the bpffs, like:

  libbpf: specified path /home/ubuntu/test/sock_ops_map is not on BPF FS
  Error: failed to pin all maps

  [0] libbpf/bpftool#146

Fixes: 3767a94 ("bpftool: add pinmaps argument to the load/loadall")
Signed-off-by: Tao Chen <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Tested-by: Quentin Monnet <[email protected]>
Reviewed-by: Quentin Monnet <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
chentao-kernel authored and Sasha Levin committed Aug 12, 2024
1 parent 1411aeb commit 19b5bc5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tools/bpf/bpftool/prog.c
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,10 @@ static int load_with_options(int argc, char **argv, bool first_prog_only)
}

if (pinmaps) {
err = create_and_mount_bpffs_dir(pinmaps);
if (err)
goto err_unpin;

err = bpf_object__pin_maps(obj, pinmaps);
if (err) {
p_err("failed to pin all maps");
Expand Down

0 comments on commit 19b5bc5

Please sign in to comment.