Change from Rust edition 2018 to 2021

Rust 2021 adds more core prelude imports, including `TryFrom` and
`TryInto`.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
pull/368/head
Michal Rostecki 2 years ago committed by Alessandro Decina
parent c713dde061
commit 944d6b8a16

@ -75,7 +75,6 @@ Aya supports a large chunk of the eBPF API. The following example shows how to u
```rust ```rust
use std::fs::File; use std::fs::File;
use std::convert::TryInto;
use aya::Bpf; use aya::Bpf;
use aya::programs::{CgroupSkb, CgroupSkbAttachType}; use aya::programs::{CgroupSkb, CgroupSkbAttachType};

@ -2,7 +2,7 @@
name = "aya-bpf-macros" name = "aya-bpf-macros"
version = "0.1.0" version = "0.1.0"
authors = ["Alessandro Decina <alessandro.d@gmail.com>"] authors = ["Alessandro Decina <alessandro.d@gmail.com>"]
edition = "2018" edition = "2021"
[lib] [lib]
proc-macro = true proc-macro = true

@ -2,7 +2,7 @@
name = "aya-gen" name = "aya-gen"
version = "0.1.0" version = "0.1.0"
authors = ["Alessandro Decina <alessandro.d@gmail.com>"] authors = ["Alessandro Decina <alessandro.d@gmail.com>"]
edition = "2018" edition = "2021"
[dependencies] [dependencies]
bindgen = "0.60" bindgen = "0.60"

@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
authors = ["The Aya Contributors"] authors = ["The Aya Contributors"]
repository = "https://github.com/aya-rs/aya-log" repository = "https://github.com/aya-rs/aya-log"
documentation = "https://docs.rs/aya-log" documentation = "https://docs.rs/aya-log"
edition = "2018" edition = "2021"
[features] [features]
default = [] default = []

@ -1,7 +1,7 @@
[package] [package]
name = "aya-log-ebpf-macros" name = "aya-log-ebpf-macros"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]
proc-macro2 = "1.0" proc-macro2 = "1.0"

@ -8,7 +8,7 @@ authors = ["The Aya Contributors"]
repository = "https://github.com/aya-rs/aya-log" repository = "https://github.com/aya-rs/aya-log"
readme = "README.md" readme = "README.md"
documentation = "https://docs.rs/aya-log" documentation = "https://docs.rs/aya-log"
edition = "2018" edition = "2021"
[dependencies] [dependencies]
aya = { path = "../aya", version = "0.11.0", features=["async_tokio"] } aya = { path = "../aya", version = "0.11.0", features=["async_tokio"] }

@ -49,7 +49,7 @@
//! [Log]: https://docs.rs/log/0.4.14/log/trait.Log.html //! [Log]: https://docs.rs/log/0.4.14/log/trait.Log.html
//! [log]: https://docs.rs/log //! [log]: https://docs.rs/log
//! //!
use std::{convert::TryInto, io, mem, ptr, str, sync::Arc}; use std::{io, mem, ptr, str, sync::Arc};
use aya_log_common::{ArgType, RecordField, LOG_BUF_CAPACITY, LOG_FIELDS}; use aya_log_common::{ArgType, RecordField, LOG_BUF_CAPACITY, LOG_FIELDS};
use bytes::BytesMut; use bytes::BytesMut;

@ -8,7 +8,7 @@ authors = ["The Aya Contributors"]
repository = "https://github.com/aya-rs/aya" repository = "https://github.com/aya-rs/aya"
readme = "README.md" readme = "README.md"
documentation = "https://docs.rs/aya" documentation = "https://docs.rs/aya"
edition = "2018" edition = "2021"
[dependencies] [dependencies]
libc = { version = "0.2.105" } libc = { version = "0.2.105" }

@ -75,7 +75,6 @@ Aya supports a large chunk of the eBPF API. The following example shows how to u
```rust ```rust
use std::fs::File; use std::fs::File;
use std::convert::TryInto;
use aya::Bpf; use aya::Bpf;
use aya::programs::{CgroupSkb, CgroupSkbAttachType}; use aya::programs::{CgroupSkb, CgroupSkbAttachType};

@ -1,7 +1,6 @@
use std::{ use std::{
borrow::Cow, borrow::Cow,
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
convert::TryFrom,
error::Error, error::Error,
ffi::CString, ffi::CString,
fs, io, fs, io,
@ -743,7 +742,6 @@ impl Bpf {
/// ```no_run /// ```no_run
/// # let mut bpf = aya::Bpf::load(&[])?; /// # let mut bpf = aya::Bpf::load(&[])?;
/// use aya::programs::UProbe; /// use aya::programs::UProbe;
/// use std::convert::TryInto;
/// ///
/// let program: &mut UProbe = bpf.program_mut("SSL_read").unwrap().try_into()?; /// let program: &mut UProbe = bpf.program_mut("SSL_read").unwrap().try_into()?;
/// program.load()?; /// program.load()?;

@ -1,5 +1,4 @@
use std::{ use std::{
convert::TryFrom,
marker::PhantomData, marker::PhantomData,
mem, mem,
ops::{Deref, DerefMut}, ops::{Deref, DerefMut},
@ -25,7 +24,6 @@ use crate::{
/// ```no_run /// ```no_run
/// # let bpf = aya::Bpf::load(&[])?; /// # let bpf = aya::Bpf::load(&[])?;
/// use aya::maps::Array; /// use aya::maps::Array;
/// use std::convert::TryFrom;
/// ///
/// let mut array = Array::try_from(bpf.map_mut("ARRAY")?)?; /// let mut array = Array::try_from(bpf.map_mut("ARRAY")?)?;
/// array.set(1, 42, 0)?; /// array.set(1, 42, 0)?;

@ -1,5 +1,4 @@
use std::{ use std::{
convert::TryFrom,
marker::PhantomData, marker::PhantomData,
mem, mem,
ops::{Deref, DerefMut}, ops::{Deref, DerefMut},
@ -35,7 +34,6 @@ use crate::{
/// # let bpf = aya::Bpf::load(&[])?; /// # let bpf = aya::Bpf::load(&[])?;
/// use aya::maps::{PerCpuArray, PerCpuValues}; /// use aya::maps::{PerCpuArray, PerCpuValues};
/// use aya::util::nr_cpus; /// use aya::util::nr_cpus;
/// use std::convert::TryFrom;
/// ///
/// let mut array = PerCpuArray::try_from(bpf.map_mut("ARRAY")?)?; /// let mut array = PerCpuArray::try_from(bpf.map_mut("ARRAY")?)?;
/// ///

@ -1,7 +1,6 @@
//! An array of eBPF program file descriptors used as a jump table. //! An array of eBPF program file descriptors used as a jump table.
use std::{ use std::{
convert::TryFrom,
mem, mem,
ops::{Deref, DerefMut}, ops::{Deref, DerefMut},
os::unix::prelude::{AsRawFd, RawFd}, os::unix::prelude::{AsRawFd, RawFd},
@ -29,7 +28,6 @@ use crate::{
/// # let mut bpf = aya::Bpf::load(&[])?; /// # let mut bpf = aya::Bpf::load(&[])?;
/// use aya::maps::ProgramArray; /// use aya::maps::ProgramArray;
/// use aya::programs::CgroupSkb; /// use aya::programs::CgroupSkb;
/// use std::convert::{TryFrom, TryInto};
/// ///
/// let mut prog_array = ProgramArray::try_from(bpf.map_mut("JUMP_TABLE")?)?; /// let mut prog_array = ProgramArray::try_from(bpf.map_mut("JUMP_TABLE")?)?;
/// let prog_0: &CgroupSkb = bpf.program("example_prog_0").unwrap().try_into()?; /// let prog_0: &CgroupSkb = bpf.program("example_prog_0").unwrap().try_into()?;

@ -1,5 +1,5 @@
//! A Bloom Filter. //! A Bloom Filter.
use std::{convert::TryFrom, marker::PhantomData, ops::Deref}; use std::{marker::PhantomData, ops::Deref};
use core::mem; use core::mem;
@ -21,7 +21,6 @@ use crate::{
/// ```no_run /// ```no_run
/// # let bpf = aya::Bpf::load(&[])?; /// # let bpf = aya::Bpf::load(&[])?;
/// use aya::maps::bloom_filter::BloomFilter; /// use aya::maps::bloom_filter::BloomFilter;
/// use std::convert::TryFrom;
/// ///
/// let mut bloom_filter = BloomFilter::try_from(bpf.map_mut("BLOOM_FILTER")?)?; /// let mut bloom_filter = BloomFilter::try_from(bpf.map_mut("BLOOM_FILTER")?)?;
/// ///

@ -1,5 +1,4 @@
use std::{ use std::{
convert::TryFrom,
marker::PhantomData, marker::PhantomData,
ops::{Deref, DerefMut}, ops::{Deref, DerefMut},
}; };
@ -22,7 +21,6 @@ use crate::{
/// ```no_run /// ```no_run
/// # let bpf = aya::Bpf::load(&[])?; /// # let bpf = aya::Bpf::load(&[])?;
/// use aya::maps::HashMap; /// use aya::maps::HashMap;
/// use std::convert::TryFrom;
/// ///
/// let mut redirect_ports = HashMap::try_from(bpf.map_mut("REDIRECT_PORTS")?)?; /// let mut redirect_ports = HashMap::try_from(bpf.map_mut("REDIRECT_PORTS")?)?;
/// ///

@ -1,6 +1,5 @@
//! Per-CPU hash map. //! Per-CPU hash map.
use std::{ use std::{
convert::TryFrom,
marker::PhantomData, marker::PhantomData,
ops::{Deref, DerefMut}, ops::{Deref, DerefMut},
}; };
@ -29,7 +28,6 @@ use crate::{
/// ```no_run /// ```no_run
/// # let bpf = aya::Bpf::load(&[])?; /// # let bpf = aya::Bpf::load(&[])?;
/// use aya::maps::PerCpuHashMap; /// use aya::maps::PerCpuHashMap;
/// use std::convert::TryFrom;
/// ///
/// const CPU_IDS: u8 = 1; /// const CPU_IDS: u8 = 1;
/// const WAKEUPS: u8 = 2; /// const WAKEUPS: u8 = 2;
@ -116,7 +114,6 @@ impl<T: DerefMut<Target = Map>, K: Pod, V: Pod> PerCpuHashMap<T, K, V> {
/// # let bpf = aya::Bpf::load(&[])?; /// # let bpf = aya::Bpf::load(&[])?;
/// use aya::maps::{PerCpuHashMap, PerCpuValues}; /// use aya::maps::{PerCpuHashMap, PerCpuValues};
/// use aya::util::nr_cpus; /// use aya::util::nr_cpus;
/// use std::convert::TryFrom;
/// ///
/// const RETRIES: u8 = 1; /// const RETRIES: u8 = 1;
/// ///

@ -1,5 +1,5 @@
//! A LPM Trie. //! A LPM Trie.
use std::{convert::TryFrom, marker::PhantomData, mem, ops::Deref}; use std::{marker::PhantomData, mem, ops::Deref};
use crate::{ use crate::{
generated::bpf_map_type::BPF_MAP_TYPE_LPM_TRIE, generated::bpf_map_type::BPF_MAP_TYPE_LPM_TRIE,
@ -19,7 +19,6 @@ use crate::{
/// ```no_run /// ```no_run
/// # let bpf = aya::Bpf::load(&[])?; /// # let bpf = aya::Bpf::load(&[])?;
/// use aya::maps::lpm_trie::{LpmTrie, Key}; /// use aya::maps::lpm_trie::{LpmTrie, Key};
/// use std::convert::TryFrom;
/// use std::net::Ipv4Addr; /// use std::net::Ipv4Addr;
/// ///
/// let mut trie = LpmTrie::try_from(bpf.map_mut("LPM_TRIE")?)?; /// let mut trie = LpmTrie::try_from(bpf.map_mut("LPM_TRIE")?)?;
@ -56,7 +55,6 @@ pub struct LpmTrie<T: Deref<Target = Map>, K, V> {
/// ///
/// ```no_run /// ```no_run
/// use aya::maps::lpm_trie::{LpmTrie, Key}; /// use aya::maps::lpm_trie::{LpmTrie, Key};
/// use std::convert::TryFrom;
/// use std::net::Ipv4Addr; /// use std::net::Ipv4Addr;
/// ///
/// let ipaddr = Ipv4Addr::new(8,8,8,8); /// let ipaddr = Ipv4Addr::new(8,8,8,8);
@ -77,7 +75,6 @@ impl<K: Pod> Key<K> {
/// ///
/// ```no_run /// ```no_run
/// use aya::maps::lpm_trie::{LpmTrie, Key}; /// use aya::maps::lpm_trie::{LpmTrie, Key};
/// use std::convert::TryFrom;
/// use std::net::Ipv4Addr; /// use std::net::Ipv4Addr;
/// ///
/// let ipaddr = Ipv4Addr::new(8, 8, 8, 8); /// let ipaddr = Ipv4Addr::new(8, 8, 8, 8);

@ -16,7 +16,6 @@
//! //!
//! ```no_run //! ```no_run
//! # let mut bpf = aya::Bpf::load(&[])?; //! # let mut bpf = aya::Bpf::load(&[])?;
//! use std::convert::{TryFrom, TryInto};
//! use aya::maps::SockMap; //! use aya::maps::SockMap;
//! use aya::programs::SkMsg; //! use aya::programs::SkMsg;
//! //!
@ -33,7 +32,6 @@
//! versa. Because of that, all map values must be plain old data and therefore //! versa. Because of that, all map values must be plain old data and therefore
//! implement the [Pod] trait. //! implement the [Pod] trait.
use std::{ use std::{
convert::{TryFrom, TryInto},
ffi::CString, ffi::CString,
fmt, io, fmt, io,
marker::PhantomData, marker::PhantomData,
@ -523,7 +521,6 @@ impl PerCpuKernelMem {
/// # let bpf = aya::Bpf::load(&[])?; /// # let bpf = aya::Bpf::load(&[])?;
/// use aya::maps::PerCpuValues; /// use aya::maps::PerCpuValues;
/// use aya::util::nr_cpus; /// use aya::util::nr_cpus;
/// use std::convert::TryFrom;
/// ///
/// let values = PerCpuValues::try_from(vec![42u32; nr_cpus()?])?; /// let values = PerCpuValues::try_from(vec![42u32; nr_cpus()?])?;
/// # Ok::<(), Error>(()) /// # Ok::<(), Error>(())

@ -1,6 +1,5 @@
use bytes::BytesMut; use bytes::BytesMut;
use std::{ use std::{
convert::TryFrom,
ops::DerefMut, ops::DerefMut,
os::unix::prelude::{AsRawFd, RawFd}, os::unix::prelude::{AsRawFd, RawFd},
}; };
@ -49,7 +48,6 @@ use crate::maps::{
/// # let bpf = aya::Bpf::load(&[])?; /// # let bpf = aya::Bpf::load(&[])?;
/// use aya::maps::perf::{AsyncPerfEventArray, PerfBufferError}; /// use aya::maps::perf::{AsyncPerfEventArray, PerfBufferError};
/// use aya::util::online_cpus; /// use aya::util::online_cpus;
/// use std::convert::TryFrom;
/// use futures::future; /// use futures::future;
/// use bytes::BytesMut; /// use bytes::BytesMut;
/// use tokio::task; // or async_std::task /// use tokio::task; // or async_std::task

@ -318,7 +318,7 @@ mod tests {
generated::perf_event_mmap_page, generated::perf_event_mmap_page,
sys::{override_syscall, Syscall, TEST_MMAP_RET}, sys::{override_syscall, Syscall, TEST_MMAP_RET},
}; };
use std::{convert::TryInto, fmt::Debug, mem}; use std::{fmt::Debug, mem};
const PAGE_SIZE: usize = 4096; const PAGE_SIZE: usize = 4096;
union MMappedBuf { union MMappedBuf {

@ -2,7 +2,6 @@
//! //!
//! [`perf`]: https://perf.wiki.kernel.org/index.php/Main_Page. //! [`perf`]: https://perf.wiki.kernel.org/index.php/Main_Page.
use std::{ use std::{
convert::TryFrom,
ops::DerefMut, ops::DerefMut,
os::unix::io::{AsRawFd, RawFd}, os::unix::io::{AsRawFd, RawFd},
sync::Arc, sync::Arc,
@ -109,7 +108,6 @@ impl<T: DerefMut<Target = Map>> AsRawFd for PerfEventArrayBuffer<T> {
/// # let bpf = aya::Bpf::load(&[])?; /// # let bpf = aya::Bpf::load(&[])?;
/// use aya::maps::PerfEventArray; /// use aya::maps::PerfEventArray;
/// use aya::util::online_cpus; /// use aya::util::online_cpus;
/// use std::convert::{TryFrom, TryInto};
/// use bytes::BytesMut; /// use bytes::BytesMut;
/// ///
/// let mut perf_array = PerfEventArray::try_from(bpf.map_mut("EVENTS")?)?; /// let mut perf_array = PerfEventArray::try_from(bpf.map_mut("EVENTS")?)?;

@ -1,6 +1,5 @@
//! A FIFO queue. //! A FIFO queue.
use std::{ use std::{
convert::TryFrom,
marker::PhantomData, marker::PhantomData,
mem, mem,
ops::{Deref, DerefMut}, ops::{Deref, DerefMut},
@ -23,7 +22,6 @@ use crate::{
/// ```no_run /// ```no_run
/// # let bpf = aya::Bpf::load(&[])?; /// # let bpf = aya::Bpf::load(&[])?;
/// use aya::maps::Queue; /// use aya::maps::Queue;
/// use std::convert::TryFrom;
/// ///
/// let mut queue = Queue::try_from(bpf.map_mut("ARRAY")?)?; /// let mut queue = Queue::try_from(bpf.map_mut("ARRAY")?)?;
/// queue.push(42, 0)?; /// queue.push(42, 0)?;

@ -1,5 +1,4 @@
use std::{ use std::{
convert::TryFrom,
marker::PhantomData, marker::PhantomData,
ops::{Deref, DerefMut}, ops::{Deref, DerefMut},
os::unix::io::{AsRawFd, RawFd}, os::unix::io::{AsRawFd, RawFd},
@ -42,7 +41,6 @@ use crate::{
/// # Bpf(#[from] aya::BpfError) /// # Bpf(#[from] aya::BpfError)
/// # } /// # }
/// # let mut bpf = aya::Bpf::load(&[])?; /// # let mut bpf = aya::Bpf::load(&[])?;
/// use std::convert::{TryFrom, TryInto};
/// use std::io::Write; /// use std::io::Write;
/// use std::net::TcpStream; /// use std::net::TcpStream;
/// use std::os::unix::io::AsRawFd; /// use std::os::unix::io::AsRawFd;

@ -1,7 +1,6 @@
//! An array of eBPF program file descriptors used as a jump table. //! An array of eBPF program file descriptors used as a jump table.
use std::{ use std::{
convert::TryFrom,
mem, mem,
ops::{Deref, DerefMut}, ops::{Deref, DerefMut},
os::unix::{io::AsRawFd, prelude::RawFd}, os::unix::{io::AsRawFd, prelude::RawFd},
@ -30,7 +29,6 @@ use crate::{
/// ///
/// ```no_run /// ```no_run
/// # let mut bpf = aya::Bpf::load(&[])?; /// # let mut bpf = aya::Bpf::load(&[])?;
/// use std::convert::{TryFrom, TryInto};
/// use aya::maps::SockMap; /// use aya::maps::SockMap;
/// use aya::programs::SkSkb; /// use aya::programs::SkSkb;
/// ///

@ -1,6 +1,5 @@
//! A LIFO stack. //! A LIFO stack.
use std::{ use std::{
convert::TryFrom,
marker::PhantomData, marker::PhantomData,
mem, mem,
ops::{Deref, DerefMut}, ops::{Deref, DerefMut},
@ -23,7 +22,6 @@ use crate::{
/// ```no_run /// ```no_run
/// # let bpf = aya::Bpf::load(&[])?; /// # let bpf = aya::Bpf::load(&[])?;
/// use aya::maps::Stack; /// use aya::maps::Stack;
/// use std::convert::TryFrom;
/// ///
/// let mut stack = Stack::try_from(bpf.map_mut("STACK")?)?; /// let mut stack = Stack::try_from(bpf.map_mut("STACK")?)?;
/// stack.push(42, 0)?; /// stack.push(42, 0)?;

@ -1,9 +1,7 @@
//! A hash map of kernel or user space stack traces. //! A hash map of kernel or user space stack traces.
//! //!
//! See [`StackTraceMap`] for documentation and examples. //! See [`StackTraceMap`] for documentation and examples.
use std::{ use std::{collections::BTreeMap, fs, io, mem, ops::Deref, path::Path, str::FromStr};
collections::BTreeMap, convert::TryFrom, fs, io, mem, ops::Deref, path::Path, str::FromStr,
};
use crate::{ use crate::{
generated::bpf_map_type::BPF_MAP_TYPE_STACK_TRACE, generated::bpf_map_type::BPF_MAP_TYPE_STACK_TRACE,
@ -37,7 +35,6 @@ use crate::{
/// # let bpf = aya::Bpf::load(&[])?; /// # let bpf = aya::Bpf::load(&[])?;
/// use aya::maps::StackTraceMap; /// use aya::maps::StackTraceMap;
/// use aya::util::kernel_symbols; /// use aya::util::kernel_symbols;
/// use std::convert::TryFrom;
/// ///
/// let mut stack_traces = StackTraceMap::try_from(bpf.map("STACK_TRACES")?)?; /// let mut stack_traces = StackTraceMap::try_from(bpf.map("STACK_TRACES")?)?;
/// // load kernel symbols from /proc/kallsyms /// // load kernel symbols from /proc/kallsyms

@ -1,7 +1,6 @@
use std::{ use std::{
borrow::Cow, borrow::Cow,
collections::HashMap, collections::HashMap,
convert::TryInto,
ffi::{c_void, CStr, CString}, ffi::{c_void, CStr, CString},
fs, io, mem, fs, io, mem,
path::{Path, PathBuf}, path::{Path, PathBuf},

@ -1,4 +1,4 @@
use std::{collections::HashMap, convert::TryInto}; use std::collections::HashMap;
use bytes::BufMut; use bytes::BufMut;
use object::Endianness; use object::Endianness;

@ -1,9 +1,4 @@
use std::{ use std::{collections::HashMap, io, mem, ptr, str::FromStr};
collections::HashMap,
convert::{TryFrom, TryInto},
io, mem, ptr,
str::FromStr,
};
use thiserror::Error; use thiserror::Error;

@ -1,8 +1,4 @@
use std::{ use std::{fmt::Display, mem, ptr};
convert::{TryFrom, TryInto},
fmt::Display,
mem, ptr,
};
use object::Endianness; use object::Endianness;

@ -9,7 +9,6 @@ use object::{
}; };
use std::{ use std::{
collections::HashMap, collections::HashMap,
convert::{TryFrom, TryInto},
ffi::{CStr, CString}, ffi::{CStr, CString},
mem, ptr, mem, ptr,
str::FromStr, str::FromStr,

@ -44,7 +44,6 @@ use crate::{
/// # } /// # }
/// # let mut bpf = aya::Bpf::load(&[])?; /// # let mut bpf = aya::Bpf::load(&[])?;
/// use std::fs::File; /// use std::fs::File;
/// use std::convert::TryInto;
/// use aya::programs::{CgroupSkb, CgroupSkbAttachType}; /// use aya::programs::{CgroupSkb, CgroupSkbAttachType};
/// ///
/// let file = File::open("/sys/fs/cgroup/unified")?; /// let file = File::open("/sys/fs/cgroup/unified")?;

@ -43,7 +43,6 @@ use crate::{
/// # } /// # }
/// # let mut bpf = aya::Bpf::load(&[])?; /// # let mut bpf = aya::Bpf::load(&[])?;
/// use std::fs::File; /// use std::fs::File;
/// use std::convert::TryInto;
/// use aya::programs::{CgroupSock, CgroupSockAttachType}; /// use aya::programs::{CgroupSock, CgroupSockAttachType};
/// ///
/// let file = File::open("/sys/fs/cgroup/unified")?; /// let file = File::open("/sys/fs/cgroup/unified")?;

@ -44,7 +44,6 @@ use crate::{
/// # } /// # }
/// # let mut bpf = aya::Bpf::load(&[])?; /// # let mut bpf = aya::Bpf::load(&[])?;
/// use std::fs::File; /// use std::fs::File;
/// use std::convert::TryInto;
/// use aya::programs::{CgroupSockAddr, CgroupSockAddrAttachType}; /// use aya::programs::{CgroupSockAddr, CgroupSockAddrAttachType};
/// ///
/// let file = File::open("/sys/fs/cgroup/unified")?; /// let file = File::open("/sys/fs/cgroup/unified")?;

@ -40,7 +40,6 @@ use crate::{
/// # } /// # }
/// # let mut bpf = aya::Bpf::load(&[])?; /// # let mut bpf = aya::Bpf::load(&[])?;
/// use std::fs::File; /// use std::fs::File;
/// use std::convert::TryInto;
/// use aya::programs::CgroupSockopt; /// use aya::programs::CgroupSockopt;
/// ///
/// let file = File::open("/sys/fs/cgroup/unified")?; /// let file = File::open("/sys/fs/cgroup/unified")?;

@ -38,7 +38,6 @@ use crate::{
/// # } /// # }
/// # let mut bpf = aya::Bpf::load(&[])?; /// # let mut bpf = aya::Bpf::load(&[])?;
/// use std::fs::File; /// use std::fs::File;
/// use std::convert::TryInto;
/// use aya::programs::CgroupSysctl; /// use aya::programs::CgroupSysctl;
/// ///
/// let file = File::open("/sys/fs/cgroup/unified")?; /// let file = File::open("/sys/fs/cgroup/unified")?;

@ -36,7 +36,6 @@ pub enum ExtensionError {
/// ///
/// ```no_run /// ```no_run
/// use aya::{BpfLoader, programs::{Xdp, XdpFlags, Extension}}; /// use aya::{BpfLoader, programs::{Xdp, XdpFlags, Extension}};
/// use std::convert::TryInto;
/// ///
/// let mut bpf = BpfLoader::new().extension("extension").load_file("app.o")?; /// let mut bpf = BpfLoader::new().extension("extension").load_file("app.o")?;
/// let prog: &mut Xdp = bpf.program_mut("main").unwrap().try_into()?; /// let prog: &mut Xdp = bpf.program_mut("main").unwrap().try_into()?;

@ -35,7 +35,6 @@ use crate::{
/// # } /// # }
/// # let mut bpf = Bpf::load_file("ebpf_programs.o")?; /// # let mut bpf = Bpf::load_file("ebpf_programs.o")?;
/// use aya::{Bpf, programs::FEntry, BtfError, Btf}; /// use aya::{Bpf, programs::FEntry, BtfError, Btf};
/// use std::convert::TryInto;
/// ///
/// let btf = Btf::from_sys_fs()?; /// let btf = Btf::from_sys_fs()?;
/// let program: &mut FEntry = bpf.program_mut("filename_lookup").unwrap().try_into()?; /// let program: &mut FEntry = bpf.program_mut("filename_lookup").unwrap().try_into()?;

@ -35,7 +35,6 @@ use crate::{
/// # } /// # }
/// # let mut bpf = Bpf::load_file("ebpf_programs.o")?; /// # let mut bpf = Bpf::load_file("ebpf_programs.o")?;
/// use aya::{Bpf, programs::FExit, BtfError, Btf}; /// use aya::{Bpf, programs::FExit, BtfError, Btf};
/// use std::convert::TryInto;
/// ///
/// let btf = Btf::from_sys_fs()?; /// let btf = Btf::from_sys_fs()?;
/// let program: &mut FExit = bpf.program_mut("filename_lookup").unwrap().try_into()?; /// let program: &mut FExit = bpf.program_mut("filename_lookup").unwrap().try_into()?;

@ -29,7 +29,6 @@ use crate::{
/// ```no_run /// ```no_run
/// # let mut bpf = Bpf::load_file("ebpf_programs.o")?; /// # let mut bpf = Bpf::load_file("ebpf_programs.o")?;
/// use aya::{Bpf, programs::KProbe}; /// use aya::{Bpf, programs::KProbe};
/// use std::convert::TryInto;
/// ///
/// let program: &mut KProbe = bpf.program_mut("intercept_wakeups").unwrap().try_into()?; /// let program: &mut KProbe = bpf.program_mut("intercept_wakeups").unwrap().try_into()?;
/// program.load()?; /// program.load()?;

@ -36,7 +36,6 @@ use libc::{close, dup};
/// # } /// # }
/// # let mut bpf = aya::Bpf::load(&[])?; /// # let mut bpf = aya::Bpf::load(&[])?;
/// use std::fs::File; /// use std::fs::File;
/// use std::convert::TryInto;
/// use aya::programs::LircMode2; /// use aya::programs::LircMode2;
/// ///
/// let file = File::open("/dev/lirc0")?; /// let file = File::open("/dev/lirc0")?;

@ -36,7 +36,6 @@ use crate::{
/// # } /// # }
/// # let mut bpf = Bpf::load_file("ebpf_programs.o")?; /// # let mut bpf = Bpf::load_file("ebpf_programs.o")?;
/// use aya::{Bpf, programs::Lsm, BtfError, Btf}; /// use aya::{Bpf, programs::Lsm, BtfError, Btf};
/// use std::convert::TryInto;
/// ///
/// let btf = Btf::from_sys_fs()?; /// let btf = Btf::from_sys_fs()?;
/// let program: &mut Lsm = bpf.program_mut("lsm_prog").unwrap().try_into()?; /// let program: &mut Lsm = bpf.program_mut("lsm_prog").unwrap().try_into()?;

@ -15,7 +15,6 @@
//! //!
//! ```no_run //! ```no_run
//! use aya::{Bpf, programs::KProbe}; //! use aya::{Bpf, programs::KProbe};
//! use std::convert::TryInto;
//! //!
//! let mut bpf = Bpf::load_file("ebpf_programs.o")?; //! let mut bpf = Bpf::load_file("ebpf_programs.o")?;
//! // intercept_wakeups is the name of the program we want to load //! // intercept_wakeups is the name of the program we want to load
@ -66,7 +65,6 @@ pub mod xdp;
use libc::ENOSPC; use libc::ENOSPC;
use std::{ use std::{
convert::TryFrom,
ffi::CString, ffi::CString,
io, io,
os::unix::io::{AsRawFd, RawFd}, os::unix::io::{AsRawFd, RawFd},

@ -97,7 +97,6 @@ pub enum PerfEventScope {
/// # Bpf(#[from] aya::BpfError) /// # Bpf(#[from] aya::BpfError)
/// # } /// # }
/// # let mut bpf = aya::Bpf::load(&[])?; /// # let mut bpf = aya::Bpf::load(&[])?;
/// use std::convert::TryInto;
/// use aya::util::online_cpus; /// use aya::util::online_cpus;
/// use aya::programs::perf_event::{ /// use aya::programs::perf_event::{
/// perf_sw_ids::PERF_COUNT_SW_CPU_CLOCK, PerfEvent, PerfEventScope, PerfTypeId, SamplePolicy, /// perf_sw_ids::PERF_COUNT_SW_CPU_CLOCK, PerfEvent, PerfEventScope, PerfTypeId, SamplePolicy,

@ -26,7 +26,6 @@ use crate::{
/// ```no_run /// ```no_run
/// # let mut bpf = Bpf::load_file("ebpf_programs.o")?; /// # let mut bpf = Bpf::load_file("ebpf_programs.o")?;
/// use aya::{Bpf, programs::RawTracePoint}; /// use aya::{Bpf, programs::RawTracePoint};
/// use std::convert::TryInto;
/// ///
/// let program: &mut RawTracePoint = bpf.program_mut("sys_enter").unwrap().try_into()?; /// let program: &mut RawTracePoint = bpf.program_mut("sys_enter").unwrap().try_into()?;
/// program.load()?; /// program.load()?;

@ -36,7 +36,6 @@ use super::links::FdLink;
/// # } /// # }
/// # let mut bpf = aya::Bpf::load(&[])?; /// # let mut bpf = aya::Bpf::load(&[])?;
/// use std::fs::File; /// use std::fs::File;
/// use std::convert::TryInto;
/// use aya::programs::SkLookup; /// use aya::programs::SkLookup;
/// ///
/// let file = File::open("/var/run/netns/test")?; /// let file = File::open("/var/run/netns/test")?;

@ -34,7 +34,6 @@ use crate::{
/// # Bpf(#[from] aya::BpfError) /// # Bpf(#[from] aya::BpfError)
/// # } /// # }
/// # let mut bpf = aya::Bpf::load(&[])?; /// # let mut bpf = aya::Bpf::load(&[])?;
/// use std::convert::{TryFrom, TryInto};
/// use std::io::Write; /// use std::io::Write;
/// use std::net::TcpStream; /// use std::net::TcpStream;
/// use std::os::unix::io::AsRawFd; /// use std::os::unix::io::AsRawFd;

@ -35,7 +35,6 @@ pub enum SkSkbKind {
/// ///
/// ```no_run /// ```no_run
/// # let mut bpf = aya::Bpf::load(&[])?; /// # let mut bpf = aya::Bpf::load(&[])?;
/// use std::convert::{TryFrom, TryInto};
/// use aya::maps::SockMap; /// use aya::maps::SockMap;
/// use aya::programs::SkSkb; /// use aya::programs::SkSkb;
/// ///

@ -36,7 +36,6 @@ use crate::{
/// # } /// # }
/// # let mut bpf = aya::Bpf::load(&[])?; /// # let mut bpf = aya::Bpf::load(&[])?;
/// use std::fs::File; /// use std::fs::File;
/// use std::convert::TryInto;
/// use aya::programs::SockOps; /// use aya::programs::SockOps;
/// ///
/// let file = File::open("/sys/fs/cgroup/unified")?; /// let file = File::open("/sys/fs/cgroup/unified")?;

@ -47,7 +47,6 @@ pub enum SocketFilterError {
/// # Bpf(#[from] aya::BpfError) /// # Bpf(#[from] aya::BpfError)
/// # } /// # }
/// # let mut bpf = aya::Bpf::load(&[])?; /// # let mut bpf = aya::Bpf::load(&[])?;
/// use std::convert::TryInto;
/// use std::net::TcpStream; /// use std::net::TcpStream;
/// use std::os::unix::io::AsRawFd; /// use std::os::unix::io::AsRawFd;
/// use aya::programs::SocketFilter; /// use aya::programs::SocketFilter;

@ -55,7 +55,6 @@ pub enum TcAttachType {
/// # Bpf(#[from] aya::BpfError) /// # Bpf(#[from] aya::BpfError)
/// # } /// # }
/// # let mut bpf = aya::Bpf::load(&[])?; /// # let mut bpf = aya::Bpf::load(&[])?;
/// use std::convert::TryInto;
/// use aya::programs::{tc, SchedClassifier, TcAttachType}; /// use aya::programs::{tc, SchedClassifier, TcAttachType};
/// ///
/// // the clsact qdisc needs to be added before SchedClassifier programs can be /// // the clsact qdisc needs to be added before SchedClassifier programs can be

@ -33,7 +33,6 @@ use crate::{
/// # } /// # }
/// # let mut bpf = Bpf::load_file("ebpf_programs.o")?; /// # let mut bpf = Bpf::load_file("ebpf_programs.o")?;
/// use aya::{Bpf, programs::BtfTracePoint, BtfError, Btf}; /// use aya::{Bpf, programs::BtfTracePoint, BtfError, Btf};
/// use std::convert::TryInto;
/// ///
/// let btf = Btf::from_sys_fs()?; /// let btf = Btf::from_sys_fs()?;
/// let program: &mut BtfTracePoint = bpf.program_mut("sched_process_fork").unwrap().try_into()?; /// let program: &mut BtfTracePoint = bpf.program_mut("sched_process_fork").unwrap().try_into()?;

@ -51,7 +51,6 @@ pub enum TracePointError {
/// # Bpf(#[from] aya::BpfError) /// # Bpf(#[from] aya::BpfError)
/// # } /// # }
/// # let mut bpf = aya::Bpf::load(&[])?; /// # let mut bpf = aya::Bpf::load(&[])?;
/// use std::convert::TryInto;
/// use aya::programs::TracePoint; /// use aya::programs::TracePoint;
/// ///
/// let prog: &mut TracePoint = bpf.program_mut("trace_context_switch").unwrap().try_into()?; /// let prog: &mut TracePoint = bpf.program_mut("trace_context_switch").unwrap().try_into()?;

@ -62,7 +62,6 @@ bitflags! {
/// ```no_run /// ```no_run
/// # let mut bpf = Bpf::load_file("ebpf_programs.o")?; /// # let mut bpf = Bpf::load_file("ebpf_programs.o")?;
/// use aya::{Bpf, programs::{Xdp, XdpFlags}}; /// use aya::{Bpf, programs::{Xdp, XdpFlags}};
/// use std::convert::TryInto;
/// ///
/// let program: &mut Xdp = bpf.program_mut("intercept_packets").unwrap().try_into()?; /// let program: &mut Xdp = bpf.program_mut("intercept_packets").unwrap().try_into()?;
/// program.attach("eth0", XdpFlags::default())?; /// program.attach("eth0", XdpFlags::default())?;

@ -7,7 +7,7 @@ mod fake;
use std::io; use std::io;
#[cfg(not(test))] #[cfg(not(test))]
use std::{convert::TryInto, ffi::CString, mem}; use std::{ffi::CString, mem};
#[cfg(not(test))] #[cfg(not(test))]
use libc::utsname; use libc::utsname;

@ -590,7 +590,7 @@ fn bytes_of<T>(val: &T) -> &[u8] {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::{convert::TryInto, ffi::CString}; use std::ffi::CString;
use super::*; use super::*;

@ -2,7 +2,7 @@
name = "aya-bpf-bindings" name = "aya-bpf-bindings"
version = "0.1.0" version = "0.1.0"
authors = ["Alessandro Decina <alessandro.d@gmail.com>"] authors = ["Alessandro Decina <alessandro.d@gmail.com>"]
edition = "2018" edition = "2021"
[dependencies] [dependencies]
aya-bpf-cty = { path = "../aya-bpf-cty" } aya-bpf-cty = { path = "../aya-bpf-cty" }

@ -2,7 +2,7 @@
name = "aya-bpf" name = "aya-bpf"
version = "0.1.0" version = "0.1.0"
authors = ["Alessandro Decina <alessandro.d@gmail.com>"] authors = ["Alessandro Decina <alessandro.d@gmail.com>"]
edition = "2018" edition = "2021"
[dependencies] [dependencies]
aya-bpf-cty = { path = "../aya-bpf-cty" } aya-bpf-cty = { path = "../aya-bpf-cty" }

@ -1,7 +1,7 @@
[package] [package]
name = "aya-log-ebpf" name = "aya-log-ebpf"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]
aya-bpf = { path = "../aya-bpf" } aya-bpf = { path = "../aya-bpf" }

@ -1,7 +1,7 @@
[package] [package]
name = "integration-ebpf" name = "integration-ebpf"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
publish = false publish = false
[dependencies] [dependencies]

@ -1,7 +1,7 @@
[package] [package]
name = "integration-test-macros" name = "integration-test-macros"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
publish = false publish = false
[dependencies] [dependencies]

@ -1,7 +1,7 @@
[package] [package]
name = "integration-test" name = "integration-test"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
publish = false publish = false
[dependencies] [dependencies]

@ -1,8 +1,4 @@
use std::{ use std::{process::Command, thread, time};
convert::{TryFrom, TryInto},
process::Command,
thread, time,
};
use aya::{ use aya::{
include_bytes_aligned, include_bytes_aligned,

@ -1,5 +1,3 @@
use std::convert::TryInto;
use aya::{ use aya::{
include_bytes_aligned, include_bytes_aligned,
programs::{Extension, Xdp, XdpFlags}, programs::{Extension, Xdp, XdpFlags},

@ -2,7 +2,7 @@
name = "xtask" name = "xtask"
version = "0.1.0" version = "0.1.0"
authors = ["Alessandro Decina <alessandro.d@gmail.com>"] authors = ["Alessandro Decina <alessandro.d@gmail.com>"]
edition = "2018" edition = "2021"
[dependencies] [dependencies]
aya-gen = { path = "../aya-gen" } aya-gen = { path = "../aya-gen" }

Loading…
Cancel
Save