-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Improve static data load support #7123
Comments
A note: The docker GSG is currently locked to v1.4 due to this issue (see comment added in #7574) |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
This issue has not seen any activity since it was marked stale. Closing. |
Pointers in gobpf for program templating:
Although it's not clear if we can already use gobpf for Cilium BPF programs. |
My high level take is that Cilium would benefit from moving the entire loader logic into Golang, to avoid recent situations like #12070 (which was a regression due to introducing map-handling logic into the Go side where it was previously only handled by iproute2/tc in the shell scripting) and also to improve code structuring, unit testing, integration between Cilium core logic and the loader logic. I note that this is not strictly the same problem as addressing the way we handle static data substitution, but it's related. If we switch the encoding of static data, we necessarily need an implementation to handle that encoding. That leads us back to the decision of whether to keep the same approach with Go->bash->C programs (where we need to modify the C programs) or to more natively integrate a loader directly in Go. This is the back of my mind while I think through this problem. I note also that this is related to the mechanism which invokes the compiler to build the datapath ELF files. For a minimal solution here, I don't believe we will need to make any major modifications to this logic; most likely just some compiler flag changes. The latest option that I've added to the PR description is inspired by some discussions I had with @jrfastab around BTF.
I also had a thought about whether we need to touch |
Given the kernel gained support for direct map accesses in https://lore.kernel.org/bpf/20190409212018.32423-2-daniel@iogearbox.net/, shipped in 5.2, and ebpf-go has supported it for years, we shouldn't spend too much time inventing another solution to this problem. We can wait until 4.19 goes EOL and remove this hack when we target 5.2 or later. One small improvement that could be made to the current implementation of inlineGlobalData is that it currently requires all constants to be 32 bits wide, since that's what the equivalent iproute2 code did in our fork. Now we have access to .data's BTF Datasec through MapSpec.Value, we can determine the exact width of the value the instruction is referring to, and issue a copy of the correct size instead of a fixed 32 bits. This means we would dynamically support values of 8/16/32/64 bits wide, not just 32-bits. See https://github.com/cilium/cilium/blob/main/bpf/lib/static_data.h for the C side of things. Supporting larger values (esp. 64 bits) could have an impact on instruction count in ipv6-heavy code paths since currently, with only 32-bit values supported, ipv6 addresses need to be split into 4 chunks. These are then put into 4 imm64 instructions, only utilizing half of the space available. Worse, an imm64 is actually encoded using 2 raw instructions in the insn stream, so this totals 8 raw instructions for an ipv6. Knowing how much impact will require us to do the work anyway. Edit: My proposal for the above: #25195. |
The current approach for templatizing BPF programs [ #7095 ] uses these fun tricks to convince LLVM to tag global data symbols and reserve space in the .data section:
https://github.com/cilium/cilium/pull/7095/files#diff-fb0192c65751d297ed36049608a36c89
These can then be interpreted in the following iproute2 changes to load the data we want:
isovalent/iproute2@16ed3bd
A similar approach was proposed to upstream libbpf, but rejected:
https://www.spinics.net/lists/netdev/msg550707.html
Possible solutions:
Use inline-asm tricks:The text was updated successfully, but these errors were encountered: