diff options
Diffstat (limited to 'kernel/bpf/stackmap.c')
-rw-r--r-- | kernel/bpf/stackmap.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c index a15bc636cc98..6c63c2222ea8 100644 --- a/kernel/bpf/stackmap.c +++ b/kernel/bpf/stackmap.c | |||
@@ -226,9 +226,33 @@ int bpf_stackmap_copy(struct bpf_map *map, void *key, void *value) | |||
226 | return 0; | 226 | return 0; |
227 | } | 227 | } |
228 | 228 | ||
229 | static int stack_map_get_next_key(struct bpf_map *map, void *key, void *next_key) | 229 | static int stack_map_get_next_key(struct bpf_map *map, void *key, |
230 | void *next_key) | ||
230 | { | 231 | { |
231 | return -EINVAL; | 232 | struct bpf_stack_map *smap = container_of(map, |
233 | struct bpf_stack_map, map); | ||
234 | u32 id; | ||
235 | |||
236 | WARN_ON_ONCE(!rcu_read_lock_held()); | ||
237 | |||
238 | if (!key) { | ||
239 | id = 0; | ||
240 | } else { | ||
241 | id = *(u32 *)key; | ||
242 | if (id >= smap->n_buckets || !smap->buckets[id]) | ||
243 | id = 0; | ||
244 | else | ||
245 | id++; | ||
246 | } | ||
247 | |||
248 | while (id < smap->n_buckets && !smap->buckets[id]) | ||
249 | id++; | ||
250 | |||
251 | if (id >= smap->n_buckets) | ||
252 | return -ENOENT; | ||
253 | |||
254 | *(u32 *)next_key = id; | ||
255 | return 0; | ||
232 | } | 256 | } |
233 | 257 | ||
234 | static int stack_map_update_elem(struct bpf_map *map, void *key, void *value, | 258 | static int stack_map_update_elem(struct bpf_map *map, void *key, void *value, |