tools/lib/bpf/bpf.h
Source file repositories/reference/linux-study-clean/tools/lib/bpf/bpf.h
File Facts
- System
- Linux kernel
- Corpus path
tools/lib/bpf/bpf.h- Extension
.h- Size
- 27820 bytes
- Lines
- 791
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bpf.hstdbool.hstddef.hstdint.hlibbpf_common.hlibbpf_legacy.h
Detected Declarations
struct bpf_log_optsstruct bpf_map_create_optsstruct bpf_prog_load_optsstruct bpf_btf_load_optsstruct bpf_map_batch_optsstruct bpf_obj_pin_optsstruct bpf_obj_get_optsstruct bpf_prog_attach_optsstruct bpf_prog_detach_optsstruct bpf_link_create_optsstruct bpf_link_update_optsstruct bpf_prog_test_run_attrstruct bpf_get_fd_by_id_optsstruct bpf_prog_query_optsstruct bpf_raw_tp_optsstruct bpf_prog_bind_optsstruct bpf_test_run_optsstruct bpf_token_create_optsstruct bpf_prog_stream_read_optsstruct bpf_prog_assoc_struct_ops_optsenum bpf_stats_type
Annotated Snippet
struct bpf_log_opts {
size_t sz; /* size of this struct for forward/backward compatibility */
char *buf;
__u32 size;
__u32 level;
__u32 true_size; /* out parameter set by kernel */
size_t :0;
};
#define bpf_log_opts__last_field true_size
struct bpf_map_create_opts {
size_t sz; /* size of this struct for forward/backward compatibility */
__u32 btf_fd;
__u32 btf_key_type_id;
__u32 btf_value_type_id;
__u32 btf_vmlinux_value_type_id;
__u32 inner_map_fd;
__u32 map_flags;
__u64 map_extra;
__u32 numa_node;
__u32 map_ifindex;
__s32 value_type_btf_obj_fd;
__u32 token_fd;
const void *excl_prog_hash;
__u32 excl_prog_hash_size;
struct bpf_log_opts *log_opts;
size_t :0;
};
#define bpf_map_create_opts__last_field log_opts
LIBBPF_API int bpf_map_create(enum bpf_map_type map_type,
const char *map_name,
__u32 key_size,
__u32 value_size,
__u32 max_entries,
const struct bpf_map_create_opts *opts);
struct bpf_prog_load_opts {
size_t sz; /* size of this struct for forward/backward compatibility */
/* libbpf can retry BPF_PROG_LOAD command if bpf() syscall returns
* -EAGAIN. This field determines how many attempts libbpf has to
* make. If not specified, libbpf will use default value of 5.
*/
int attempts;
enum bpf_attach_type expected_attach_type;
__u32 prog_btf_fd;
__u32 prog_flags;
__u32 prog_ifindex;
__u32 kern_version;
__u32 attach_btf_id;
__u32 attach_prog_fd;
__u32 attach_btf_obj_fd;
const int *fd_array;
/* .BTF.ext func info data */
const void *func_info;
__u32 func_info_cnt;
__u32 func_info_rec_size;
/* .BTF.ext line info data */
const void *line_info;
__u32 line_info_cnt;
__u32 line_info_rec_size;
/* verifier log options */
__u32 log_level;
__u32 log_size;
char *log_buf;
/* output: actual total log contents size (including terminating zero).
* It could be both larger than original log_size (if log was
* truncated), or smaller (if log buffer wasn't filled completely).
* If kernel doesn't support this feature, log_size is left unchanged.
*/
__u32 log_true_size;
__u32 token_fd;
/* if set, provides the length of fd_array */
Annotation
- Immediate include surface: `linux/bpf.h`, `stdbool.h`, `stddef.h`, `stdint.h`, `libbpf_common.h`, `libbpf_legacy.h`.
- Detected declarations: `struct bpf_log_opts`, `struct bpf_map_create_opts`, `struct bpf_prog_load_opts`, `struct bpf_btf_load_opts`, `struct bpf_map_batch_opts`, `struct bpf_obj_pin_opts`, `struct bpf_obj_get_opts`, `struct bpf_prog_attach_opts`, `struct bpf_prog_detach_opts`, `struct bpf_link_create_opts`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.