Implement HashOfMaps and ArrayOfMaps
Thanks for taking this up!
I only skimmed through the changes. The user space side looks ok, the ebpf side I think should probably be a bit different. Right now maps of maps return an integer from get() (which is presumably a map id). I think they should return typed maps, eg:
#[map]
static mut OUTER: ArrayOfMaps<HashMap<X, Y>> = ...
fn some_probe(...) -> Result {
let inner_map: HashMap<X, Y> = unsafe { OUTER.get(0).ok_or(())? };
inner_map.insert(x_value, y_value);
...
}
This will also require adding some kind of from_id(u32) method to all maps, and we'll have to refactor maps to remove the assumption that we always have a bpf_map_def in self.def.
This is of interest to us!
@jeromegn awesome! i'll get back to this after #127... and probably after #151 since may as well handle internal changes to fetching internal maps/programs by id together...
@alessandrod I haven't looked into the kernel side yet, but are all maps in the array/hashmap constrained to being of the same type? if not, it won't be possible to return a strongly typed wrapper....
@dave-tucker Any interest in continuing on this? We actually need it and are happy to contribute.
I haven't looked into the kernel side yet, but are all maps in the array/hashmap constrained to being of the same type? if not, it won't be possible to return a strongly typed wrapper....
If I'm not mistaken, all the values are the same for the map of maps. They're refs u32.
I'd like to take a stab at getting this up to day/ finishing if need be! WDYT @dave-tucker?
@dave-tucker, this pull request is now in conflict and requires a rebase.
@dave-tucker, this pull request is now in conflict and requires a rebase.
Our project could use this feature. Any updates? Glad to lend a hand in finishing this up if needed.
Our project could use this feature. Any updates? Glad to lend a hand in finishing this up if needed.
I've needed this too recently so I'd like to get it landed. We've changed the implementation of maps so the code in this PR needs to be updated. Getting it to compile/work would be a good first step I guess?