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.
Resolves: #3352
Description
This pull request introduces changes that allow the EBPF verifier to load EBPF programs not only from files but also from memory. This is achieved by using
std::variant
to hold either a file path or a memory buffer. The most significant changes include adding a new methodbpf_object__open_mem
for opening an ELF file from memory, modifying several methods inlibs/api/Verifier.cpp
andlibs/api/ebpf_api.cpp
to handle the variant type, and adding a new test case for loading an EBPF program from memory.Changes to the API:
ebpfapi/Source.def
: Added a new functionbpf_object__open_mem
to the exports.libs/api/api_internal.h
: Defined a new functionebpf_object_open_memory
that opens an ELF file from memory without loading the programs.libs/api/libbpf_object.cpp
: Implementedbpf_object__open_mem
that usesebpf_object_open_memory
to open an ELF file from memory.Changes to the Verifier:
libs/api/Verifier.cpp
andlibs/api/Verifier.h
: Modified_get_program_and_map_names
andload_byte_code
to accept astd::variant
that can be either a file path or a memory buffer. [1] [2] [3] [4] [5]Changes to the EBPF API:
libs/api/ebpf_api.cpp
: Added the implementation forebpf_object_open_memory
and modified_initialize_ebpf_object_from_elf
,_initialize_ebpf_object_from_file
and other related methods to handle thestd::variant
type. [1] [2] [3] [4]Changes to the test suite:
tests/unit/libbpf_test.cpp
: Added a new test case for loading an EBPF program from memory.Testing
CI/CD + new tests.
Documentation
No.
Installation
No.