WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / bpf / progs / bpf_iter_test_kern5.c
blobe3a7575e81d2c67f0295a4219357aeb6cdbed1ae
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2020 Facebook */
3 #include "bpf_iter.h"
4 #include <bpf/bpf_helpers.h>
5 #include <bpf/bpf_tracing.h>
7 char _license[] SEC("license") = "GPL";
9 struct key_t {
10 int a;
11 int b;
12 int c;
15 struct {
16 __uint(type, BPF_MAP_TYPE_HASH);
17 __uint(max_entries, 3);
18 __type(key, struct key_t);
19 __type(value, __u64);
20 } hashmap1 SEC(".maps");
22 __u32 key_sum = 0;
24 SEC("iter/bpf_map_elem")
25 int dump_bpf_hash_map(struct bpf_iter__bpf_map_elem *ctx)
27 void *key = ctx->key;
29 if (key == (void *)0)
30 return 0;
32 /* out of bound access w.r.t. hashmap1 */
33 key_sum += *(__u32 *)(key + sizeof(struct key_t));
34 return 0;