]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
bpftool: Mount bpffs when pinmaps path not under the bpffs
authorTao Chen <chen.dylane@gmail.com>
Tue, 2 Jul 2024 13:11:50 +0000 (21:11 +0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 2 Jul 2024 16:20:32 +0000 (18:20 +0200)
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] https://github.com/libbpf/bpftool/issues/146

Fixes: 3767a94b3253 ("bpftool: add pinmaps argument to the load/loadall")
Signed-off-by: Tao Chen <chen.dylane@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Quentin Monnet <qmo@kernel.org>
Reviewed-by: Quentin Monnet <qmo@kernel.org>
Link: https://lore.kernel.org/bpf/20240702131150.15622-1-chen.dylane@gmail.com
tools/bpf/bpftool/prog.c

index 1a501cf09e782b7b5f1a369badf99d7087fe580f..40ea743d139fd226cceac1878f6dcd383a781957 100644 (file)
@@ -1813,6 +1813,10 @@ offload_dev:
        }
 
        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");