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

support partial output buffer for get_info API. #4286

Merged
merged 2 commits into from
Mar 21, 2025

Conversation

shankarseal
Copy link
Collaborator

Description

Describe the purpose of and changes within this Pull Request.
This PR fixes #4160 by allowing smaller output buffer than the size of the struct for bpf_obj_get_info_by_fd API. The changes were made for program, map and link objects. This PR found two incidental issues:

  1. In JIT case, the count_of_maps for eBPF program object was set to the count of map references in individual instructions, instead of total number of unique maps referred to by the program.
  2. The query_map_definition invoked bpf_obj_get_info_by_fd but did not check if the returned object type was indeed that of a map.

Testing

Do any existing tests cover this change? Are new tests needed?
Test cases were added in libbpf unit tests to invoke ``bpf_obj_get_info_by_fd` with smaller output buffers.

Documentation

Is there any documentation impact for this change?
N/A.

Installation

Is there any installer impact for this change?
N/A.

@shankarseal shankarseal enabled auto-merge March 19, 2025 22:03
@shankarseal shankarseal added this pull request to the merge queue Mar 19, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 20, 2025
@shankarseal shankarseal added this pull request to the merge queue Mar 20, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 20, 2025
@shankarseal shankarseal added this pull request to the merge queue Mar 21, 2025
Merged via the queue into microsoft:main with commit 1a0b8c8 Mar 21, 2025
95 of 97 checks passed
@shankarseal shankarseal deleted the fix_4160 branch March 21, 2025 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bpf_obj_get_info_by_fd doesn't allow passing structs smaller than sizeof(struct bpf_*_info)
3 participants