diff options
author | Yonghong Song <yhs@fb.com> | 2019-05-16 13:17:31 -0400 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2019-05-16 14:44:50 -0400 |
commit | ac4e0e055fee5751c78bba1fc9ce508a6874d916 (patch) | |
tree | 5e1d1a8e3bc75cb07992a924142f457fea9aa861 /tools/bpf/bpftool/prog.c | |
parent | bca844a8c92502b2aa5bd50a9094eaf01a1710c0 (diff) |
tools/bpftool: move set_max_rlimit() before __bpf_object__open_xattr()
For a host which has a lower rlimit for max locked memory (e.g., 64KB),
the following error occurs in one of our production systems:
# /usr/sbin/bpftool prog load /paragon/pods/52877437/home/mark.o \
/sys/fs/bpf/paragon_mark_21 type cgroup/skb \
map idx 0 pinned /sys/fs/bpf/paragon_map_21
libbpf: Error in bpf_object__probe_name():Operation not permitted(1).
Couldn't load basic 'r0 = 0' BPF program.
Error: failed to open object file
The reason is due to low locked memory during bpf_object__probe_name()
which probes whether program name is supported in kernel or not
during __bpf_object__open_xattr().
bpftool program load already tries to relax mlock rlimit before
bpf_object__load(). Let us move set_max_rlimit() before
__bpf_object__open_xattr(), which fixed the issue here.
Fixes: 47eff61777c7 ("bpf, libbpf: introduce bpf_object__probe_caps to test BPF capabilities")
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/bpf/bpftool/prog.c')
-rw-r--r-- | tools/bpf/bpftool/prog.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index fc495b27f0fc..26336bad0442 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c | |||
@@ -879,6 +879,8 @@ static int load_with_options(int argc, char **argv, bool first_prog_only) | |||
879 | } | 879 | } |
880 | } | 880 | } |
881 | 881 | ||
882 | set_max_rlimit(); | ||
883 | |||
882 | obj = __bpf_object__open_xattr(&attr, bpf_flags); | 884 | obj = __bpf_object__open_xattr(&attr, bpf_flags); |
883 | if (IS_ERR_OR_NULL(obj)) { | 885 | if (IS_ERR_OR_NULL(obj)) { |
884 | p_err("failed to open object file"); | 886 | p_err("failed to open object file"); |
@@ -958,8 +960,6 @@ static int load_with_options(int argc, char **argv, bool first_prog_only) | |||
958 | goto err_close_obj; | 960 | goto err_close_obj; |
959 | } | 961 | } |
960 | 962 | ||
961 | set_max_rlimit(); | ||
962 | |||
963 | err = bpf_object__load(obj); | 963 | err = bpf_object__load(obj); |
964 | if (err) { | 964 | if (err) { |
965 | p_err("failed to load object file"); | 965 | p_err("failed to load object file"); |