-
Notifications
You must be signed in to change notification settings - Fork 138
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
declaring a map requires having a field named type #54
Comments
Gonna close this out b/c it's probably better asked on the bpf mailing lists. But just out of curiosity, why are you bindgen'ing the .bpf.c code? |
I'm not. Currently I'm using a patched cargo-bpf that emits debug info [0], at least until the rustc bpf target support is merged [1]. I'm currently working on my own bpf library that is going to work something like this: let bpf = BpfBuilder::new(PROBE)?
.attach_probe("tracepoint:raw_syscalls:sys_enter", "sys_enter")?
.attach_probe("tracepoint:raw_syscalls:sys_exit", "sys_exit")?
.attach_probe("profile:hz:99", "profile")?
.load()?; I'm still missing an understanding of how maps work in detail, I assumed libbpf-rs would handle it for me until I realized it does not. So you used to be able to declare a map using the |
Any suggestions on how to proceed? I guess I'll just not put maps in the .maps section and load them manually using the bpf(BPF_MAP_CREATE) syscall. |
It's not clear. So how does your BPF code look like? |
It's a work in progress, I made my first experiments with redbpf and got something to work (counting syscalls). Here is the wip adaption to my own library [0]. Note that nothing actually works yet. |
redbpf doesn use libbpf. Those BTF-based map definitions in SEC(".maps") is libbpf convention. Kernel itself just expects BTF FD and type IDs associated with key and value to get everything working. On the other hand, libbpf does expect BPF code to be written in C and compiled with Clang. So if you want to go with Rust for BPF code, I don't think you can easily use libbpf. |
Yes I came to the same conclusion. I can still use libbpf-rs to bootstrap, it should work for parsing the elf file and loading bpf programs, but I'll need to implement my own map handling. |
libbpf-rs works for me now. apparently you can put maps in a |
Unfortunately, the only way is to read the source. Usually the function names will hint you in the right direction. |
This can not be accomplished when compiling from rust.
type_
as emitted by bindgen orr#type
generate wrong identifier names in the debug info making it impossible to get btf to acknowledge atype
field. I'd suggest also acceptingtype_
.Ups wrong repo should be the libbpf one.
The text was updated successfully, but these errors were encountered: