Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright (c) 2018 Facebook */
0003 #include <linux/bpf.h>
0004 #include <bpf/bpf_helpers.h>
0005 
0006 struct ipv_counts {
0007     unsigned int v4;
0008     unsigned int v6;
0009 };
0010 
0011 struct {
0012     __uint(type, BPF_MAP_TYPE_ARRAY);
0013     __uint(key_size, sizeof(int));
0014     __uint(value_size, sizeof(struct ipv_counts));
0015     __uint(max_entries, 4);
0016 } btf_map SEC(".maps");
0017 
0018 __attribute__((noinline))
0019 int test_long_fname_2(void)
0020 {
0021     struct ipv_counts *counts;
0022     int key = 0;
0023 
0024     counts = bpf_map_lookup_elem(&btf_map, &key);
0025     if (!counts)
0026         return 0;
0027 
0028     counts->v6++;
0029 
0030     return 0;
0031 }
0032 
0033 __attribute__((noinline))
0034 int test_long_fname_1(void)
0035 {
0036     return test_long_fname_2();
0037 }
0038 
0039 SEC("dummy_tracepoint")
0040 int _dummy_tracepoint(void *arg)
0041 {
0042     return test_long_fname_1();
0043 }
0044 
0045 char _license[] SEC("license") = "GPL";