Linux Audio

Check our new training course

Loading...
Note: File does not exist in v6.8.
 1// SPDX-License-Identifier: GPL-2.0
 2#include <linux/bpf.h>
 3#include <bpf/bpf_helpers.h>
 4#include <bpf/bpf_tracing.h>
 5#include <stdbool.h>
 6#include "bpf_kfuncs.h"
 7#include "bpf_misc.h"
 8
 9char _license[] SEC("license") = "GPL";
10
11__u64 uprobe_session_result[3] = {};
12int pid = 0;
13
14static int uprobe_multi_check(void *ctx, int idx)
15{
16	if (bpf_get_current_pid_tgid() >> 32 != pid)
17		return 1;
18
19	uprobe_session_result[idx]++;
20
21	/* only consumer 1 executes return probe */
22	if (idx == 0 || idx == 2)
23		return 1;
24
25	return 0;
26}
27
28SEC("uprobe.session//proc/self/exe:uprobe_multi_func_1")
29int uprobe_0(struct pt_regs *ctx)
30{
31	return uprobe_multi_check(ctx, 0);
32}
33
34SEC("uprobe.session//proc/self/exe:uprobe_multi_func_1")
35int uprobe_1(struct pt_regs *ctx)
36{
37	return uprobe_multi_check(ctx, 1);
38}
39
40SEC("uprobe.session//proc/self/exe:uprobe_multi_func_1")
41int uprobe_2(struct pt_regs *ctx)
42{
43	return uprobe_multi_check(ctx, 2);
44}