You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to create an eBPF hash of maps and add entries to this map gradually. Since BPF programs cannot add new entires to outer maps, my only option is to do that in the userspace program. And I found out a way to do that by defining a outer map and the expected inner map in the BPF program:
But when try to load the program, the following error is announced:
libbpf: map 'outer_hash.inner': can't determine value size for type [37]: -22.
And the thing is, I know that I can specify that the inner map should hold structs if I declare the inner maps statically, but I want to add new entries to a map dynamically at userspace. So, what can I do to have dynamic outer map entries while still having structs in the inner maps?
The text was updated successfully, but these errors were encountered:
Oh that makes sense, thanks! I've updated it with your suggestion and it isn't showing me that error anymore.
However, when I try running the following code:
int inner_fd = bpf_map_create(BPF_MAP_TYPE_ARRAY, "test", sizeof(__u32), sizeof(struct test), 4, 0);
int err = bpf_map_update_elem(map_fd, &key, &inner_fd, BPF_ANY);
err receives -22 returned from bpf_map_update_elem, which means that an argument is invalid.
In that same example with integer as the value of the inner map, when I used sizeof(__u32), instead of sizeof(struct test), it was working normally. So, I imagine that this might be the incorrect argument, but I wonder why
I want to create an eBPF hash of maps and add entries to this map gradually. Since BPF programs cannot add new entires to outer maps, my only option is to do that in the userspace program. And I found out a way to do that by defining a outer map and the expected inner map in the BPF program:
While the userspace program uses bpf_map_create to create a new inner map and bpf_map_update_elem to include it in the outer map.
However, instead of the inner map being an array of integers, I'd like for it to be an array of structs, such as:
But when try to load the program, the following error is announced:
And the thing is, I know that I can specify that the inner map should hold structs if I declare the inner maps statically, but I want to add new entries to a map dynamically at userspace. So, what can I do to have dynamic outer map entries while still having structs in the inner maps?
The text was updated successfully, but these errors were encountered: