Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for autoload libbpf APIs #3555

Closed
dthaler opened this issue May 18, 2024 · 0 comments · Fixed by #3592
Closed

Add support for autoload libbpf APIs #3555

dthaler opened this issue May 18, 2024 · 0 comments · Fixed by #3592
Assignees
Labels
enhancement New feature or request triaged Discussed in a triage meeting
Milestone

Comments

@dthaler
Copy link
Collaborator

dthaler commented May 18, 2024

Describe the feature you'd like supported

libbpf.h has these APIs which are not currently supported:

LIBBPF_API bool bpf_program__autoload(const struct bpf_program *prog);
LIBBPF_API int bpf_program__set_autoload(struct bpf_program *prog, bool autoload);

Today when bpf_object__load(object) is called, all programs in the object get loaded regardless of whether they will ever be attached. If a caller only wants to use (say) one program in the object, this wastes memory and verification time.

bpf_program__set_autoload can be used to control, on a per program basis, whether bpf_object__load will or will not load the program, and bpf_program__autoload can be used to read whether it will be loaded.

Proposed solution

Implement to match equivalent functionality as standard libbpf.

Additional context

map.o for instance has 3 programs, only the last of which can actually be loaded:

C:\Users\dthal\git\ebpf\ebpf-for-windows\x64\Debug>llvm-objdump -t map.o | findstr F
0000000000000000 g     F .text  00000000000006d8 test_LRU_map
00000000000006d8 g     F .text  0000000000001890 test_PUSH_POP_map
0000000000000000 g     F sample_ext     0000000000006000 test_maps
@dthaler dthaler added the enhancement New feature or request label May 18, 2024
@dahavey dahavey added the triaged Discussed in a triage meeting label May 20, 2024
@dahavey dahavey added this to the 2406 milestone May 20, 2024
dthaler added a commit to dthaler/ebpf-for-windows that referenced this issue May 30, 2024
Fixes microsoft#3555

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>
dthaler added a commit to dthaler/ebpf-for-windows that referenced this issue May 30, 2024
Fixes microsoft#3555

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>
dthaler added a commit to dthaler/ebpf-for-windows that referenced this issue May 31, 2024
Fixes microsoft#3555

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>
dthaler added a commit to dthaler/ebpf-for-windows that referenced this issue May 31, 2024
Fixes microsoft#3555

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>
github-merge-queue bot pushed a commit that referenced this issue Jun 3, 2024
* Implement libbpf autoload APIs

Fixes #3555

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Suppress spurious compiler warning

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Fix test failure

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Update tests

Files with no program sections succeed loading

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Address PR comment from Anurag

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* PR feedback

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Fix test

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Prevent changing prog type of a native program

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* PR feedback

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Remove unused program_type from native load ioctl

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Update default autoload value

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* PR feedback

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Fix test

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Add check to unit_test to match api_test

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Fix api_test

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

---------

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triaged Discussed in a triage meeting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants