-
Notifications
You must be signed in to change notification settings - Fork 311
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
feat: Add set
for Array<T>
#1005
feat: Add set
for Array<T>
#1005
Conversation
✅ Deploy Preview for aya-rs-docs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
ping |
Needs tests. |
To be precise - a great place to add tests would be https://github.com/aya-rs/aya/blob/main/test/integration-ebpf/src/map_test.rs A simple |
Ok, I'll add tests tomorrow |
4f0b904
to
5458de0
Compare
I've already added a test and rebased the branch to the latest version. Could you please review it? Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 3 files at r1, all commit messages.
Reviewable status: 1 of 3 files reviewed, 4 unresolved discussions (waiting on @fslongjin)
ebpf/aya-ebpf/src/maps/array.rs
line 8 at r1 (raw file):
use crate::{ bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_ARRAY}, helpers::bpf_map_lookup_elem,
can you put bpf_map_update_elem
here?
ebpf/aya-ebpf/src/maps/array.rs
line 78 at r1 (raw file):
/// Sets the value of the element at the given index. pub fn set(&self, index: u32, value: &T, flags: u64) -> Result<(), c_long> { insert(self.def.get(), &index, value, flags)
lookup
above is unsafe, why is this one safe? why do we need the insert
helper?
ebpf/aya-ebpf/src/maps/array.rs
line 92 at r1 (raw file):
) }; (ret == 0).then_some(()).ok_or(ret)
why are we making an option only to turn it into a result?
match unsafe {
bpf_map_update_elem(
def as *mut _,
key as *const _ as *const _,
value as *const _ as *const _,
flags,
)
} {
0 => Ok(())
ret => Err(ret),
}
Code quote:
let ret = unsafe {
bpf_map_update_elem(
def as *mut _,
key as *const _ as *const _,
value as *const _ as *const _,
flags,
)
};
(ret == 0).then_some(()).ok_or(ret)
test/integration-test/src/tests/smoke.rs
line 74 at r1 (raw file):
#[test] fn map_set() {
i don't think this is an appropriate place for this test. this file is called "smoke" because it is testing only loading and attaching programs, and what you're doing here is different. please have a look at the other tests that do more sophisticated things.
@fslongjin are you planning to work on this? |
These functions (and more) are duplicated all over the place.
573f590
to
488e5c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that this is basically a 1-liner, I think we can forgo the tests.
Reviewable status: 0 of 12 files reviewed, all discussions resolved
ebpf/aya-ebpf/src/maps/array.rs
line 8 at r1 (raw file):
Previously, tamird (Tamir Duberstein) wrote…
can you put
bpf_map_update_elem
here?
Done.
Signed-off-by: jinlong <[email protected]>
488e5c5
to
3decd82
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 9 of 12 files at r2, 2 of 3 files at r3, 2 of 2 files at r5, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @vadorovsky)
Add
set()
function forArray<T>
This change is