mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-02 04:24:05 +00:00
libbpf: add bpf_raw_tracepoint_open helper
add bpf_raw_tracepoint_open(const char *name, int prog_fd) api to libbpf Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
parent
c4f6699dfc
commit
a0fe3e574b
3 changed files with 23 additions and 0 deletions
|
@ -94,6 +94,7 @@ enum bpf_cmd {
|
||||||
BPF_MAP_GET_FD_BY_ID,
|
BPF_MAP_GET_FD_BY_ID,
|
||||||
BPF_OBJ_GET_INFO_BY_FD,
|
BPF_OBJ_GET_INFO_BY_FD,
|
||||||
BPF_PROG_QUERY,
|
BPF_PROG_QUERY,
|
||||||
|
BPF_RAW_TRACEPOINT_OPEN,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum bpf_map_type {
|
enum bpf_map_type {
|
||||||
|
@ -134,6 +135,7 @@ enum bpf_prog_type {
|
||||||
BPF_PROG_TYPE_SK_SKB,
|
BPF_PROG_TYPE_SK_SKB,
|
||||||
BPF_PROG_TYPE_CGROUP_DEVICE,
|
BPF_PROG_TYPE_CGROUP_DEVICE,
|
||||||
BPF_PROG_TYPE_SK_MSG,
|
BPF_PROG_TYPE_SK_MSG,
|
||||||
|
BPF_PROG_TYPE_RAW_TRACEPOINT,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum bpf_attach_type {
|
enum bpf_attach_type {
|
||||||
|
@ -344,6 +346,11 @@ union bpf_attr {
|
||||||
__aligned_u64 prog_ids;
|
__aligned_u64 prog_ids;
|
||||||
__u32 prog_cnt;
|
__u32 prog_cnt;
|
||||||
} query;
|
} query;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
__u64 name;
|
||||||
|
__u32 prog_fd;
|
||||||
|
} raw_tracepoint;
|
||||||
} __attribute__((aligned(8)));
|
} __attribute__((aligned(8)));
|
||||||
|
|
||||||
/* BPF helper function descriptions:
|
/* BPF helper function descriptions:
|
||||||
|
@ -1151,4 +1158,8 @@ struct bpf_cgroup_dev_ctx {
|
||||||
__u32 minor;
|
__u32 minor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct bpf_raw_tracepoint_args {
|
||||||
|
__u64 args[0];
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* _UAPI__LINUX_BPF_H__ */
|
#endif /* _UAPI__LINUX_BPF_H__ */
|
||||||
|
|
|
@ -428,6 +428,17 @@ int bpf_obj_get_info_by_fd(int prog_fd, void *info, __u32 *info_len)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int bpf_raw_tracepoint_open(const char *name, int prog_fd)
|
||||||
|
{
|
||||||
|
union bpf_attr attr;
|
||||||
|
|
||||||
|
bzero(&attr, sizeof(attr));
|
||||||
|
attr.raw_tracepoint.name = ptr_to_u64(name);
|
||||||
|
attr.raw_tracepoint.prog_fd = prog_fd;
|
||||||
|
|
||||||
|
return sys_bpf(BPF_RAW_TRACEPOINT_OPEN, &attr, sizeof(attr));
|
||||||
|
}
|
||||||
|
|
||||||
int bpf_set_link_xdp_fd(int ifindex, int fd, __u32 flags)
|
int bpf_set_link_xdp_fd(int ifindex, int fd, __u32 flags)
|
||||||
{
|
{
|
||||||
struct sockaddr_nl sa;
|
struct sockaddr_nl sa;
|
||||||
|
|
|
@ -79,4 +79,5 @@ int bpf_map_get_fd_by_id(__u32 id);
|
||||||
int bpf_obj_get_info_by_fd(int prog_fd, void *info, __u32 *info_len);
|
int bpf_obj_get_info_by_fd(int prog_fd, void *info, __u32 *info_len);
|
||||||
int bpf_prog_query(int target_fd, enum bpf_attach_type type, __u32 query_flags,
|
int bpf_prog_query(int target_fd, enum bpf_attach_type type, __u32 query_flags,
|
||||||
__u32 *attach_flags, __u32 *prog_ids, __u32 *prog_cnt);
|
__u32 *attach_flags, __u32 *prog_ids, __u32 *prog_cnt);
|
||||||
|
int bpf_raw_tracepoint_open(const char *name, int prog_fd);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue