bpftime
bpftime copied to clipboard
How to use bpftime as as a library rather than CLI ?
The current bpftime/example/libbpftime_example is very incomplete and only demonstrates basic shared memory operations. There's a lack of comprehensive examples showing how to use bpftime as a library rather than through the CLI tools.
Could you provide more complete library usage examples that demonstrate the full lifecycle of eBPF programs using bpftime APIs directly, similar to how the malloc example works but using library calls instead of CLI commands?
Ok! We will add it.
by the way, maybe you can also look at https://github.com/eunomia-bpf/bpftime/tree/master/tools%2Fbpftimetool
by the way, maybe you can also look at https://github.com/eunomia-bpf/bpftime/tree/master/tools%2Fbpftimetool
Thank you for your response and for confirming that you'll add more comprehensive examples!
I also have a follow-up question regarding the usage of libbpftime.a: when using bpftime as a library, is it sufficient to link only the static library file (libbpftime.a), or are other compiled .so shared libraries also required?
@yunwei37
I added a minimal “library mode” example (no CLI): https://github.com/Yinwhe/bpftime/tree/yinwhe/dev/example/bpftime-libhelper
Note:
- This example works by intercepting sys_bpf and routing libbpf calls to bpftime’s userspace implementation; it does not directly use bpftime’s low-level runtime APIs.
Discussion:
- Would a non-hijacking, non-libbpf example that uses the runtime/handler APIs directly (create program/map/link, run, read, teardown) be valuable?
- If so, I can draft that example with concise docs and open a PR.