lkml.org 
[lkml]   [2019]   [Apr]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] bpf: do not start from first bucket if elem is not found on a htab
> This breaks BPF selftest suite unfortunately:
>
> # ./test_maps
> test_maps: test_maps.c:114: test_hashmap: Assertion `bpf_map_get_next_key(fd, &key, &next_key) == 0 && (next_key == first_key)' failed.
> Aborted
>
> Some more background, situation is a bit tricky: pre 8fe45924387b ("bpf:
> map_get_next_key to return first key on NULL") there was no reliable way
> of getting to the start of a hash table, meaning it needed an 'invalid'
> key to return the first element for starting traversal which commit fixed
> by being able to pass in NULL. So some applications might still just rely
> on e.g. key of zero bytes (if guaranteed to not be used otherwise) to do
> just that. With this patch, we'd start out from anywhere in the hash table.

sdf@ just mentioned this internally as well... I think we simply will
need to add a flags field
with at least two options/flags:
- return error if key not found
- resume from bucket instead of beginning if key not found
and while we're at it:
- return concatenated key+value instead of just key to save an
immediate lookup on the returned key

\
 
 \ /
  Last update: 2019-04-01 23:38    [W:0.036 / U:7.456 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site