Commit 3da6e7e4 authored by Benjamin Poirier's avatar Benjamin Poirier Committed by Daniel Borkmann

bpftool: Improve handling of ENOSPC on reuseport_array map dumps

avoids outputting a series of
	value:
	No space left on device

The value itself is not wrong but bpf_fd_reuseport_array_lookup_elem() can
only return it if the map was created with value_size = 8. There's nothing
bpftool can do about it. Instead of repeating this error for every key in
the map, print an explanatory warning and a specialized error.

example before:
key: 00 00 00 00
value:
No space left on device
key: 01 00 00 00
value:
No space left on device
key: 02 00 00 00
value:
No space left on device
Found 0 elements

example after:
Warning: cannot read values from reuseport_sockarray map with value_size != 8
key: 00 00 00 00  value: <cannot read>
key: 01 00 00 00  value: <cannot read>
key: 02 00 00 00  value: <cannot read>
Found 0 elements
Signed-off-by: default avatarBenjamin Poirier <bpoirier@suse.com>
Reviewed-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent 0478c3bf
...@@ -719,6 +719,9 @@ static int dump_map_elem(int fd, void *key, void *value, ...@@ -719,6 +719,9 @@ static int dump_map_elem(int fd, void *key, void *value,
if (errno == ENOENT) if (errno == ENOENT)
msg = "<no entry>"; msg = "<no entry>";
else if (lookup_errno == ENOSPC &&
map_info->type == BPF_MAP_TYPE_REUSEPORT_SOCKARRAY)
msg = "<cannot read>";
print_entry_error(map_info, key, print_entry_error(map_info, key,
msg ? : strerror(lookup_errno)); msg ? : strerror(lookup_errno));
...@@ -775,6 +778,10 @@ static int do_dump(int argc, char **argv) ...@@ -775,6 +778,10 @@ static int do_dump(int argc, char **argv)
} }
} }
if (info.type == BPF_MAP_TYPE_REUSEPORT_SOCKARRAY &&
info.value_size != 8)
p_info("Warning: cannot read values from %s map with value_size != 8",
map_type_name[info.type]);
while (true) { while (true) {
err = bpf_map_get_next_key(fd, prev_key, key); err = bpf_map_get_next_key(fd, prev_key, key);
if (err) { if (err) {
......
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