Navigation Menu

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

Libbpf API compatibility #350

Merged
merged 8 commits into from Jul 30, 2021
Merged

Libbpf API compatibility #350

merged 8 commits into from Jul 30, 2021

Conversation

dthaler
Copy link
Collaborator

@dthaler dthaler commented Jul 28, 2021

Libbpf is incorporated as a submodule just for the header file.
As discussed in issue #84, we cannot currently use the implementation since it is very Linux and GCC specific.

This PR also fixes a bug where the user-mode API was calling CloseHandle() directly instead of Platform::CloseHandle() which is needed to make tests work with the mock platform.

Fixes #84 (future changes should be done under API-specific issues)

Some code will be cleaner once issue #81 is done

Signed-off-by: Dave Thaler dthaler@microsoft.com

Libbpf is incorporated as a submodule just for the header file.
As discussed in issue #84, we cannot currently use the implementation
since it is very Linux and GCC specific.

This PR also fixes a bug where the user-mode API was calling
CloseHandle directly instead of Platform::CloseHandle which is needed
to make tests work with the mock platform.

Addresses #84

Some code will be cleaner once issue #81 is done

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
// TODO(issue #223): read this mapping from the registry
switch (type) {
case BPF_PROG_TYPE_XDP:
return &EBPF_PROGRAM_TYPE_XDP;
Copy link
Contributor

Choose a reason for hiding this comment

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

EBPF_PROGRAM_TYPE_XDP definition which is present in ebpf_api.h is temporary till Issue #223 is fixed. Once these definitions are removed, how will bpf_prog_type enums be mapped to the program type guids?

Copy link
Collaborator Author

@dthaler dthaler Jul 30, 2021

Choose a reason for hiding this comment

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

By reading the mapping from the registry, as line 17 says

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
@@ -166,6 +166,8 @@ TEST_CASE("libbpf map", "[libbpf]")
REQUIRE(bpf_map__prev(map, object) == nullptr);
REQUIRE(bpf_map__prev(nullptr, object) == map);

const char* name = bpf_map__name(map);
REQUIRE(name == nullptr); // droppacket.o has no map name.
Copy link
Contributor

Choose a reason for hiding this comment

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

Just mentioning: PR for issue #81 will populate map names also from ELF file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that will be great. That PR will need to update this line since the test will fail until this line is updated to match.

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
@dthaler dthaler merged commit 8006f18 into microsoft:master Jul 30, 2021
@dthaler dthaler deleted the libbpf-compat branch July 30, 2021 22:34
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.

Add support for libbpf API compatibility
3 participants