mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-27 00:04:47 +08:00
06ec0e2c49
ef99b02b23
("libbpf: capture value in BTF type info for BTF-defined map defs") changed BTF-defined maps syntax, while independently merged1e8611bbdf
("selftests/bpf: add kprobe/uprobe selftests") added new test using outdated syntax of maps. This patch fixes this test after corresponding patch sets were merged. Fixes:ef99b02b23
("libbpf: capture value in BTF type info for BTF-defined map defs") Fixes:1e8611bbdf
("selftests/bpf: add kprobe/uprobe selftests") Signed-off-by: Andrii Nakryiko <andriin@fb.com> Acked-by: Yonghong Song <yhs@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
53 lines
1.0 KiB
C
53 lines
1.0 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
// Copyright (c) 2017 Facebook
|
|
|
|
#include <linux/ptrace.h>
|
|
#include <linux/bpf.h>
|
|
#include "bpf_helpers.h"
|
|
|
|
struct {
|
|
__uint(type, BPF_MAP_TYPE_ARRAY);
|
|
__uint(max_entries, 4);
|
|
__type(key, int);
|
|
__type(value, int);
|
|
} results_map SEC(".maps");
|
|
|
|
SEC("kprobe/sys_nanosleep")
|
|
int handle_sys_nanosleep_entry(struct pt_regs *ctx)
|
|
{
|
|
const int key = 0, value = 1;
|
|
|
|
bpf_map_update_elem(&results_map, &key, &value, 0);
|
|
return 0;
|
|
}
|
|
|
|
SEC("kretprobe/sys_nanosleep")
|
|
int handle_sys_getpid_return(struct pt_regs *ctx)
|
|
{
|
|
const int key = 1, value = 2;
|
|
|
|
bpf_map_update_elem(&results_map, &key, &value, 0);
|
|
return 0;
|
|
}
|
|
|
|
SEC("uprobe/trigger_func")
|
|
int handle_uprobe_entry(struct pt_regs *ctx)
|
|
{
|
|
const int key = 2, value = 3;
|
|
|
|
bpf_map_update_elem(&results_map, &key, &value, 0);
|
|
return 0;
|
|
}
|
|
|
|
SEC("uretprobe/trigger_func")
|
|
int handle_uprobe_return(struct pt_regs *ctx)
|
|
{
|
|
const int key = 3, value = 4;
|
|
|
|
bpf_map_update_elem(&results_map, &key, &value, 0);
|
|
return 0;
|
|
}
|
|
|
|
char _license[] SEC("license") = "GPL";
|
|
__u32 _version SEC("version") = 1;
|