aya icon indicating copy to clipboard operation
aya copied to clipboard

aya-bpf: why BPF_MAP_TYPE_ARRAY doesn't have get_mut() method?

Open zzzz465 opened this issue 3 years ago • 4 comments

in aya, Array has set() method https://github.com/aya-rs/aya/blob/main/aya/src/maps/array/array.rs#L115-L125

...but aya-bpf Array doesn't. why? https://github.com/aya-rs/aya/blob/main/bpf/aya-bpf/src/maps/array.rs#L19-L60

I thought BPF_MAP_TYPE_ARRAY is mutable from bpf side. am I missing something? https://prototype-kernel.readthedocs.io/en/latest/bpf/ebpf_maps_types.html

zzzz465 avatar Oct 05 '22 11:10 zzzz465

It's indeed mutable. I already have a PR adding get_ptr and get_mut_ptr methods. I can also add a set/insert method there.

vadorovsky avatar Oct 05 '22 11:10 vadorovsky

@vadorovsky looks like we still don't have get_mut?

tamird avatar Jul 19 '23 09:07 tamird

@vadorovsky looks like we still don't have get_mut?

It has get_ptr_mut as the other map do.

https://github.com/aya-rs/aya/blob/33baf7ef2203a27c69ff640d17fb382fca870c5c/bpf/aya-bpf/src/maps/array.rs#L61-L64

I don't think we have get_mut methods on any map type anymore, but I would have to scroll Discord to search for the reason why we dropped get_mut (returning &mut T) in favor of get_ptr_mut (returning *mut T).

The question is whether we want to have set() method, to give people better API then using raw pointers. I can work on that.

vadorovsky avatar Jul 19 '23 12:07 vadorovsky