-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 embedded clang/llvm for runtime compilation of eBPF programs #6978
Conversation
`inv deps` did not like it when these files were missing and not generated yet
This figures out the correct path if deployed in a similar repo structure to how it was built. Otherwise, it assumes you are running from the root directory.
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.
lgtm for container-integrations
// defaultProxyPort is the default port used for proxies. | ||
// This mirrors the configuration for the infrastructure agent. | ||
defaultProxyPort = 3128 | ||
|
||
// defaultSystemProbeBPFDir is the default path for eBPF programs | ||
defaultSystemProbeBPFDir = "/opt/datadog-agent/embedded/share/system-probe/ebpf" | ||
|
||
// defaultRuntimeCompilerOutputDir is the default path for output from the system-probe runtime compiler | ||
defaultRuntimeCompilerOutputDir = "/var/tmp/datadog-agent/system-probe/build" |
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.
This is also defined separately as a default in pkg/ebpf/config.go
. Might be worth cleaning up so its defined once. Fine if this is done in a separate follow-up PR .
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.
LGTM on the Processes-side for configuration. I haven't dug into the actual runtime compilation pieces given its been thoroughly reviewed and approved.
This ensures we re-compile assets when config options change and/or we update the default flags.
This doesn't include DNS or HTTP tests at the moment because some refactoring is needed to make that possible.
4442771
to
4cbf304
Compare
What does this PR do?
Adds a statically-linked, embedded clang/llvm for runtime compilation of eBPF programs. If enabled, these programs are compiled on-demand. The output object file is cached, such that if any of the following changes, it will be re-compiled:
Each runtime-compiled source file is pre-processed during CI build to be a concatenation of the
.c
and all user (non-kernel).h
files. Also during CI build, a hash is computed for the pre-processed file, such that any modifications on the host would result in refusing to compile the program.The pre-processed
.c
file is distributed separately from thesystem-probe
binary, like our.o
files, since it must be GPL-licensed to use certain kernel BPF helper functions.Motivation
Planned features for networks and/or the system-probe require access to kernel structures that are too difficult to access with offset guessing. Runtime compilation allows us to compile on each host so it is targeted for the running kernel.
Additional Notes
g++
being killed. I'm investigating why, but it was not happening before I rebased on master.Describe your test plan
The kitchen tests currently pass across a wide range of kernels/distros, but the runtime compilations tests only ensure that the programs can be compiled. The CI tests are run another time with the runtime compiler enabled.
Further testing with
system_probe_config.enable_runtime_compiler
turned on would be useful.