#ifndef _LINUX_BTF_H
#define _LINUX_BTF_H …
#include <linux/types.h>
#include <linux/bpfptr.h>
#include <linux/bsearch.h>
#include <linux/btf_ids.h>
#include <uapi/linux/btf.h>
#include <uapi/linux/bpf.h>
#define BTF_TYPE_EMIT(type) …
#define BTF_TYPE_EMIT_ENUM(enum_val) …
#define KF_ACQUIRE …
#define KF_RELEASE …
#define KF_RET_NULL …
#define KF_TRUSTED_ARGS …
#define KF_SLEEPABLE …
#define KF_DESTRUCTIVE …
#define KF_RCU …
#define KF_ITER_NEW …
#define KF_ITER_NEXT …
#define KF_ITER_DESTROY …
#define KF_RCU_PROTECTED …
#define __bpf_kfunc …
#define __bpf_kfunc_start_defs() …
#define __bpf_kfunc_end_defs() …
#define __bpf_hook_start() …
#define __bpf_hook_end() …
#define stringify_struct(x) …
struct btf;
struct btf_member;
struct btf_type;
bpf_attr;
struct btf_show;
struct btf_id_set;
struct bpf_prog;
btf_kfunc_filter_t;
struct btf_kfunc_id_set { … };
struct btf_id_dtor_kfunc { … };
struct btf_struct_meta { … };
struct btf_struct_metas { … };
extern const struct file_operations btf_fops;
const char *btf_get_name(const struct btf *btf);
void btf_get(struct btf *btf);
void btf_put(struct btf *btf);
const struct btf_header *btf_header(const struct btf *btf);
int btf_new_fd(const union bpf_attr *attr, bpfptr_t uattr, u32 uattr_sz);
struct btf *btf_get_by_fd(int fd);
int btf_get_info_by_fd(const struct btf *btf,
const union bpf_attr *attr,
union bpf_attr __user *uattr);
const struct btf_type *btf_type_id_size(const struct btf *btf,
u32 *type_id,
u32 *ret_size);
#define BTF_SHOW_COMPACT …
#define BTF_SHOW_NONAME …
#define BTF_SHOW_PTR_RAW …
#define BTF_SHOW_ZERO …
#define BTF_SHOW_UNSAFE …
void btf_type_seq_show(const struct btf *btf, u32 type_id, void *obj,
struct seq_file *m);
int btf_type_seq_show_flags(const struct btf *btf, u32 type_id, void *obj,
struct seq_file *m, u64 flags);
int btf_type_snprintf_show(const struct btf *btf, u32 type_id, void *obj,
char *buf, int len, u64 flags);
int btf_get_fd_by_id(u32 id);
u32 btf_obj_id(const struct btf *btf);
bool btf_is_kernel(const struct btf *btf);
bool btf_is_module(const struct btf *btf);
bool btf_is_vmlinux(const struct btf *btf);
struct module *btf_try_get_module(const struct btf *btf);
u32 btf_nr_types(const struct btf *btf);
struct btf *btf_base_btf(const struct btf *btf);
bool btf_member_is_reg_int(const struct btf *btf, const struct btf_type *s,
const struct btf_member *m,
u32 expected_offset, u32 expected_size);
struct btf_record *btf_parse_fields(const struct btf *btf, const struct btf_type *t,
u32 field_mask, u32 value_size);
int btf_check_and_fixup_fields(const struct btf *btf, struct btf_record *rec);
bool btf_type_is_void(const struct btf_type *t);
s32 btf_find_by_name_kind(const struct btf *btf, const char *name, u8 kind);
s32 bpf_find_btf_id(const char *name, u32 kind, struct btf **btf_p);
const struct btf_type *btf_type_skip_modifiers(const struct btf *btf,
u32 id, u32 *res_id);
const struct btf_type *btf_type_resolve_ptr(const struct btf *btf,
u32 id, u32 *res_id);
const struct btf_type *btf_type_resolve_func_ptr(const struct btf *btf,
u32 id, u32 *res_id);
const struct btf_type *
btf_resolve_size(const struct btf *btf, const struct btf_type *type,
u32 *type_size);
const char *btf_type_str(const struct btf_type *t);
#define for_each_member(i, struct_type, member) …
#define for_each_vsi(i, datasec_type, member) …
static inline bool btf_type_is_ptr(const struct btf_type *t)
{ … }
static inline bool btf_type_is_int(const struct btf_type *t)
{ … }
static inline bool btf_type_is_small_int(const struct btf_type *t)
{ … }
static inline u8 btf_int_encoding(const struct btf_type *t)
{ … }
static inline bool btf_type_is_signed_int(const struct btf_type *t)
{ … }
static inline bool btf_type_is_enum(const struct btf_type *t)
{ … }
static inline bool btf_is_any_enum(const struct btf_type *t)
{ … }
static inline bool btf_kind_core_compat(const struct btf_type *t1,
const struct btf_type *t2)
{ … }
static inline bool str_is_empty(const char *s)
{ … }
static inline u16 btf_kind(const struct btf_type *t)
{ … }
static inline bool btf_is_enum(const struct btf_type *t)
{ … }
static inline bool btf_is_enum64(const struct btf_type *t)
{ … }
static inline u64 btf_enum64_value(const struct btf_enum64 *e)
{ … }
static inline bool btf_is_composite(const struct btf_type *t)
{ … }
static inline bool btf_is_array(const struct btf_type *t)
{ … }
static inline bool btf_is_int(const struct btf_type *t)
{ … }
static inline bool btf_is_ptr(const struct btf_type *t)
{ … }
static inline u8 btf_int_offset(const struct btf_type *t)
{ … }
static inline __u8 btf_int_bits(const struct btf_type *t)
{ … }
static inline bool btf_type_is_scalar(const struct btf_type *t)
{ … }
static inline bool btf_type_is_typedef(const struct btf_type *t)
{ … }
static inline bool btf_type_is_volatile(const struct btf_type *t)
{ … }
static inline bool btf_type_is_func(const struct btf_type *t)
{ … }
static inline bool btf_type_is_func_proto(const struct btf_type *t)
{ … }
static inline bool btf_type_is_var(const struct btf_type *t)
{ … }
static inline bool btf_type_is_type_tag(const struct btf_type *t)
{ … }
static inline bool btf_type_is_struct(const struct btf_type *t)
{ … }
static inline bool __btf_type_is_struct(const struct btf_type *t)
{ … }
static inline bool btf_type_is_array(const struct btf_type *t)
{ … }
static inline u16 btf_type_vlen(const struct btf_type *t)
{ … }
static inline u16 btf_vlen(const struct btf_type *t)
{ … }
static inline u16 btf_func_linkage(const struct btf_type *t)
{ … }
static inline bool btf_type_kflag(const struct btf_type *t)
{ … }
static inline u32 __btf_member_bit_offset(const struct btf_type *struct_type,
const struct btf_member *member)
{ … }
static inline u32 __btf_member_bitfield_size(const struct btf_type *struct_type,
const struct btf_member *member)
{ … }
static inline struct btf_member *btf_members(const struct btf_type *t)
{ … }
static inline u32 btf_member_bit_offset(const struct btf_type *t, u32 member_idx)
{ … }
static inline u32 btf_member_bitfield_size(const struct btf_type *t, u32 member_idx)
{ … }
static inline const struct btf_member *btf_type_member(const struct btf_type *t)
{ … }
static inline struct btf_array *btf_array(const struct btf_type *t)
{ … }
static inline struct btf_enum *btf_enum(const struct btf_type *t)
{ … }
static inline struct btf_enum64 *btf_enum64(const struct btf_type *t)
{ … }
static inline const struct btf_var_secinfo *btf_type_var_secinfo(
const struct btf_type *t)
{ … }
static inline struct btf_param *btf_params(const struct btf_type *t)
{ … }
static inline struct btf_decl_tag *btf_decl_tag(const struct btf_type *t)
{ … }
static inline int btf_id_cmp_func(const void *a, const void *b)
{ … }
static inline bool btf_id_set_contains(const struct btf_id_set *set, u32 id)
{ … }
static inline void *btf_id_set8_contains(const struct btf_id_set8 *set, u32 id)
{ … }
bool btf_param_match_suffix(const struct btf *btf,
const struct btf_param *arg,
const char *suffix);
int btf_ctx_arg_offset(const struct btf *btf, const struct btf_type *func_proto,
u32 arg_no);
struct bpf_verifier_log;
#if defined(CONFIG_BPF_JIT) && defined(CONFIG_BPF_SYSCALL)
struct bpf_struct_ops;
int __register_bpf_struct_ops(struct bpf_struct_ops *st_ops);
const struct bpf_struct_ops_desc *bpf_struct_ops_find_value(struct btf *btf, u32 value_id);
const struct bpf_struct_ops_desc *bpf_struct_ops_find(struct btf *btf, u32 type_id);
#else
static inline const struct bpf_struct_ops_desc *bpf_struct_ops_find(struct btf *btf, u32 type_id)
{
return NULL;
}
#endif
enum btf_field_iter_kind { … };
struct btf_field_desc { … };
struct btf_field_iter { … };
#ifdef CONFIG_BPF_SYSCALL
const struct btf_type *btf_type_by_id(const struct btf *btf, u32 type_id);
void btf_set_base_btf(struct btf *btf, const struct btf *base_btf);
int btf_relocate(struct btf *btf, const struct btf *base_btf, __u32 **map_ids);
int btf_field_iter_init(struct btf_field_iter *it, struct btf_type *t,
enum btf_field_iter_kind iter_kind);
__u32 *btf_field_iter_next(struct btf_field_iter *it);
const char *btf_name_by_offset(const struct btf *btf, u32 offset);
const char *btf_str_by_offset(const struct btf *btf, u32 offset);
struct btf *btf_parse_vmlinux(void);
struct btf *bpf_prog_get_target_btf(const struct bpf_prog *prog);
u32 *btf_kfunc_id_set_contains(const struct btf *btf, u32 kfunc_btf_id,
const struct bpf_prog *prog);
u32 *btf_kfunc_is_modify_return(const struct btf *btf, u32 kfunc_btf_id,
const struct bpf_prog *prog);
int register_btf_kfunc_id_set(enum bpf_prog_type prog_type,
const struct btf_kfunc_id_set *s);
int register_btf_fmodret_id_set(const struct btf_kfunc_id_set *kset);
s32 btf_find_dtor_kfunc(struct btf *btf, u32 btf_id);
int register_btf_id_dtor_kfuncs(const struct btf_id_dtor_kfunc *dtors, u32 add_cnt,
struct module *owner);
struct btf_struct_meta *btf_find_struct_meta(const struct btf *btf, u32 btf_id);
bool btf_is_projection_of(const char *pname, const char *tname);
bool btf_is_prog_ctx_type(struct bpf_verifier_log *log, const struct btf *btf,
const struct btf_type *t, enum bpf_prog_type prog_type,
int arg);
int get_kern_ctx_btf_id(struct bpf_verifier_log *log, enum bpf_prog_type prog_type);
bool btf_types_are_same(const struct btf *btf1, u32 id1,
const struct btf *btf2, u32 id2);
#else
static inline const struct btf_type *btf_type_by_id(const struct btf *btf,
u32 type_id)
{
return NULL;
}
static inline void btf_set_base_btf(struct btf *btf, const struct btf *base_btf)
{
}
static inline int btf_relocate(void *log, struct btf *btf, const struct btf *base_btf,
__u32 **map_ids)
{
return -EOPNOTSUPP;
}
static inline int btf_field_iter_init(struct btf_field_iter *it, struct btf_type *t,
enum btf_field_iter_kind iter_kind)
{
return -EOPNOTSUPP;
}
static inline __u32 *btf_field_iter_next(struct btf_field_iter *it)
{
return NULL;
}
static inline const char *btf_name_by_offset(const struct btf *btf,
u32 offset)
{
return NULL;
}
static inline u32 *btf_kfunc_id_set_contains(const struct btf *btf,
u32 kfunc_btf_id,
struct bpf_prog *prog)
{
return NULL;
}
static inline int register_btf_kfunc_id_set(enum bpf_prog_type prog_type,
const struct btf_kfunc_id_set *s)
{
return 0;
}
static inline s32 btf_find_dtor_kfunc(struct btf *btf, u32 btf_id)
{
return -ENOENT;
}
static inline int register_btf_id_dtor_kfuncs(const struct btf_id_dtor_kfunc *dtors,
u32 add_cnt, struct module *owner)
{
return 0;
}
static inline struct btf_struct_meta *btf_find_struct_meta(const struct btf *btf, u32 btf_id)
{
return NULL;
}
static inline bool
btf_is_prog_ctx_type(struct bpf_verifier_log *log, const struct btf *btf,
const struct btf_type *t, enum bpf_prog_type prog_type,
int arg)
{
return false;
}
static inline int get_kern_ctx_btf_id(struct bpf_verifier_log *log,
enum bpf_prog_type prog_type) {
return -EINVAL;
}
static inline bool btf_types_are_same(const struct btf *btf1, u32 id1,
const struct btf *btf2, u32 id2)
{
return false;
}
#endif
static inline bool btf_type_is_struct_ptr(struct btf *btf, const struct btf_type *t)
{ … }
#endif