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

BPF kfuncs and vmlinux.h #380

Open
danobi opened this issue Dec 15, 2023 · 2 comments
Open

BPF kfuncs and vmlinux.h #380

danobi opened this issue Dec 15, 2023 · 2 comments

Comments

@danobi
Copy link
Contributor

danobi commented Dec 15, 2023

Hi,

I noticed in 3f3751c that the "traditional" vmlinux.h was stripped down. I think in the regular BPF helper world that was probably fine, but I think having a stripped vmlinux.h has implications for the new kfunc world.

For example, kfuncs will now expose internal kernel data structures -- I'm mostly thinking of struct xfrm_state and https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=403f3e8fda60f1a3e54741742d46aea98ecf671e. Those structs depend on a lot of internal kernel types. Maintaining all the dependencies by hand could get tricky.

I was wondering if y'all had any thoughts on the path forward for calling kfuncs.

@tohojo
Copy link
Member

tohojo commented Dec 15, 2023 via email

@danobi
Copy link
Contributor Author

danobi commented Dec 17, 2023

Not really, other than yeah, tedious :)

Tooling to dynamically generate the stripped-down header would be pretty neat (by recursively expanding dependent types from a list of kfunc names, say). Don't think any such tooling exists, though.

I did something like this for libbpf-rs originally (although much of it has changed since then): https://github.com/libbpf/libbpf-rs/blob/7f3ba404486f7a9b2d02ed5717c81e92e8a3425b/libbpf-cargo/src/gen/btf.rs#L249-L252 . I think it should be fairly straightfoward for bpftool to do this as well. Although I wonder what bpftool folks think about this vs generating entire vmlinux.h. cc @anakryiko @qmonnet

I believe there was also a plan at some point to have the kfunc signatures themselves included in the generated vmlinux.h? In which case you could just use the full file and then just call the functions without having to make any further definitions...

Yeah that's something that's been bugging me for a while as well. I found libbpf/bpftool#98 which is kinda related.

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

No branches or pull requests

2 participants