-
Notifications
You must be signed in to change notification settings - Fork 302
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
New Map API #75
Comments
What would be the purpose of registering the map with
Without going into API details yet, generally speaking whenever there's a need for a builder, I think we should have both the builder and a simplified API for the common cases implemented on top of the builder. Having to type the whole builder thing every time where one could use
Can you explain what's the use case for this? I can see how we could implement pinned maps this way, but I think I prefer the current approach to this, where the user only specifies a path, and then loading happens transparently as with non-pinned maps.
I think this would work yes
I don't think this would work. The only thing we'd be able to share is the API signatures, but then we'd have two completely different implementations. Maps in aya-bpf are glorified sugar for building |
So the map created from userspace could be used in the eBPF program (and not recreated by the call to load).
I could have an eBPF program that wants to reuse a pinned map, while creating some maps that get pinned to its mao_pin_path.
Yeah maybe this would be too much |
But used how by the eBPF program? Maps for which we have relocation entries in program code are discovered and loaded automatically. Maps inside other maps are looked up using
Don't we already support that today? |
Currently it's not possible to decide from user-space that a map should be pinned, you must specify it in the eBPF-side map definition.
|
Closing as this is stale. |
Following the discussion on #45 and since I started work on #70 it's become clear that the current Map API needs some work.
We have 3 use cases I can think of from userspace
BpfLoader
such that any loaded programs use the map that I've created (not implemented)a. As (3) but register the map with the
BpfLoader
so it can be used when loading my program, which was implemented in Add support for map and program pinning #45Creating a Map from Userspace
The simple case would be to re-implement what we have in
aya-bpf
We could however implement a builder style api, which I think is a little more expressive:
Registering Maps to a BpfLoader
In order for
.map()
to work, ourHashMap<u32,u32>
needs to be able to be inserted in to aVec<Map>
.Given that #70, might need to implement a special case of
create
- because i believe that we may also need to create dummy inner maps to make the verifier happy - I'm wondering whether it makes sense forMap
to become a trait instead.Loading a Pinned Map from Userspace
This is a little trickier to implement in practice because we don't have the bpf_map_def ahead of time.
For
load
:bpf_obj_get
to get the fdbpf_obj_get_info_by_fd
to get thebpf_map_info
struct, which appears to be a superset ofbpf_map_def
Moving all Map code to a new
aya-map
moduleSeeing as creating maps from userspace will offer an almost identical API to the
aya-bpf
module, I wonder whether it might be worth moving all map code to it's own module calledaya-map
🤔This would allow us to provide a consistent API from both userspace and kernel space - we can use attributes
#[cfg(feature = "user")]
or#[cfg(feature = "ebpf")]
to implement functions where the implementation needs to differ. In some ways this would make #36 easier, since I believe we already have some mocks in place for maps which could be re-used when testing eBPF code 🤔The text was updated successfully, but these errors were encountered: