1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 #define __PERF_EVENT_INSNS__ \
28 BPF_MOV64_IMM(BPF_REG_2, 5), \
29 BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_2, -8), \
30 BPF_MOV64_REG(BPF_REG_4, BPF_REG_10), \
31 BPF_ALU64_IMM(BPF_ADD, BPF_REG_4, -8), \
32 BPF_LD_MAP_FD(BPF_REG_2, 0), \
33 BPF_MOV64_IMM(BPF_REG_3, 0), \
34 BPF_MOV64_IMM(BPF_REG_5, 8), \
35 BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, \
36 BPF_FUNC_perf_event_output), \
37 BPF_MOV64_IMM(BPF_REG_0, 1), \
38 BPF_EXIT_INSN(),
39 {
40 "perfevent for sockops",
41 .insns = { __PERF_EVENT_INSNS__ },
42 .prog_type = BPF_PROG_TYPE_SOCK_OPS,
43 .fixup_map_event_output = { 4 },
44 .result = ACCEPT,
45 .retval = 1,
46 },
47 {
48 "perfevent for tc",
49 .insns = { __PERF_EVENT_INSNS__ },
50 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
51 .fixup_map_event_output = { 4 },
52 .result = ACCEPT,
53 .retval = 1,
54 },
55 {
56 "perfevent for lwt out",
57 .insns = { __PERF_EVENT_INSNS__ },
58 .prog_type = BPF_PROG_TYPE_LWT_OUT,
59 .fixup_map_event_output = { 4 },
60 .result = ACCEPT,
61 .retval = 1,
62 },
63 {
64 "perfevent for xdp",
65 .insns = { __PERF_EVENT_INSNS__ },
66 .prog_type = BPF_PROG_TYPE_XDP,
67 .fixup_map_event_output = { 4 },
68 .result = ACCEPT,
69 .retval = 1,
70 },
71 {
72 "perfevent for socket filter",
73 .insns = { __PERF_EVENT_INSNS__ },
74 .prog_type = BPF_PROG_TYPE_SOCKET_FILTER,
75 .fixup_map_event_output = { 4 },
76 .result = ACCEPT,
77 .retval = 1,
78 },
79 {
80 "perfevent for sk_skb",
81 .insns = { __PERF_EVENT_INSNS__ },
82 .prog_type = BPF_PROG_TYPE_SK_SKB,
83 .fixup_map_event_output = { 4 },
84 .result = ACCEPT,
85 .retval = 1,
86 },
87 {
88 "perfevent for cgroup skb",
89 .insns = { __PERF_EVENT_INSNS__ },
90 .prog_type = BPF_PROG_TYPE_CGROUP_SKB,
91 .fixup_map_event_output = { 4 },
92 .result = ACCEPT,
93 .retval = 1,
94 },