Skip to content

Make bpf() wrapper ABI compatible with Linux #3729

@lmb

Description

@lmb

Describe the feature you'd like supported

This is an alternative proposal to #3700. Based on feedback by my colleague Timo I had a look at invoking the bpf() syscall wrapper via LoadLibrary (this was mentioned by @shankarseal during the last triage). It turns out this works, and would make it easier to port cilium/ebpf.

The problem is that at efW is currently API compatible with bpf(), but does not follow the Linux ABI. This means we can't use our existing syscall wrappers to call into ebpfabi.dll. As I mentioned earlier we can't make use of API compatibility since that forces use of CGO.

Proposed solution

Guarantee that the exposed bpf() function follows the Linux ABI. Figure out a way to reuse bpf_attr, etc. from upstream as much as possible.

Additional context

Here is a non-exhaustive list of things that would need to be fixed:

  • Accept both larger and smaller bpf_attr from the caller of bpf()
  • Fix values of enum bpf_cmd_id to correspond to Linux equivalents
  • Make union bpf_attr actually match Linux ABI (flags on linux are 32 bit, etc.)

We'd also need some new API (these don't have to go via bpf()):

  • A way to load a native image and enumerate maps and programs without being tied into bpf_object lifecyle.
  • Add ebpf_close_fd again so that we have an easy way to call into the right UCRT _close function.

Metadata

Metadata

Labels

P1enhancementNew feature or requesttriagedDiscussed in a triage meeting

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions