Open dave-tucker opened 3 years ago
Hi, is this feature ready now? In my usecases, I want to create maps in userspace dynamically. There is a function bcc_create_map
in bcc. I wonder how to do this in aya. :)
Hiya @loheagn This isn't implemented yet, but I might be able to pick it up here soon! Will post back here with updates.
Hiya @loheagn This isn't implemented yet, but I might be able to pick it up here soon! Will post back here with updates.
@astoycos Thanks! I found the function aya::maps::MapData::create
, can I use this function to create maps? Do you have any suggestions?
So aya::maps::MapData::create takes
obj: obj::Map,
name: &str,
btf_fd: Option<BorrowedFd<'_>>,
as args meaning the map was defined in bytecode, and I don't think it was designed to be used directly (maybe this function shouldn't actually be public 🤔 ).
The API which @dave-tucker describes above allows direct instantiation of Maps with simple data such as K/V types+size along with pin path etc.
So aya::maps::MapData::create takes
obj: obj::Map, name: &str, btf_fd: Option<BorrowedFd<'_>>,
as args meaning the map was defined in bytecode, and I don't think it was designed to be used directly (maybe this function shouldn't actually be public 🤔 ).
The API which @dave-tucker describes above allows direct instantiation of Maps with simple data such as K/V types+size along with pin path etc.
@astoycos I see the differences. Then I may need some workaround. Thanks again!
@loheagn PTAL at https://github.com/aya-rs/aya/issues/837 as it aligns with this
It would be nice if maps could be created from user-space before the program is loaded. This gives more granular control over which maps should (or should not) be pinned than what is available in #45.
As for the API, it's going to be a fairly big change and requires a bit of upfront design.
Typed maps could be able to be instantiated directly, like in the
bpf
crate, but we'd make the syscalls immediately (or in the case of pinning and the map exists, the use that instead).The only complication is that created maps need to be available to
Bpf::load
so we can perform relocations. In which case we'd need to somehow register created maps with theBpf
struct and make ensure that all load functions have a reference to&self