OSDN Git Service

libbpf: Print hint about ulimit when getting permission denied error
authorToke Høiland-Jørgensen <toke@redhat.com>
Mon, 16 Dec 2019 18:12:04 +0000 (19:12 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 16 Dec 2019 22:52:34 +0000 (14:52 -0800)
commitdc3a2d254782dea8e23a55f46129105ecfe787fb
tree88c4ce73c2fcd58091deac7c297084bdd64a1d81
parentd50ecc46d18fa19ccf06e0c4d2ee8a050c665e3d
libbpf: Print hint about ulimit when getting permission denied error

Probably the single most common error newcomers to XDP are stumped by is
the 'permission denied' error they get when trying to load their program
and 'ulimit -l' is set too low. For examples, see [0], [1].

Since the error code is UAPI, we can't change that. Instead, this patch
adds a few heuristics in libbpf and outputs an additional hint if they are
met: If an EPERM is returned on map create or program load, and geteuid()
shows we are root, and the current RLIMIT_MEMLOCK is not infinity, we
output a hint about raising 'ulimit -l' as an additional log line.

[0] https://marc.info/?l=xdp-newbies&m=157043612505624&w=2
[1] https://github.com/xdp-project/xdp-tutorial/issues/86

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20191216181204.724953-1-toke@redhat.com
tools/lib/bpf/libbpf.c