FILE
uprobe_multi_session_cookie.c
File preview with syntax highlighting.
linux-6.19.14/tools/testing/selftests/bpf/progs/uprobe_multi_session_cookie.c
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 8char _license[] SEC("license") = "GPL"; 9 10int pid = 0; 11 12__u64 test_uprobe_1_result = 0; 13__u64 test_uprobe_2_result = 0; 14__u64 test_uprobe_3_result = 0; 15 16static int check_cookie(__u64 val, __u64 *result) 17{ 18 __u64 *cookie; 19 20 if (bpf_get_current_pid_tgid() >> 32 != pid) 21 return 1; 22 23 cookie = bpf_session_cookie(); 24 25 if (bpf_session_is_return()) 26 *result = *cookie == val ? val : 0; 27 else 28 *cookie = val; 29 return 0; 30} 31 32SEC("uprobe.session//proc/self/exe:uprobe_multi_func_1") 33int uprobe_1(struct pt_regs *ctx) 34{ 35 return check_cookie(1, &test_uprobe_1_result); 36} 37 38SEC("uprobe.session//proc/self/exe:uprobe_multi_func_2") 39int uprobe_2(struct pt_regs *ctx) 40{ 41 return check_cookie(2, &test_uprobe_2_result); 42} 43 44SEC("uprobe.session//proc/self/exe:uprobe_multi_func_3") 45int uprobe_3(struct pt_regs *ctx) 46{ 47 return check_cookie(3, &test_uprobe_3_result); 48}
~/
Read-only file preview.