Message ID | 20190415071536.19287-2-bpoirier@suse.com |
---|---|
State | Accepted |
Delegated to: | BPF Maintainers |
Headers | show |
Series | [v3,bpf-next,1/2] bpftool: Use print_entry_error() in case of ENOENT when dumping | expand |
2019-04-15 16:15 UTC+0900 ~ Benjamin Poirier <bpoirier@suse.com> > 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: Benjamin Poirier <bpoirier@suse.com> > --- > tools/bpf/bpftool/map.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c > index df958af56b6c..44b192e87708 100644 > --- a/tools/bpf/bpftool/map.c > +++ b/tools/bpf/bpftool/map.c > @@ -719,6 +719,9 @@ static int dump_map_elem(int fd, void *key, void *value, > > if (errno == ENOENT) > 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, > msg ? : strerror(lookup_errno)); > @@ -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) { > err = bpf_map_get_next_key(fd, prev_key, key); > if (err) { > All good for me now, thanks a lot! Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
On Mon, 15 Apr 2019 16:15:36 +0900, Benjamin Poirier wrote: > 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: Benjamin Poirier <bpoirier@suse.com> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com> Thank you!!
diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c index df958af56b6c..44b192e87708 100644 --- a/tools/bpf/bpftool/map.c +++ b/tools/bpf/bpftool/map.c @@ -719,6 +719,9 @@ static int dump_map_elem(int fd, void *key, void *value, if (errno == ENOENT) 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, msg ? : strerror(lookup_errno)); @@ -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) { err = bpf_map_get_next_key(fd, prev_key, key); if (err) {
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: Benjamin Poirier <bpoirier@suse.com> --- tools/bpf/bpftool/map.c | 7 +++++++ 1 file changed, 7 insertions(+)