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

Sort programs to match bpf2c #2784

Merged
merged 4 commits into from
Aug 24, 2023
Merged

Conversation

Alan-Jowett
Copy link
Member

@Alan-Jowett Alan-Jowett commented Aug 23, 2023

Resolves: #2781

Description

The bpf2c tool populates the _programs array sorted by the section name for each program. This then defines the order in which program handles are returned from kernel to user mode. The function _ebpf_enumerate_native_sections returns programs in the order in which they occur in the PE file (which doesn't always match). The net result is that libbpf programs -> kernel handles sometimes don't match.

Testing

CI/CD

Documentation

No.

Installation

No.

Signed-off-by: Alan Jowett <[email protected]>
saxena-anurag
saxena-anurag previously approved these changes Aug 23, 2023
@Alan-Jowett Alan-Jowett marked this pull request as draft August 23, 2023 15:56
@Alan-Jowett
Copy link
Member Author

bad_tail_call-native is failing. Switching to draft.

Signed-off-by: Alan Jowett <[email protected]>
Alan Jowett added 2 commits August 23, 2023 09:18
Signed-off-by: Alan Jowett <[email protected]>
@Alan-Jowett Alan-Jowett marked this pull request as ready for review August 23, 2023 22:00
// vector to match. If there are multiple programs per section, sort by program name.
std::sort(object.programs.begin(), object.programs.end(), [](const ebpf_program_t* a, const ebpf_program_t* b) {
int section_name_comparison = strcmp(a->section_name, b->section_name);
int program_name_comparison = strcmp(a->program_name, b->program_name);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: moving line 1757 into the else clause might be more efficient.

@Alan-Jowett Alan-Jowett added this pull request to the merge queue Aug 24, 2023
Merged via the queue into microsoft:main with commit 5c9ca4b Aug 24, 2023
64 checks passed
@Alan-Jowett Alan-Jowett deleted the issue2781 branch August 24, 2023 01:36
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_object__open and bpf_object__load get inconsistent list of programs
3 participants