Skip to content
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

Fix CI errors #398

Merged
merged 3 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions aya/src/maps/hash_map/hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,10 @@ mod tests {
}

#[test]
// Syscall overrides are performing integer-to-pointer conversions, which
// should be done with `ptr::from_exposed_addr` in Rust nightly, but we have
// to support stable as well.
#[cfg_attr(miri, ignore)]
fn test_keys() {
override_syscall(|call| match call {
Syscall::Bpf {
Expand All @@ -497,6 +501,10 @@ mod tests {
}

#[test]
// Syscall overrides are performing integer-to-pointer conversions, which
// should be done with `ptr::from_exposed_addr` in Rust nightly, but we have
// to support stable as well.
#[cfg_attr(miri, ignore)]
fn test_keys_error() {
override_syscall(|call| match call {
Syscall::Bpf {
Expand Down Expand Up @@ -532,6 +540,10 @@ mod tests {
}

#[test]
// Syscall overrides are performing integer-to-pointer conversions, which
// should be done with `ptr::from_exposed_addr` in Rust nightly, but we have
// to support stable as well.
#[cfg_attr(miri, ignore)]
fn test_iter() {
override_syscall(|call| match call {
Syscall::Bpf {
Expand All @@ -556,6 +568,10 @@ mod tests {
}

#[test]
// Syscall overrides are performing integer-to-pointer conversions, which
// should be done with `ptr::from_exposed_addr` in Rust nightly, but we have
// to support stable as well.
#[cfg_attr(miri, ignore)]
fn test_iter_key_deleted() {
override_syscall(|call| match call {
Syscall::Bpf {
Expand Down Expand Up @@ -591,6 +607,10 @@ mod tests {
}

#[test]
// Syscall overrides are performing integer-to-pointer conversions, which
// should be done with `ptr::from_exposed_addr` in Rust nightly, but we have
// to support stable as well.
#[cfg_attr(miri, ignore)]
fn test_iter_key_error() {
override_syscall(|call| match call {
Syscall::Bpf {
Expand Down Expand Up @@ -632,6 +652,10 @@ mod tests {
}

#[test]
// Syscall overrides are performing integer-to-pointer conversions, which
// should be done with `ptr::from_exposed_addr` in Rust nightly, but we have
// to support stable as well.
#[cfg_attr(miri, ignore)]
fn test_iter_value_error() {
override_syscall(|call| match call {
Syscall::Bpf {
Expand Down
12 changes: 6 additions & 6 deletions aya/src/obj/btf/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -894,12 +894,12 @@ unsafe fn read_array<T>(data: &[u8], len: usize) -> Result<Vec<T>, BtfError> {
if mem::size_of::<T>() * len > data.len() {
return Err(BtfError::InvalidTypeInfo);
}

Ok((0..len)
.map(|i| {
ptr::read_unaligned::<T>((data.as_ptr() as usize + i * mem::size_of::<T>()) as *const T)
})
.collect::<Vec<T>>())
let data = &data[0..mem::size_of::<T>() * len];
let r = data
.chunks(mem::size_of::<T>())
.map(|chunk| ptr::read_unaligned(chunk.as_ptr() as *const T))
.collect();
Ok(r)
}

impl BtfType {
Expand Down
11 changes: 3 additions & 8 deletions aya/src/obj/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1348,15 +1348,10 @@ pub(crate) fn copy_instructions(data: &[u8]) -> Result<Vec<bpf_insn>, ParseError
if data.len() % mem::size_of::<bpf_insn>() > 0 {
return Err(ParseError::InvalidProgramCode);
}
let num_instructions = data.len() / mem::size_of::<bpf_insn>();
let instructions = (0..num_instructions)
.map(|i| unsafe {
ptr::read_unaligned(
(data.as_ptr() as usize + i * mem::size_of::<bpf_insn>()) as *const bpf_insn,
)
})
let instructions = data
.chunks_exact(mem::size_of::<bpf_insn>())
.map(|d| unsafe { ptr::read_unaligned(d.as_ptr() as *const bpf_insn) })
.collect::<Vec<_>>();

Ok(instructions)
}

Expand Down
47 changes: 0 additions & 47 deletions test/integration-ebpf/src/bpf/multimap.bpf.c

This file was deleted.

11 changes: 0 additions & 11 deletions test/integration-test/src/tests/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,6 @@ fn long_name() -> anyhow::Result<()> {
Ok(())
}

#[integration_test]
fn multiple_maps() -> anyhow::Result<()> {
let bytes =
include_bytes_aligned!("../../../../target/bpfel-unknown-none/debug/multimap.bpf.o");
let mut bpf = Bpf::load(bytes)?;
let pass: &mut Xdp = bpf.program_mut("stats").unwrap().try_into().unwrap();
pass.load().unwrap();
pass.attach("lo", XdpFlags::default()).unwrap();
Ok(())
}

#[integration_test]
fn multiple_btf_maps() -> anyhow::Result<()> {
let bytes =
Expand Down