blob: 8c7ca096ecf2e76bf35c0de30133c66edd19339a [file] [log] [blame]
Martin KaFai Lauc0fa1b62018-04-18 15:56:06 -07001/* SPDX-License-Identifier: GPL-2.0 */
2/* Copyright (c) 2018 Facebook */
3#include <linux/bpf.h>
4#include "bpf_helpers.h"
5
6int _version SEC("version") = 1;
7
8struct ipv_counts {
9 unsigned int v4;
10 unsigned int v6;
11};
12
13typedef int btf_map_key;
14typedef struct ipv_counts btf_map_value;
15btf_map_key dumm_key;
16btf_map_value dummy_value;
17
18struct bpf_map_def SEC("maps") btf_map = {
19 .type = BPF_MAP_TYPE_ARRAY,
20 .key_size = sizeof(int),
21 .value_size = sizeof(struct ipv_counts),
22 .max_entries = 4,
23};
24
25struct dummy_tracepoint_args {
26 unsigned long long pad;
27 struct sock *sock;
28};
29
30SEC("dummy_tracepoint")
31int _dummy_tracepoint(struct dummy_tracepoint_args *arg)
32{
33 struct ipv_counts *counts;
34 int key = 0;
35
36 if (!arg->sock)
37 return 0;
38
39 counts = bpf_map_lookup_elem(&btf_map, &key);
40 if (!counts)
41 return 0;
42
43 counts->v6++;
44
45 return 0;
46}
47
48char _license[] SEC("license") = "GPL";