-
Notifications
You must be signed in to change notification settings - Fork 141
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
Generate key and value structs of BPF maps #972
Comments
Can you provide an fully working example, please? I think we should be dumping all types available in BTF, which includes keys and values used in BPF maps. |
Sure, find attached the example. With my main project I noticed that some structs are exported, but others are not. In the attached project I can't get any struct to get generated. Either way, I think providing a working example of this could be very useful, as discussed in #312. |
This map doesn't contain type information. It probably need to be written like this: struct {
__uint(type, BPF_MAP_TYPE_SOCKHASH);
__uint(max_entries, 8192);
__type(key, struct sock_key);
__type(value, int);
} sock_map SEC(".maps"); |
@kxxt that indeed works, thank you! I noticed that in my main project I was using an outdated version of libbpf, where this doesn't work either. But in the example it works! |
Hi everybody,
I noticed that the structs used in BPF maps, i.e. the key and value structs, are not available in the skeleton. I found myself redefining the same structs in rust, just so that it's easier to populate the maps from userspace. Am I missing something, or is this actually the easiest way to do it? :)
If this is indeed the case, I think it would be useful to export these structs as well to reduce boilerplate code.
Cheers,
Laurin
The text was updated successfully, but these errors were encountered: