diff options
| author | Dmitry Torokhov <[email protected]> | 2021-05-04 11:46:00 -0700 |
|---|---|---|
| committer | Dmitry Torokhov <[email protected]> | 2021-05-04 11:46:00 -0700 |
| commit | d0034a7a4ac7fae708146ac0059b9c47a1543f0d (patch) | |
| tree | ac3ac88066f0f80632aa754e3ae008994f2426a2 /tools/testing/selftests/bpf/progs/recursion.c | |
| parent | 56cfe6f820a6315291eb5a1b82bb49633b993d3b (diff) | |
| parent | d12b64b9764ea17554fb230784ebf91287ed807e (diff) | |
Merge branch 'next' into for-linus
Prepare input updates for 5.13 merge window.
Diffstat (limited to 'tools/testing/selftests/bpf/progs/recursion.c')
| -rw-r--r-- | tools/testing/selftests/bpf/progs/recursion.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/recursion.c b/tools/testing/selftests/bpf/progs/recursion.c new file mode 100644 index 000000000000..49f679375b9d --- /dev/null +++ b/tools/testing/selftests/bpf/progs/recursion.c @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2021 Facebook */ + +#include "vmlinux.h" +#include <bpf/bpf_helpers.h> +#include <bpf/bpf_tracing.h> + +char _license[] SEC("license") = "GPL"; + +struct { + __uint(type, BPF_MAP_TYPE_HASH); + __uint(max_entries, 1); + __type(key, int); + __type(value, long); +} hash1 SEC(".maps"); + +struct { + __uint(type, BPF_MAP_TYPE_HASH); + __uint(max_entries, 1); + __type(key, int); + __type(value, long); +} hash2 SEC(".maps"); + +int pass1 = 0; +int pass2 = 0; + +SEC("fentry/__htab_map_lookup_elem") +int BPF_PROG(on_lookup, struct bpf_map *map) +{ + int key = 0; + + if (map == (void *)&hash1) { + pass1++; + return 0; + } + if (map == (void *)&hash2) { + pass2++; + /* htab_map_gen_lookup() will inline below call + * into direct call to __htab_map_lookup_elem() + */ + bpf_map_lookup_elem(&hash2, &key); + return 0; + } + + return 0; +} |