Commit aee65746 authored by Daniel Borkmann's avatar Daniel Borkmann

Merge branch 'bpf-bpftool-various-fixes'

Jakub Kicinski says:

====================
Two small fixes here to listing maps and programs.  The loop for showing
maps is written slightly differently to programs which was missed in JSON
output support, and output would be broken if any of the system calls
failed.  Second fix is in very unlikely case that program or map disappears
after we get its ID we should just skip over that object instead of failing.
====================
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parents cd95a892 8207c6dd
...@@ -523,21 +523,23 @@ static int do_show(int argc, char **argv) ...@@ -523,21 +523,23 @@ static int do_show(int argc, char **argv)
break; break;
p_err("can't get next map: %s%s", strerror(errno), p_err("can't get next map: %s%s", strerror(errno),
errno == EINVAL ? " -- kernel too old?" : ""); errno == EINVAL ? " -- kernel too old?" : "");
return -1; break;
} }
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));
return -1; break;
} }
err = bpf_obj_get_info_by_fd(fd, &info, &len); err = bpf_obj_get_info_by_fd(fd, &info, &len);
if (err) { if (err) {
p_err("can't get map info: %s", strerror(errno)); p_err("can't get map info: %s", strerror(errno));
close(fd); close(fd);
return -1; break;
} }
if (json_output) if (json_output)
......
...@@ -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%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment