-
Notifications
You must be signed in to change notification settings - Fork 445
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 libbpf to maintain Ubuntu 16.04 compatibility #2403
Conversation
#include "ebpf_common.h" | ||
|
||
|
||
/* If we operate in user space we only need to include bpf.h and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this compile with any kernel version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well this is what libbpf says: "No ties to any specific kernel, transparent handling of older kernels. Libbpf is designed to be kernel-agnostic and work across multitude of kernel versions. It has built-in mechanisms to gracefully handle older kernels, that are missing some of the features, by working around or gracefully degrading functionality. Thus libbpf is not tied to a specific kernel version and can/should be packaged and versioned independently."
I try to use their custom headers everywhere I can.
@@ -141,6 +141,15 @@ else() | |||
set (SUPPORTS_KERNEL False) | |||
endif() | |||
|
|||
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/runtime/usr/include/bpf") | |||
message(STATUS "Found libbpf") | |||
else() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you test this on MacOS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's see what Travis will say.
backends/ebpf/runtime/ebpf_kernel.h
Outdated
({ \ | ||
char ____fmt[] = fmt; \ | ||
bpf_trace_printk(____fmt, sizeof(____fmt), \ | ||
##__VA_ARGS__); \ | ||
}) | ||
|
||
/* helper functions called from eBPF programs written in C */ | ||
static void *(*bpf_map_lookup_elem)(void *map, void *key) = | ||
static void *(*bpf_map_lookup_elem)(void *map, const void *key) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping we would not need this junk anymore.
Isn't there a header with this stuff in libbpf?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will see if I can strip more later. Last time I checked those were still necessary.
There are some problems with your Python scripts. |
Trying to support kernel eBPF tests in Ubuntu 16.04 is just pure masochism. At this point we also need to build the iproute2 package from source... These are the same problems we had with the xdp back ends so at least we have the fixes already. |
Cmake improvements. Fix some more things. Some work on runtime.mk
Trying to fix the build unearthed a bunch of other issues. Right now, I have no idea what to do about the failing tests. One of them requires a change to how tables are registered, the other is the LPM_TRIE map getting rejected. They are failing for reasons we have missed before. |
I thought we didn't support lpm in the ebpf backends. |
There is a test that fails for the kernel |
The other tests that fail are the extern object ones, they do not play nicely for various reasons. |
Add a comment.
More junk-a-way Make lpm ebpf fail properly.
I think this is ready for review now. I also created some issues based on problems I have encountered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's see if anyone else wants to review this.
@fruffy : is this finished? |
From my point of view it is. The remaining issues should probably be handled separately. Merging this will break the xdp back end, but I have a pull request ready for it. |
This pull request adds libbpf as dependency to make the eBPF back end more stable. It makes the generated code less dependent on the kernel headers of a particular distribution. This may help with the problem that different distributions of Ubuntu cannot compile the code generated by p4c-ebpf. Also fixes #1961.
Let's see if this works out.
Changes:
lpm_ebpf.p4
, also marked this test as xfail.ebpf_kernel.h
file, using only the imports fromlibbpf
.BPF_USER_MAP_UPDATE_ELEM
to the user-space test framework.