提交 8207c6dd 编写于 作者: J Jakub Kicinski 提交者: Daniel Borkmann

tools: bpftool: protect against races with disappearing objects

On program/map show we may get an ID of an object from GETNEXT,
but the object may disappear before we call GET_FD_BY_ID.  If
that happens, ignore the object and continue.

Fixes: 71bb428f ("tools: bpf: add bpftool")
Signed-off-by: NJakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: NQuentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
上级 b3b1b653
...@@ -528,6 +528,8 @@ static int do_show(int argc, char **argv) ...@@ -528,6 +528,8 @@ static int do_show(int argc, char **argv)
fd = bpf_map_get_fd_by_id(id); fd = bpf_map_get_fd_by_id(id);
if (fd < 0) { if (fd < 0) {
if (errno == ENOENT)
continue;
p_err("can't get map by id (%u): %s", p_err("can't get map by id (%u): %s",
id, strerror(errno)); id, strerror(errno));
break; break;
......
...@@ -382,6 +382,8 @@ static int do_show(int argc, char **argv) ...@@ -382,6 +382,8 @@ static int do_show(int argc, char **argv)
fd = bpf_prog_get_fd_by_id(id); fd = bpf_prog_get_fd_by_id(id);
if (fd < 0) { if (fd < 0) {
if (errno == ENOENT)
continue;
p_err("can't get prog by id (%u): %s", p_err("can't get prog by id (%u): %s",
id, strerror(errno)); id, strerror(errno));
err = -1; err = -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册