WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / bpf / progs / test_btf_haskv.c
blob31538c9ed1939ca5360d0052086534720de8f67d
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2018 Facebook */
3 #include <linux/bpf.h>
4 #include <bpf/bpf_helpers.h>
5 #include "bpf_legacy.h"
7 int _version SEC("version") = 1;
9 struct ipv_counts {
10 unsigned int v4;
11 unsigned int v6;
14 struct bpf_map_def SEC("maps") btf_map = {
15 .type = BPF_MAP_TYPE_ARRAY,
16 .key_size = sizeof(int),
17 .value_size = sizeof(struct ipv_counts),
18 .max_entries = 4,
21 BPF_ANNOTATE_KV_PAIR(btf_map, int, struct ipv_counts);
23 __attribute__((noinline))
24 int test_long_fname_2(void)
26 struct ipv_counts *counts;
27 int key = 0;
29 counts = bpf_map_lookup_elem(&btf_map, &key);
30 if (!counts)
31 return 0;
33 counts->v6++;
35 return 0;
38 __attribute__((noinline))
39 int test_long_fname_1(void)
41 return test_long_fname_2();
44 SEC("dummy_tracepoint")
45 int _dummy_tracepoint(void *arg)
47 return test_long_fname_1();
50 char _license[] SEC("license") = "GPL";