Re: [PATCH bpf-next 2/2] selftests/bpf: Test bpf_for_each_map_elem on BPF_MAP_TYPE_HASH_OF_MAPS

Alexei Starovoitov
2023-06-05T22:07:36Z

On Mon, Jun 5, 2023 at 1:05 PM David Vernet <void@manifault.com> wrote:
>
> +
> +static __u64 set_invoked(struct bpf_map *map, __u64 *key, __u64 *val, struct callback_ctx *ctx)
> +{
> + struct bpf_map *inner_map;
> +
> + ctx->invoked = true;
> + inner_map = bpf_map_lookup_elem(map, key);
> + if (!inner_map) {
> + ctx->failed = true;
> + return 1;
> + }

This doesn't look right. 'val' is not 'u64 *'.
It probably should be 'struct bpf_map *',
so lookup shouldn't be necessary.

map_set_for_each_callback_args() just sets it to PTR_TO_MAP_VALUE.
It probably should be CONST_PTR_TO_MAP.
Also for normal hash map for_each_elem 'val' is writeable.
It shouldn't be in this case.
So to cleanly support iterating hash_of_maps patch 1 needs more work.