feat: enhance BPF core read macros and add new utility functions #797
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces several updates to the eBPF codebase, including enhancements to kernel compatibility, new helper macros, and improvements to core relocation handling. The changes aim to increase compatibility with newer compilers, improve usability, and add new functionality for eBPF programs.
Kernel Compatibility Enhancements:
Makefile
to include$(KERN_SRC_PATH)/include/linux
, ensuring compatibility with additional kernel headers. [1] [2]vmlinux_510.h
withvmlinux_614.h
inkern/bpf/arm64/vmlinux.h
to align with a newer kernel version.Core Relocation and Type Handling:
BPF_TYPE_MATCHES
kind inenum bpf_type_info_kind
to check type matches in target kernels.bpf_core_cast()
to simplify pointer casting with kernel-side BTF types, enabling direct member access.bpf_core_field_exists
andbpf_core_field_size
to support both variable and type-based field references. [1] [2]Compiler Compatibility and Optimization:
SEC()
andoffsetof()
to handle compiler-specific quirks. [1] [2]likely()
andunlikely()
macros for branch prediction optimization.New Helper Macros and Functions:
BPF_CORE_WRITE_BITFIELD()
for writing to bitfields, complementing existing read macros.barrier()
andbarrier_var()
macros to enforce memory and variable-specific compiler barriers.Cleanups and Deprecations:
bpf_map_def
structure, which has been replaced by newer mechanisms in the eBPF ecosystem.refer: iovisor/bcc#5258