repo
string | pull_number
int64 | instance_id
string | issue_numbers
sequence | base_commit
string | patch
string | test_patch
string | problem_statement
string | hints_text
string | created_at
string | version
string | updated_at
string | environment_setup_commit
string | FAIL_TO_PASS
sequence | PASS_TO_PASS
sequence | FAIL_TO_FAIL
sequence | PASS_TO_FAIL
sequence | source_dir
string |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
aya-rs/aya
| 774
|
aya-rs__aya-774
|
[
"636"
] |
792f467d40dc4c6c543c62dda7a608863fc364dc
|
diff --git a/aya/src/maps/mod.rs b/aya/src/maps/mod.rs
--- a/aya/src/maps/mod.rs
+++ b/aya/src/maps/mod.rs
@@ -291,9 +291,9 @@ macro_rules! impl_try_from_map {
// rather than the repeated idents used later because the macro language does not allow one
// repetition to be pasted inside another.
($ty_param:tt {
- $($ty:ident $(from $variant:ident)?),+ $(,)?
+ $($ty:ident $(from $($variant:ident)|+)?),+ $(,)?
}) => {
- $(impl_try_from_map!(<$ty_param> $ty $(from $variant)?);)+
+ $(impl_try_from_map!(<$ty_param> $ty $(from $($variant)|+)?);)+
};
// Add the "from $variant" using $ty as the default if it is missing.
(<$ty_param:tt> $ty:ident) => {
diff --git a/aya/src/maps/mod.rs b/aya/src/maps/mod.rs
--- a/aya/src/maps/mod.rs
+++ b/aya/src/maps/mod.rs
@@ -301,17 +301,17 @@ macro_rules! impl_try_from_map {
};
// Dispatch for each of the lifetimes.
(
- <($($ty_param:ident),*)> $ty:ident from $variant:ident
+ <($($ty_param:ident),*)> $ty:ident from $($variant:ident)|+
) => {
- impl_try_from_map!(<'a> ($($ty_param),*) $ty from $variant);
- impl_try_from_map!(<'a mut> ($($ty_param),*) $ty from $variant);
- impl_try_from_map!(<> ($($ty_param),*) $ty from $variant);
+ impl_try_from_map!(<'a> ($($ty_param),*) $ty from $($variant)|+);
+ impl_try_from_map!(<'a mut> ($($ty_param),*) $ty from $($variant)|+);
+ impl_try_from_map!(<> ($($ty_param),*) $ty from $($variant)|+);
};
// An individual impl.
(
<$($l:lifetime $($m:ident)?)?>
($($ty_param:ident),*)
- $ty:ident from $variant:ident
+ $ty:ident from $($variant:ident)|+
) => {
impl<$($l,)? $($ty_param: Pod),*> TryFrom<$(&$l $($m)?)? Map>
for $ty<$(&$l $($m)?)? MapData, $($ty_param),*>
diff --git a/aya/src/maps/mod.rs b/aya/src/maps/mod.rs
--- a/aya/src/maps/mod.rs
+++ b/aya/src/maps/mod.rs
@@ -320,7 +320,7 @@ macro_rules! impl_try_from_map {
fn try_from(map: $(&$l $($m)?)? Map) -> Result<Self, Self::Error> {
match map {
- Map::$variant(map_data) => Self::new(map_data),
+ $(Map::$variant(map_data) => Self::new(map_data),)+
map => Err(MapError::InvalidMapType {
map_type: map.map_type()
}),
diff --git a/aya/src/maps/mod.rs b/aya/src/maps/mod.rs
--- a/aya/src/maps/mod.rs
+++ b/aya/src/maps/mod.rs
@@ -353,8 +353,8 @@ impl_try_from_map!((V) {
});
impl_try_from_map!((K, V) {
- HashMap,
- PerCpuHashMap,
+ HashMap from HashMap|LruHashMap,
+ PerCpuHashMap from PerCpuHashMap|PerCpuLruHashMap,
LpmTrie,
});
|
diff --git a/aya/src/maps/hash_map/hash_map.rs b/aya/src/maps/hash_map/hash_map.rs
--- a/aya/src/maps/hash_map/hash_map.rs
+++ b/aya/src/maps/hash_map/hash_map.rs
@@ -108,43 +108,22 @@ mod tests {
use libc::{EFAULT, ENOENT};
use crate::{
- bpf_map_def,
generated::{
bpf_attr, bpf_cmd,
bpf_map_type::{BPF_MAP_TYPE_HASH, BPF_MAP_TYPE_LRU_HASH},
},
- maps::{Map, MapData},
- obj::{self, maps::LegacyMap, BpfSectionKind},
+ maps::Map,
+ obj,
sys::{override_syscall, SysResult, Syscall},
};
- use super::*;
+ use super::{
+ super::test_utils::{self, new_map},
+ *,
+ };
fn new_obj_map() -> obj::Map {
- obj::Map::Legacy(LegacyMap {
- def: bpf_map_def {
- map_type: BPF_MAP_TYPE_HASH as u32,
- key_size: 4,
- value_size: 4,
- max_entries: 1024,
- ..Default::default()
- },
- section_index: 0,
- section_kind: BpfSectionKind::Maps,
- data: Vec::new(),
- symbol_index: None,
- })
- }
-
- fn new_map(obj: obj::Map) -> MapData {
- override_syscall(|call| match call {
- Syscall::Bpf {
- cmd: bpf_cmd::BPF_MAP_CREATE,
- ..
- } => Ok(1337),
- call => panic!("unexpected syscall {:?}", call),
- });
- MapData::create(obj, "foo", None).unwrap()
+ test_utils::new_obj_map(BPF_MAP_TYPE_HASH)
}
fn sys_error(value: i32) -> SysResult<c_long> {
diff --git a/aya/src/maps/hash_map/hash_map.rs b/aya/src/maps/hash_map/hash_map.rs
--- a/aya/src/maps/hash_map/hash_map.rs
+++ b/aya/src/maps/hash_map/hash_map.rs
@@ -213,21 +192,10 @@ mod tests {
#[test]
fn test_try_from_ok_lru() {
- let map = new_map(obj::Map::Legacy(LegacyMap {
- def: bpf_map_def {
- map_type: BPF_MAP_TYPE_LRU_HASH as u32,
- key_size: 4,
- value_size: 4,
- max_entries: 1024,
- ..Default::default()
- },
- section_index: 0,
- section_kind: BpfSectionKind::Maps,
- symbol_index: None,
- data: Vec::new(),
- }));
- let map = Map::HashMap(map);
-
+ let map_data = || new_map(test_utils::new_obj_map(BPF_MAP_TYPE_LRU_HASH));
+ let map = Map::HashMap(map_data());
+ assert!(HashMap::<_, u32, u32>::try_from(&map).is_ok());
+ let map = Map::LruHashMap(map_data());
assert!(HashMap::<_, u32, u32>::try_from(&map).is_ok())
}
diff --git a/aya/src/maps/hash_map/mod.rs b/aya/src/maps/hash_map/mod.rs
--- a/aya/src/maps/hash_map/mod.rs
+++ b/aya/src/maps/hash_map/mod.rs
@@ -41,3 +41,41 @@ pub(crate) fn remove<K: Pod>(map: &MapData, key: &K) -> Result<(), MapError> {
.into()
})
}
+
+#[cfg(test)]
+mod test_utils {
+ use crate::{
+ bpf_map_def,
+ generated::{bpf_cmd, bpf_map_type},
+ maps::MapData,
+ obj::{self, maps::LegacyMap, BpfSectionKind},
+ sys::{override_syscall, Syscall},
+ };
+
+ pub(super) fn new_map(obj: obj::Map) -> MapData {
+ override_syscall(|call| match call {
+ Syscall::Bpf {
+ cmd: bpf_cmd::BPF_MAP_CREATE,
+ ..
+ } => Ok(1337),
+ call => panic!("unexpected syscall {:?}", call),
+ });
+ MapData::create(obj, "foo", None).unwrap()
+ }
+
+ pub(super) fn new_obj_map(map_type: bpf_map_type) -> obj::Map {
+ obj::Map::Legacy(LegacyMap {
+ def: bpf_map_def {
+ map_type: map_type as u32,
+ key_size: 4,
+ value_size: 4,
+ max_entries: 1024,
+ ..Default::default()
+ },
+ section_index: 0,
+ section_kind: BpfSectionKind::Maps,
+ data: Vec::new(),
+ symbol_index: None,
+ })
+ }
+}
diff --git a/aya/src/maps/hash_map/per_cpu_hash_map.rs b/aya/src/maps/hash_map/per_cpu_hash_map.rs
--- a/aya/src/maps/hash_map/per_cpu_hash_map.rs
+++ b/aya/src/maps/hash_map/per_cpu_hash_map.rs
@@ -146,3 +146,30 @@ impl<T: Borrow<MapData>, K: Pod, V: Pod> IterableMap<K, PerCpuValues<V>>
Self::get(self, key, 0)
}
}
+
+#[cfg(test)]
+mod tests {
+ use crate::{
+ generated::bpf_map_type::{BPF_MAP_TYPE_LRU_PERCPU_HASH, BPF_MAP_TYPE_PERCPU_HASH},
+ maps::Map,
+ };
+
+ use super::{super::test_utils, *};
+
+ #[test]
+ fn test_try_from_ok() {
+ let map = Map::PerCpuHashMap(test_utils::new_map(test_utils::new_obj_map(
+ BPF_MAP_TYPE_PERCPU_HASH,
+ )));
+ assert!(PerCpuHashMap::<_, u32, u32>::try_from(&map).is_ok())
+ }
+ #[test]
+ fn test_try_from_ok_lru() {
+ let map_data =
+ || test_utils::new_map(test_utils::new_obj_map(BPF_MAP_TYPE_LRU_PERCPU_HASH));
+ let map = Map::PerCpuHashMap(map_data());
+ assert!(PerCpuHashMap::<_, u32, u32>::try_from(&map).is_ok());
+ let map = Map::PerCpuLruHashMap(map_data());
+ assert!(PerCpuHashMap::<_, u32, u32>::try_from(&map).is_ok())
+ }
+}
|
cant' use LruHashMap in userspace
the userspace HashMap try_from impl
```rust
impl<'a, V: Pod, K: Pod> TryFrom<&'a mut Map> for HashMap<&'a mut MapData, V, K> {
type Error = MapError;
fn try_from(map: &'a mut Map) -> Result<HashMap<&'a mut MapData, V, K>, MapError> {
match map {
Map::HashMap(m) => {
HashMap::new(m)
}
_ => Err(MapError::InvalidMapType { map_type: map.map_type() }),
}
}
}
impl<V: Pod, K: Pod> TryFrom<Map> for HashMap<MapData, V, K> {
type Error = MapError;
fn try_from(map: Map) -> Result<HashMap<MapData, V, K>, MapError> {
match map {
Map::HashMap(m) => HashMap::new(m),
_ => Err(MapError::InvalidMapType { map_type: map.map_type() }),
}
}
}
```
the expanded codes show HashMap only can from bpf hashmap, but not lru hashmap, I remember HashMap can try_from a LruHashMap at previous commit
the latest commit 5c86b7e is broken
|
https://docs.rs/aya/latest/src/aya/maps/hash_map/hash_map.rs.html#48
the crates.io version handled the lruhashmap
maybe we can add a new type LruHashMap to fix this problem
Do you have a test? I don't understand this issue.
sorry for the late reply
kernel space codes
main.rs
```rust
#[xdp(name = "lru_test")]
fn lru_test(ctx: XdpContext) -> u32 {
kernel::lru::lru_test(ctx)
}
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
unsafe { core::hint::unreachable_unchecked() }
}
```
lru.rs
```rust
use aya_bpf::bindings::xdp_action::XDP_PASS;
use aya_bpf::macros::map;
use aya_bpf::maps::LruHashMap;
use aya_bpf::programs::XdpContext;
#[map]
static LRU_MAP: LruHashMap<u32, u32> = LruHashMap::with_max_entries(100, 0);
pub fn lru_test(_ctx: XdpContext) -> u32 {
let key = 1;
let value = 1;
let _ = LRU_MAP.insert(&key, &value, 0);
XDP_PASS
}
```
user space codes
lru_test.rs
```rust
use std::env;
use aya::Bpf;
use aya::maps::HashMap;
use aya::programs::{Xdp, XdpFlags};
pub fn run() {
let path = env::args().nth(1).unwrap();
let mut bpf = Bpf::load_file(path).unwrap();
let mut lru_map: HashMap<_, u32, u32> = bpf.map_mut("LRU_MAP").unwrap().try_into().unwrap();
lru_map.insert(2, 2, 0).unwrap();
let prog: &mut Xdp = bpf.program_mut("lru_test").unwrap().try_into().unwrap();
prog.load().unwrap();
let link_id = prog.attach("lo", XdpFlags::default()).unwrap();
prog.detach(link_id).unwrap();
}
```
main.rs
```rust
#[tokio::main]
async fn main() {
user::lru_test::run();
}
```
compile bpf codes with `cargo b -r`
compile user space codes with `cargo b`
run it `sudo ../target/debug/user ../target/bpfel-unknown-none/release/kernel`
and it will fail with these messages
> thread 'main' panicked at user/src/lru_test.rs:11:88:
> called `Result::unwrap()` on an `Err` value: InvalidMapType { map_type: 9 }
> note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
> [1] 210886 IOT instruction sudo ../target/debug/user ../target/bpfel-unknown-none/release/kernel
I think @ajwerner has a fix for this.
|
2023-08-31T01:49:22Z
|
1.5
|
2023-09-01T15:30:33Z
|
1d272f38bd19f64652ac8a278948f61e66164856
|
[
"maps::hash_map::hash_map::tests::test_try_from_ok_lru",
"maps::hash_map::per_cpu_hash_map::tests::test_try_from_ok_lru"
] |
[
"maps::bloom_filter::tests::test_contains_not_found",
"maps::bloom_filter::tests::test_contains_syscall_error",
"maps::bloom_filter::tests::test_insert_ok",
"maps::bloom_filter::tests::test_insert_syscall_error",
"maps::bloom_filter::tests::test_new_ok",
"maps::bloom_filter::tests::test_try_from_ok",
"maps::bloom_filter::tests::test_try_from_wrong_map",
"maps::bloom_filter::tests::test_wrong_value_size",
"maps::hash_map::hash_map::tests::test_get_not_found",
"maps::hash_map::hash_map::tests::test_get_syscall_error",
"maps::hash_map::hash_map::tests::test_insert_boxed_ok",
"maps::hash_map::hash_map::tests::test_insert_ok",
"maps::hash_map::hash_map::tests::test_insert_syscall_error",
"maps::hash_map::hash_map::tests::test_iter",
"maps::hash_map::hash_map::tests::test_iter_key_deleted",
"maps::hash_map::hash_map::tests::test_iter_key_error",
"maps::hash_map::hash_map::tests::test_iter_value_error",
"maps::hash_map::hash_map::tests::test_keys",
"maps::hash_map::hash_map::tests::test_keys_empty",
"maps::hash_map::hash_map::tests::test_keys_error",
"maps::hash_map::hash_map::tests::test_new_ok",
"maps::hash_map::hash_map::tests::test_remove_ok",
"maps::hash_map::hash_map::tests::test_remove_syscall_error",
"maps::hash_map::hash_map::tests::test_try_from_ok",
"maps::hash_map::hash_map::tests::test_try_from_wrong_map",
"maps::hash_map::hash_map::tests::test_try_from_wrong_map_values",
"maps::hash_map::hash_map::tests::test_wrong_key_size",
"maps::hash_map::hash_map::tests::test_wrong_value_size",
"maps::hash_map::per_cpu_hash_map::tests::test_try_from_ok",
"maps::lpm_trie::tests::test_get_not_found",
"maps::lpm_trie::tests::test_get_syscall_error",
"maps::lpm_trie::tests::test_insert_ok",
"maps::lpm_trie::tests::test_insert_syscall_error",
"maps::lpm_trie::tests::test_new_ok",
"maps::lpm_trie::tests::test_remove_ok",
"maps::lpm_trie::tests::test_remove_syscall_error",
"maps::lpm_trie::tests::test_try_from_ok",
"maps::lpm_trie::tests::test_try_from_wrong_map",
"maps::lpm_trie::tests::test_wrong_key_size",
"maps::lpm_trie::tests::test_wrong_value_size",
"maps::perf::perf_buffer::tests::test_invalid_page_count",
"maps::perf::perf_buffer::tests::test_no_events",
"maps::perf::perf_buffer::tests::test_no_out_bufs",
"maps::perf::perf_buffer::tests::test_read_first_sample",
"maps::perf::perf_buffer::tests::test_read_first_lost",
"maps::perf::perf_buffer::tests::test_read_many_with_many_reads",
"maps::perf::perf_buffer::tests::test_read_last_sample",
"maps::perf::perf_buffer::tests::test_read_many_with_one_read",
"maps::perf::perf_buffer::tests::test_read_wrapping_sample_size",
"maps::perf::perf_buffer::tests::test_read_wrapping_value",
"maps::tests::test_create",
"maps::tests::test_create_failed",
"programs::links::tests::test_already_attached",
"programs::links::tests::test_drop_detach",
"programs::links::tests::test_link_map",
"programs::links::tests::test_not_attached",
"programs::links::tests::test_owned_detach",
"sys::bpf::tests::test_perf_link_supported",
"sys::netlink::tests::test_nlattr_iterator_empty",
"sys::netlink::tests::test_nested_attrs",
"sys::netlink::tests::test_nlattr_iterator_many",
"programs::links::tests::test_pin",
"sys::netlink::tests::test_nlattr_iterator_nested",
"sys::netlink::tests::test_nlattr_iterator_one",
"util::tests::test_parse_kernel_version_string",
"util::tests::test_parse_kernel_symbols",
"util::tests::test_parse_online_cpus",
"programs::uprobe::test_resolve_attach_path",
"aya/src/bpf.rs - bpf::Bpf::program_mut (line 879) - compile",
"aya/src/bpf.rs - bpf::BpfLoader<'a>::set_global (line 248) - compile",
"aya/src/bpf.rs - bpf::BpfLoader (line 116) - compile",
"aya/src/programs/mod.rs - programs (line 16) - compile",
"aya/src/maps/hash_map/hash_map.rs - maps::hash_map::hash_map::HashMap (line 20) - compile",
"aya/src/programs/links.rs - programs::links::FdLink (line 95) - compile",
"aya/src/bpf.rs - bpf::Bpf::programs (line 895) - compile",
"aya/src/util.rs - util::syscall_prefix (line 239) - compile",
"aya/src/programs/xdp.rs - programs::xdp::Xdp (line 71) - compile",
"aya/src/bpf.rs - bpf::BpfLoader<'a>::map_pin_path (line 228) - compile",
"aya/src/bpf.rs - bpf::Bpf::programs_mut (line 913) - compile",
"aya/src/maps/mod.rs - maps::PerCpuValues (line 671) - compile",
"aya/src/programs/socket_filter.rs - programs::socket_filter::SocketFilter (line 37) - compile",
"aya/src/programs/sk_lookup.rs - programs::sk_lookup::SkLookup (line 25) - compile",
"aya/src/maps/array/program_array.rs - maps::array::program_array::ProgramArray (line 25) - compile",
"aya/src/programs/cgroup_sysctl.rs - programs::cgroup_sysctl::CgroupSysctl (line 25) - compile",
"aya/src/bpf.rs - bpf::BpfLoader<'a>::set_max_entries (line 298) - compile",
"aya/src/programs/fexit.rs - programs::fexit::FExit (line 26) - compile",
"aya/src/maps/hash_map/per_cpu_hash_map.rs - maps::hash_map::per_cpu_hash_map::PerCpuHashMap (line 27) - compile",
"aya/src/maps/stack_trace.rs - maps::stack_trace::StackTraceMap (line 24) - compile",
"aya/src/bpf.rs - bpf::Bpf::program (line 862) - compile",
"aya/src/maps/sock/sock_map.rs - maps::sock::sock_map::SockMap (line 28) - compile",
"aya/src/maps/sock/sock_hash.rs - maps::sock::sock_hash::SockHash (line 30) - compile",
"aya/src/programs/lsm.rs - programs::lsm::Lsm (line 28) - compile",
"aya/src/programs/cgroup_device.rs - programs::cgroup_device::CgroupDevice (line 27) - compile",
"aya/src/maps/lpm_trie.rs - maps::lpm_trie::Key (line 59) - compile",
"aya/src/maps/lpm_trie.rs - maps::lpm_trie::LpmTrie (line 21) - compile",
"aya/src/programs/raw_trace_point.rs - programs::raw_trace_point::RawTracePoint (line 26) - compile",
"aya/src/bpf.rs - bpf::BpfLoader<'a>::load_file (line 356) - compile",
"aya/src/programs/cgroup_sock.rs - programs::cgroup_sock::CgroupSock (line 30) - compile",
"aya/src/bpf.rs - bpf::Bpf::load (line 782) - compile",
"aya/src/bpf.rs - bpf::BpfLoader<'a>::allow_unsupported_maps (line 207) - compile",
"aya/src/bpf.rs - bpf::BpfLoader<'a>::set_global (line 255) - compile",
"aya/src/programs/tc.rs - programs::tc::SchedClassifier (line 48) - compile",
"aya/src/bpf.rs - bpf::Bpf::load_file (line 760) - compile",
"aya/src/bpf.rs - bpf::BpfLoader<'a>::set_global (line 271) - compile",
"aya/src/programs/lirc_mode2.rs - programs::lirc_mode2::LircMode2 (line 23) - compile",
"aya/src/maps/lpm_trie.rs - maps::lpm_trie::Key<K>::new (line 82) - compile",
"aya/src/programs/cgroup_sock_addr.rs - programs::cgroup_sock_addr::CgroupSockAddr (line 31) - compile",
"aya/src/maps/perf/perf_event_array.rs - maps::perf::perf_event_array::PerfEventArray (line 84) - compile",
"aya/src/bpf.rs - bpf::BpfLoader<'a>::btf (line 182) - compile",
"aya/src/bpf.rs - bpf::Bpf::maps (line 838) - compile",
"aya/src/maps/mod.rs - maps (line 20) - compile",
"aya/src/programs/extension.rs - programs::extension::Extension (line 37) - compile",
"aya/src/maps/stack.rs - maps::stack::Stack (line 20) - compile",
"aya/src/programs/cgroup_sockopt.rs - programs::cgroup_sockopt::CgroupSockopt (line 28) - compile",
"aya/src/programs/links.rs - programs::links::FdLink::pin (line 127) - compile",
"aya/src/programs/cgroup_skb.rs - programs::cgroup_skb::CgroupSkb (line 32) - compile",
"aya/src/programs/trace_point.rs - programs::trace_point::TracePoint (line 42) - compile",
"aya/src/programs/sock_ops.rs - programs::sock_ops::SockOps (line 24) - compile",
"aya/src/programs/tp_btf.rs - programs::tp_btf::BtfTracePoint (line 25) - compile",
"aya/src/maps/array/array.rs - maps::array::array::Array (line 22) - compile",
"aya/src/maps/hash_map/per_cpu_hash_map.rs - maps::hash_map::per_cpu_hash_map::PerCpuHashMap<T,K,V>::insert (line 91) - compile",
"aya/src/bpf.rs - bpf::BpfLoader<'a>::load (line 374) - compile",
"aya/src/programs/sk_msg.rs - programs::sk_msg::SkMsg (line 26) - compile",
"aya/src/programs/tc.rs - programs::tc::SchedClassifierLink::attached (line 262) - compile",
"aya/src/maps/queue.rs - maps::queue::Queue (line 20) - compile",
"aya/src/programs/sk_skb.rs - programs::sk_skb::SkSkb (line 39) - compile",
"aya/src/programs/fentry.rs - programs::fentry::FEntry (line 26) - compile",
"aya/src/maps/array/per_cpu_array.rs - maps::array::per_cpu_array::PerCpuArray (line 22) - compile",
"aya/src/maps/perf/async_perf_event_array.rs - maps::perf::async_perf_event_array::AsyncPerfEventArray (line 38) - compile",
"aya/src/programs/perf_event.rs - programs::perf_event::PerfEvent (line 92) - compile",
"aya/src/maps/bloom_filter.rs - maps::bloom_filter::BloomFilter (line 21) - compile",
"aya/src/bpf.rs - bpf::BpfLoader<'a>::verifier_log_level (line 338) - compile",
"aya/src/bpf.rs - bpf::BpfLoader<'a>::extension (line 320) - compile",
"aya/src/programs/kprobe.rs - programs::kprobe::KProbe (line 36) - compile",
"aya/src/programs/mod.rs - programs::loaded_programs (line 1100)"
] |
[] |
[] |
auto_2025-06-07
|
aya-rs/aya
| 656
|
aya-rs__aya-656
|
[
"654"
] |
61608e64583f9dc599eef9b8db098f38a765b285
|
diff --git a/Cargo.toml b/Cargo.toml
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -24,7 +24,6 @@ resolver = "2"
default-members = [
"aya",
- "aya-bpf-macros",
"aya-log",
"aya-log-common",
"aya-log-parser",
diff --git a/aya-obj/Cargo.toml b/aya-obj/Cargo.toml
--- a/aya-obj/Cargo.toml
+++ b/aya-obj/Cargo.toml
@@ -2,7 +2,7 @@
name = "aya-obj"
version = "0.1.0"
description = "An eBPF object file parsing library with BTF and relocation support."
-keywords = ["ebpf", "bpf", "btf", "elf", "object"]
+keywords = ["bpf", "btf", "ebpf", "elf", "object"]
license = "MIT OR Apache-2.0"
authors = ["The Aya Contributors"]
repository = "https://github.com/aya-rs/aya"
diff --git a/aya-obj/Cargo.toml b/aya-obj/Cargo.toml
--- a/aya-obj/Cargo.toml
+++ b/aya-obj/Cargo.toml
@@ -13,13 +13,16 @@ edition = "2021"
[dependencies]
bytes = "1"
log = "0.4"
-object = { version = "0.31", default-features = false, features = ["read_core", "elf"] }
+object = { version = "0.31", default-features = false, features = [
+ "elf",
+ "read_core",
+] }
hashbrown = { version = "0.14" }
thiserror = { version = "1", default-features = false }
core-error = { version = "0.0.0" }
[dev-dependencies]
-matches = "0.1.8"
+assert_matches = "1.5.0"
rbpf = "0.2.0"
[features]
diff --git a/aya/Cargo.toml b/aya/Cargo.toml
--- a/aya/Cargo.toml
+++ b/aya/Cargo.toml
@@ -24,13 +24,12 @@ object = { version = "0.31", default-features = false, features = [
"std",
] }
parking_lot = { version = "0.12.0", features = ["send_guard"] }
-text_io = "0.1.12"
thiserror = "1"
tokio = { version = "1.24.0", features = ["rt"], optional = true }
[dev-dependencies]
+assert_matches = "1.5.0"
futures = { version = "0.3.12", default-features = false, features = ["std"] }
-matches = "0.1.8"
tempfile = "3"
[features]
diff --git a/aya/src/util.rs b/aya/src/util.rs
--- a/aya/src/util.rs
+++ b/aya/src/util.rs
@@ -25,18 +25,14 @@ pub struct KernelVersion {
pub(crate) patch: u16,
}
-/// An error encountered while fetching the current kernel version.
#[derive(thiserror::Error, Debug)]
-pub enum CurrentKernelVersionError {
- /// The kernel version string could not be read.
+enum CurrentKernelVersionError {
#[error("failed to read kernel version")]
- IOError(#[from] io::Error),
- /// The kernel version string could not be parsed.
+ IO(#[from] io::Error),
#[error("failed to parse kernel version")]
- ParseError(#[from] text_io::Error),
- /// The kernel version string was not valid UTF-8.
+ ParseError(String),
#[error("kernel version string is not valid UTF-8")]
- Utf8Error(#[from] Utf8Error),
+ Utf8(#[from] Utf8Error),
}
impl KernelVersion {
diff --git a/aya/src/util.rs b/aya/src/util.rs
--- a/aya/src/util.rs
+++ b/aya/src/util.rs
@@ -74,7 +70,7 @@ impl KernelVersion {
fn get_ubuntu_kernel_version() -> Result<Option<Self>, CurrentKernelVersionError> {
const UBUNTU_KVER_FILE: &str = "/proc/version_signature";
- let s = match fs::read(UBUNTU_KVER_FILE) {
+ let s = match fs::read_to_string(UBUNTU_KVER_FILE) {
Ok(s) => s,
Err(e) => {
if e.kind() == io::ErrorKind::NotFound {
diff --git a/aya/src/util.rs b/aya/src/util.rs
--- a/aya/src/util.rs
+++ b/aya/src/util.rs
@@ -83,13 +79,16 @@ impl KernelVersion {
return Err(e.into());
}
};
- let ubuntu: String;
- let ubuntu_version: String;
- let major: u8;
- let minor: u8;
- let patch: u16;
- text_io::try_scan!(s.iter().copied() => "{} {} {}.{}.{}\n", ubuntu, ubuntu_version, major, minor, patch);
- Ok(Some(Self::new(major, minor, patch)))
+ let mut parts = s.split_terminator(char::is_whitespace);
+ let mut next = || {
+ parts
+ .next()
+ .ok_or_else(|| CurrentKernelVersionError::ParseError(s.to_string()))
+ };
+ let _ubuntu: &str = next()?;
+ let _ubuntu_version: &str = next()?;
+ let kernel_version_string = next()?;
+ Self::parse_kernel_version_string(kernel_version_string).map(Some)
}
fn get_debian_kernel_version(
diff --git a/aya/src/util.rs b/aya/src/util.rs
--- a/aya/src/util.rs
+++ b/aya/src/util.rs
@@ -99,17 +98,13 @@ impl KernelVersion {
//
// The length of the arrays in a struct utsname is unspecified (see NOTES); the fields are
// terminated by a null byte ('\0').
- let p = unsafe { CStr::from_ptr(info.version.as_ptr()) };
- let p = p.to_str()?;
- let p = match p.split_once("Debian ") {
+ let s = unsafe { CStr::from_ptr(info.version.as_ptr()) };
+ let s = s.to_str()?;
+ let kernel_version_string = match s.split_once("Debian ") {
Some((_prefix, suffix)) => suffix,
None => return Ok(None),
};
- let major: u8;
- let minor: u8;
- let patch: u16;
- text_io::try_scan!(p.bytes() => "{}.{}.{}", major, minor, patch);
- Ok(Some(Self::new(major, minor, patch)))
+ Self::parse_kernel_version_string(kernel_version_string).map(Some)
}
fn get_kernel_version() -> Result<Self, CurrentKernelVersionError> {
diff --git a/aya/src/util.rs b/aya/src/util.rs
--- a/aya/src/util.rs
+++ b/aya/src/util.rs
@@ -130,17 +125,23 @@ impl KernelVersion {
//
// The length of the arrays in a struct utsname is unspecified (see NOTES); the fields are
// terminated by a null byte ('\0').
- let p = unsafe { CStr::from_ptr(info.release.as_ptr()) };
- let p = p.to_str()?;
- // Unlike sscanf, text_io::try_scan! does not stop at the first non-matching character.
- let p = match p.split_once(|c: char| c != '.' && !c.is_ascii_digit()) {
- Some((prefix, _suffix)) => prefix,
- None => p,
- };
- let major: u8;
- let minor: u8;
- let patch: u16;
- text_io::try_scan!(p.bytes() => "{}.{}.{}", major, minor, patch);
+ let s = unsafe { CStr::from_ptr(info.release.as_ptr()) };
+ let s = s.to_str()?;
+ Self::parse_kernel_version_string(s)
+ }
+
+ fn parse_kernel_version_string(s: &str) -> Result<Self, CurrentKernelVersionError> {
+ fn parse<T: FromStr<Err = std::num::ParseIntError>>(s: Option<&str>) -> Option<T> {
+ match s.map(str::parse).transpose() {
+ Ok(option) => option,
+ Err(std::num::ParseIntError { .. }) => None,
+ }
+ }
+ let error = || CurrentKernelVersionError::ParseError(s.to_string());
+ let mut parts = s.split(|c: char| c == '.' || !c.is_ascii_digit());
+ let major = parse(parts.next()).ok_or_else(error)?;
+ let minor = parse(parts.next()).ok_or_else(error)?;
+ let patch = parse(parts.next()).ok_or_else(error)?;
Ok(Self::new(major, minor, patch))
}
}
|
diff --git a/aya-obj/src/obj.rs b/aya-obj/src/obj.rs
--- a/aya-obj/src/obj.rs
+++ b/aya-obj/src/obj.rs
@@ -1486,7 +1486,7 @@ pub fn copy_instructions(data: &[u8]) -> Result<Vec<bpf_insn>, ParseError> {
#[cfg(test)]
mod tests {
use alloc::vec;
- use matches::assert_matches;
+ use assert_matches::assert_matches;
use object::Endianness;
use super::*;
diff --git a/aya/src/maps/bloom_filter.rs b/aya/src/maps/bloom_filter.rs
--- a/aya/src/maps/bloom_filter.rs
+++ b/aya/src/maps/bloom_filter.rs
@@ -88,8 +88,8 @@ mod tests {
obj::{self, maps::LegacyMap, BpfSectionKind},
sys::{override_syscall, SysResult, Syscall},
};
+ use assert_matches::assert_matches;
use libc::{EFAULT, ENOENT};
- use matches::assert_matches;
use std::io;
fn new_obj_map() -> obj::Map {
diff --git a/aya/src/maps/hash_map/hash_map.rs b/aya/src/maps/hash_map/hash_map.rs
--- a/aya/src/maps/hash_map/hash_map.rs
+++ b/aya/src/maps/hash_map/hash_map.rs
@@ -107,8 +107,8 @@ impl<T: Borrow<MapData>, K: Pod, V: Pod> IterableMap<K, V> for HashMap<T, K, V>
mod tests {
use std::io;
+ use assert_matches::assert_matches;
use libc::{EFAULT, ENOENT};
- use matches::assert_matches;
use crate::{
bpf_map_def,
diff --git a/aya/src/maps/lpm_trie.rs b/aya/src/maps/lpm_trie.rs
--- a/aya/src/maps/lpm_trie.rs
+++ b/aya/src/maps/lpm_trie.rs
@@ -207,8 +207,8 @@ mod tests {
obj::{self, maps::LegacyMap, BpfSectionKind},
sys::{override_syscall, SysResult, Syscall},
};
+ use assert_matches::assert_matches;
use libc::{EFAULT, ENOENT};
- use matches::assert_matches;
use std::{io, mem, net::Ipv4Addr};
fn new_obj_map() -> obj::Map {
diff --git a/aya/src/maps/mod.rs b/aya/src/maps/mod.rs
--- a/aya/src/maps/mod.rs
+++ b/aya/src/maps/mod.rs
@@ -842,8 +842,8 @@ impl<T: Pod> Deref for PerCpuValues<T> {
#[cfg(test)]
mod tests {
+ use assert_matches::assert_matches;
use libc::EFAULT;
- use matches::assert_matches;
use crate::{
bpf_map_def,
diff --git a/aya/src/maps/perf/perf_buffer.rs b/aya/src/maps/perf/perf_buffer.rs
--- a/aya/src/maps/perf/perf_buffer.rs
+++ b/aya/src/maps/perf/perf_buffer.rs
@@ -319,7 +319,7 @@ mod tests {
generated::perf_event_mmap_page,
sys::{override_syscall, Syscall, TEST_MMAP_RET},
};
- use matches::assert_matches;
+ use assert_matches::assert_matches;
use std::{fmt::Debug, mem};
const PAGE_SIZE: usize = 4096;
diff --git a/aya/src/programs/links.rs b/aya/src/programs/links.rs
--- a/aya/src/programs/links.rs
+++ b/aya/src/programs/links.rs
@@ -353,7 +353,7 @@ pub enum LinkError {
#[cfg(test)]
mod tests {
- use matches::assert_matches;
+ use assert_matches::assert_matches;
use std::{cell::RefCell, fs::File, mem, os::unix::io::AsRawFd, rc::Rc};
use tempfile::tempdir;
diff --git a/aya/src/util.rs b/aya/src/util.rs
--- a/aya/src/util.rs
+++ b/aya/src/util.rs
@@ -331,6 +332,19 @@ pub(crate) fn bytes_of_slice<T: Pod>(val: &[T]) -> &[u8] {
#[cfg(test)]
mod tests {
use super::*;
+ use assert_matches::assert_matches;
+
+ #[test]
+ fn test_parse_kernel_version_string() {
+ // WSL.
+ assert_matches!(KernelVersion::parse_kernel_version_string("5.15.90.1-microsoft-standard-WSL2"), Ok(kernel_version) => {
+ assert_eq!(kernel_version, KernelVersion::new(5, 15, 90))
+ });
+ // uname -r on Fedora.
+ assert_matches!(KernelVersion::parse_kernel_version_string("6.3.11-200.fc38.x86_64"), Ok(kernel_version) => {
+ assert_eq!(kernel_version, KernelVersion::new(6, 3, 11))
+ });
+ }
#[test]
fn test_parse_online_cpus() {
diff --git a/test/integration-test/Cargo.toml b/test/integration-test/Cargo.toml
--- a/test/integration-test/Cargo.toml
+++ b/test/integration-test/Cargo.toml
@@ -6,12 +6,12 @@ publish = false
[dependencies]
anyhow = "1"
+assert_matches = "1.5.0"
aya = { path = "../../aya" }
aya-log = { path = "../../aya-log" }
aya-obj = { path = "../../aya-obj" }
libc = { version = "0.2.105" }
log = "0.4"
-matches = "0.1.8"
object = { version = "0.31", default-features = false, features = [
"elf",
"read_core",
diff --git a/test/integration-test/src/tests/rbpf.rs b/test/integration-test/src/tests/rbpf.rs
--- a/test/integration-test/src/tests/rbpf.rs
+++ b/test/integration-test/src/tests/rbpf.rs
@@ -8,7 +8,7 @@ fn run_with_rbpf() {
let object = Object::parse(crate::PASS).unwrap();
assert_eq!(object.programs.len(), 1);
- matches::assert_matches!(object.programs["pass"].section, ProgramSection::Xdp { .. });
+ assert_matches::assert_matches!(object.programs["pass"].section, ProgramSection::Xdp { .. });
assert_eq!(object.programs["pass"].section.name(), "pass");
let instructions = &object
diff --git a/test/integration-test/src/tests/rbpf.rs b/test/integration-test/src/tests/rbpf.rs
--- a/test/integration-test/src/tests/rbpf.rs
+++ b/test/integration-test/src/tests/rbpf.rs
@@ -35,7 +35,7 @@ fn use_map_with_rbpf() {
let mut object = Object::parse(crate::MULTIMAP_BTF).unwrap();
assert_eq!(object.programs.len(), 1);
- matches::assert_matches!(
+ assert_matches::assert_matches!(
object.programs["tracepoint"].section,
ProgramSection::TracePoint { .. }
);
|
Kernel version detection is broken on WSL
Using aya from with the yesterday's commit fails with
```
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ParseError(Parse("90.1", "patch"))', /home/debian/.cargo/git/checkouts/aya-c55fbc69175ac116/242d8c3/aya/src/maps/mod.rs:504:55
```
when running on Windows/WSL2 Debian 12.
`uname -r` for this system:
```
5.15.90.1-microsoft-standard-WSL2
```
Looks like the reworked kernel version detection from a couple of days ago doesn't work with this string.
|
2023-07-14T14:51:06Z
|
0.11
|
2023-07-15T03:18:35Z
|
61608e64583f9dc599eef9b8db098f38a765b285
|
[
"btf::btf::tests::parsing_older_ext_data",
"btf::btf::tests::test_fixup_ptr",
"btf::btf::tests::test_fixup_func_proto",
"btf::btf::tests::test_fixup_datasec",
"btf::btf::tests::test_parse_header",
"btf::btf::tests::test_sanitize_datasec",
"btf::btf::tests::test_parse_btf",
"btf::btf::tests::test_sanitize_decl_tag",
"btf::btf::tests::test_sanitize_float",
"btf::btf::tests::test_sanitize_func_and_proto",
"btf::btf::tests::test_sanitize_type_tag",
"btf::btf::tests::test_sanitize_func_global",
"btf::btf::tests::test_sanitize_var",
"btf::btf::tests::test_sanitize_mem_builtins",
"btf::btf::tests::test_write_btf",
"btf::types::tests::test_read_btf_type_array",
"btf::types::tests::test_read_btf_type_const",
"btf::types::tests::test_read_btf_type_enum",
"btf::types::tests::test_read_btf_type_float",
"btf::types::tests::test_read_btf_type_func",
"btf::types::tests::test_read_btf_type_func_datasec",
"btf::types::tests::test_read_btf_type_func_proto",
"btf::types::tests::test_read_btf_type_func_var",
"btf::types::tests::test_read_btf_type_fwd",
"btf::types::tests::test_read_btf_type_int",
"btf::types::tests::test_read_btf_type_ptr",
"btf::types::tests::test_read_btf_type_restrict",
"btf::types::tests::test_read_btf_type_struct",
"btf::types::tests::test_read_btf_type_typedef",
"btf::types::tests::test_read_btf_type_union",
"btf::types::tests::test_read_btf_type_volatile",
"btf::types::tests::test_types_are_compatible",
"btf::types::tests::test_write_btf_func_proto",
"btf::types::tests::test_write_btf_long_unsigned_int",
"btf::types::tests::test_write_btf_signed_short_int",
"btf::types::tests::test_write_btf_uchar",
"obj::tests::sanitizes_empty_btf_files_to_none",
"obj::tests::test_parse_generic_error",
"obj::tests::test_parse_license",
"obj::tests::test_parse_btf_map_section",
"obj::tests::test_parse_map_data",
"obj::tests::test_parse_map_def",
"obj::tests::test_parse_map_def_error",
"obj::tests::test_parse_map_def_with_padding",
"obj::tests::test_parse_map_short",
"obj::tests::test_parse_program_error",
"obj::tests::test_parse_program",
"obj::tests::test_parse_section_cgroup_skb_ingress_named",
"obj::tests::test_parse_section_btf_tracepoint",
"obj::tests::test_parse_section_cgroup_skb_ingress_unnamed",
"obj::tests::test_parse_section_cgroup_skb_no_direction_named",
"obj::tests::test_parse_section_cgroup_skb_no_direction_unamed",
"obj::tests::test_parse_section_data",
"obj::tests::test_parse_section_fentry",
"obj::tests::test_parse_section_fexit",
"obj::tests::test_parse_section_kprobe",
"obj::tests::test_parse_section_lsm",
"obj::tests::test_parse_section_lsm_sleepable",
"obj::tests::test_parse_section_map",
"obj::tests::test_parse_section_raw_tp",
"obj::tests::test_parse_section_multiple_maps",
"obj::tests::test_parse_section_skskb_named",
"obj::tests::test_parse_section_skskb_unnamed",
"obj::tests::test_parse_section_sock_addr_named",
"obj::tests::test_parse_section_sock_addr_unnamed",
"obj::tests::test_parse_section_socket_filter",
"obj::tests::test_parse_section_sockopt_named",
"obj::tests::test_parse_section_sockopt_unnamed",
"obj::tests::test_parse_section_trace_point",
"obj::tests::test_parse_section_uprobe",
"obj::tests::test_parse_section_xdp",
"obj::tests::test_parse_section_xdp_frags",
"obj::tests::test_parse_version",
"obj::tests::test_patch_map_data",
"relocation::test::test_multiple_btf_map_relocation",
"relocation::test::test_multiple_legacy_map_relocation",
"relocation::test::test_single_btf_map_relocation",
"relocation::test::test_single_legacy_map_relocation",
"btf::btf::tests::test_read_btf_from_sys_fs",
"src/lib.rs - (line 33) - compile",
"src/obj.rs - obj::ProgramSection (line 201)",
"maps::bloom_filter::tests::test_contains_syscall_error",
"maps::bloom_filter::tests::test_insert_ok",
"maps::bloom_filter::tests::test_contains_not_found",
"maps::bloom_filter::tests::test_insert_syscall_error",
"maps::bloom_filter::tests::test_new_not_created",
"maps::bloom_filter::tests::test_try_from_ok",
"maps::bloom_filter::tests::test_new_ok",
"maps::bloom_filter::tests::test_try_from_wrong_map",
"maps::bloom_filter::tests::test_wrong_value_size",
"maps::hash_map::hash_map::tests::test_get_not_found",
"maps::hash_map::hash_map::tests::test_get_syscall_error",
"maps::hash_map::hash_map::tests::test_insert_boxed_ok",
"maps::hash_map::hash_map::tests::test_insert_ok",
"maps::hash_map::hash_map::tests::test_insert_syscall_error",
"maps::hash_map::hash_map::tests::test_iter",
"maps::hash_map::hash_map::tests::test_iter_key_deleted",
"maps::hash_map::hash_map::tests::test_iter_key_error",
"maps::hash_map::hash_map::tests::test_iter_value_error",
"maps::hash_map::hash_map::tests::test_keys",
"maps::hash_map::hash_map::tests::test_keys_empty",
"maps::hash_map::hash_map::tests::test_keys_error",
"maps::hash_map::hash_map::tests::test_new_not_created",
"maps::hash_map::hash_map::tests::test_new_ok",
"maps::hash_map::hash_map::tests::test_remove_ok",
"maps::hash_map::hash_map::tests::test_remove_syscall_error",
"maps::hash_map::hash_map::tests::test_try_from_ok",
"maps::hash_map::hash_map::tests::test_try_from_ok_lru",
"maps::hash_map::hash_map::tests::test_try_from_wrong_map",
"maps::hash_map::hash_map::tests::test_wrong_key_size",
"maps::hash_map::hash_map::tests::test_try_from_wrong_map_values",
"maps::hash_map::hash_map::tests::test_wrong_value_size",
"maps::lpm_trie::tests::test_get_not_found",
"maps::lpm_trie::tests::test_get_syscall_error",
"maps::lpm_trie::tests::test_insert_ok",
"maps::lpm_trie::tests::test_new_not_created",
"maps::lpm_trie::tests::test_insert_syscall_error",
"maps::lpm_trie::tests::test_new_ok",
"maps::lpm_trie::tests::test_remove_ok",
"maps::lpm_trie::tests::test_remove_syscall_error",
"maps::lpm_trie::tests::test_try_from_ok",
"maps::lpm_trie::tests::test_try_from_wrong_map",
"maps::lpm_trie::tests::test_wrong_key_size",
"maps::lpm_trie::tests::test_wrong_value_size",
"maps::perf::perf_buffer::tests::test_invalid_page_count",
"maps::perf::perf_buffer::tests::test_no_events",
"maps::perf::perf_buffer::tests::test_no_out_bufs",
"maps::perf::perf_buffer::tests::test_read_first_sample",
"maps::perf::perf_buffer::tests::test_read_first_lost",
"maps::perf::perf_buffer::tests::test_read_last_sample",
"maps::perf::perf_buffer::tests::test_read_many_with_one_read",
"maps::perf::perf_buffer::tests::test_read_many_with_many_reads",
"maps::perf::perf_buffer::tests::test_read_wrapping_sample_size",
"maps::perf::perf_buffer::tests::test_read_wrapping_value",
"maps::tests::test_create",
"maps::tests::test_create_failed",
"programs::links::tests::test_already_attached",
"programs::links::tests::test_drop_detach",
"programs::links::tests::test_link_map",
"programs::links::tests::test_not_attached",
"programs::links::tests::test_owned_detach",
"sys::bpf::tests::test_perf_link_supported",
"sys::netlink::tests::test_nested_attrs",
"sys::netlink::tests::test_nlattr_iterator_empty",
"sys::netlink::tests::test_nlattr_iterator_many",
"sys::netlink::tests::test_nlattr_iterator_nested",
"sys::netlink::tests::test_nlattr_iterator_one",
"util::tests::test_parse_kernel_symbols",
"programs::links::tests::test_pin",
"util::tests::test_parse_online_cpus",
"src/bpf.rs - bpf::Bpf::program (line 864) - compile",
"src/bpf.rs - bpf::BpfLoader (line 111) - compile",
"src/bpf.rs - bpf::BpfLoader<'a>::set_global (line 243) - compile",
"src/bpf.rs - bpf::Bpf::maps (line 840) - compile",
"src/bpf.rs - bpf::BpfLoader<'a>::load_file (line 351) - compile",
"src/bpf.rs - bpf::BpfLoader<'a>::set_global (line 250) - compile",
"src/maps/lpm_trie.rs - maps::lpm_trie::Key (line 59) - compile",
"src/maps/bloom_filter.rs - maps::bloom_filter::BloomFilter (line 18) - compile",
"src/bpf.rs - bpf::Bpf::load_file (line 762) - compile",
"src/programs/links.rs - programs::links::FdLink (line 96) - compile",
"src/bpf.rs - bpf::BpfLoader<'a>::verifier_log_level (line 333) - compile",
"src/bpf.rs - bpf::Bpf::program_mut (line 881) - compile",
"src/programs/cgroup_sock_addr.rs - programs::cgroup_sock_addr::CgroupSockAddr (line 35) - compile",
"src/maps/lpm_trie.rs - maps::lpm_trie::Key<K>::new (line 82) - compile",
"src/programs/cgroup_skb.rs - programs::cgroup_skb::CgroupSkb (line 36) - compile",
"src/programs/mod.rs - programs (line 16) - compile",
"src/bpf.rs - bpf::Bpf::load (line 784) - compile",
"src/bpf.rs - bpf::BpfLoader<'a>::extension (line 315) - compile",
"src/maps/array/program_array.rs - maps::array::program_array::ProgramArray (line 25) - compile",
"src/maps/sock/sock_map.rs - maps::sock::sock_map::SockMap (line 28) - compile",
"src/maps/mod.rs - maps (line 20) - compile",
"src/bpf.rs - bpf::BpfLoader<'a>::map_pin_path (line 223) - compile",
"src/bpf.rs - bpf::BpfLoader<'a>::allow_unsupported_maps (line 202) - compile",
"src/bpf.rs - bpf::Bpf::programs (line 897) - compile",
"src/bpf.rs - bpf::BpfLoader<'a>::load (line 369) - compile",
"src/maps/hash_map/hash_map.rs - maps::hash_map::hash_map::HashMap (line 20) - compile",
"src/bpf.rs - bpf::Bpf::programs_mut (line 915) - compile",
"src/maps/hash_map/per_cpu_hash_map.rs - maps::hash_map::per_cpu_hash_map::PerCpuHashMap (line 27) - compile",
"src/bpf.rs - bpf::BpfLoader<'a>::btf (line 177) - compile",
"src/maps/hash_map/per_cpu_hash_map.rs - maps::hash_map::per_cpu_hash_map::PerCpuHashMap<T,K,V>::insert (line 94) - compile",
"src/bpf.rs - bpf::BpfLoader<'a>::set_global (line 266) - compile",
"src/maps/queue.rs - maps::queue::Queue (line 20) - compile",
"src/maps/stack.rs - maps::stack::Stack (line 20) - compile",
"src/programs/kprobe.rs - programs::kprobe::KProbe (line 31) - compile",
"src/maps/array/array.rs - maps::array::array::Array (line 22) - compile",
"src/programs/extension.rs - programs::extension::Extension (line 36) - compile",
"src/maps/lpm_trie.rs - maps::lpm_trie::LpmTrie (line 21) - compile",
"src/bpf.rs - bpf::BpfLoader<'a>::set_max_entries (line 293) - compile",
"src/maps/mod.rs - maps::PerCpuValues (line 761) - compile",
"src/programs/raw_trace_point.rs - programs::raw_trace_point::RawTracePoint (line 26) - compile",
"src/programs/sk_skb.rs - programs::sk_skb::SkSkb (line 40) - compile",
"src/programs/lsm.rs - programs::lsm::Lsm (line 28) - compile",
"src/programs/tc.rs - programs::tc::SchedClassifierLink::attached (line 261) - compile",
"src/programs/fexit.rs - programs::fexit::FExit (line 26) - compile",
"src/programs/xdp.rs - programs::xdp::Xdp (line 65) - compile",
"src/programs/cgroup_sockopt.rs - programs::cgroup_sockopt::CgroupSockopt (line 32) - compile",
"src/programs/cgroup_sock.rs - programs::cgroup_sock::CgroupSock (line 34) - compile",
"src/programs/cgroup_device.rs - programs::cgroup_device::CgroupDevice (line 27) - compile",
"src/programs/lirc_mode2.rs - programs::lirc_mode2::LircMode2 (line 25) - compile",
"src/programs/fentry.rs - programs::fentry::FEntry (line 26) - compile",
"src/programs/cgroup_sysctl.rs - programs::cgroup_sysctl::CgroupSysctl (line 28) - compile",
"src/maps/array/per_cpu_array.rs - maps::array::per_cpu_array::PerCpuArray (line 22) - compile",
"src/programs/sk_lookup.rs - programs::sk_lookup::SkLookup (line 25) - compile",
"src/programs/links.rs - programs::links::FdLink::pin (line 128) - compile",
"src/maps/sock/sock_hash.rs - maps::sock::sock_hash::SockHash (line 30) - compile",
"src/maps/stack_trace.rs - maps::stack_trace::StackTraceMap (line 24) - compile",
"src/programs/tp_btf.rs - programs::tp_btf::BtfTracePoint (line 25) - compile",
"src/programs/perf_event.rs - programs::perf_event::PerfEvent (line 90) - compile",
"src/programs/sk_msg.rs - programs::sk_msg::SkMsg (line 27) - compile",
"src/programs/tc.rs - programs::tc::SchedClassifier (line 47) - compile",
"src/maps/perf/perf_event_array.rs - maps::perf::perf_event_array::PerfEventArray (line 84) - compile",
"src/programs/socket_filter.rs - programs::socket_filter::SocketFilter (line 37) - compile",
"src/programs/trace_point.rs - programs::trace_point::TracePoint (line 42) - compile",
"src/programs/sock_ops.rs - programs::sock_ops::SockOps (line 25) - compile",
"src/maps/perf/async_perf_event_array.rs - maps::perf::async_perf_event_array::AsyncPerfEventArray (line 38) - compile",
"src/programs/mod.rs - programs::loaded_programs (line 1040)"
] |
[
"tests::btf_relocations::relocate_enum64",
"tests::btf_relocations::relocate_enum64_signed",
"tests::btf_relocations::relocate_enum_signed",
"tests::load::pin_lifecycle",
"tests::smoke::xdp"
] |
[
"tests::btf_relocations::relocate_pointer",
"tests::elf::test_maps",
"tests::btf_relocations::relocate_field",
"tests::btf_relocations::relocate_struct_flavors",
"tests::btf_relocations::relocate_enum",
"tests::rbpf::use_map_with_rbpf",
"tests::rbpf::run_with_rbpf",
"tests::load::pin_lifecycle_kprobe",
"tests::smoke::extension",
"tests::bpf_probe_read::bpf_probe_read_user_str_bytes",
"tests::load::pin_lifecycle_tracepoint",
"tests::load::unload_xdp",
"tests::load::basic_tracepoint",
"tests::bpf_probe_read::bpf_probe_read_kernel_str_bytes_truncate",
"tests::bpf_probe_read::bpf_probe_read_user_str_bytes_empty_string",
"tests::load::long_name",
"tests::load::multiple_btf_maps",
"tests::relocations::relocations",
"tests::load::basic_uprobe",
"tests::relocations::text_64_64_reloc",
"tests::bpf_probe_read::bpf_probe_read_kernel_str_bytes_empty_dest",
"tests::load::unload_kprobe",
"tests::bpf_probe_read::bpf_probe_read_kernel_str_bytes_empty_string",
"tests::load::pin_lifecycle_uprobe",
"tests::bpf_probe_read::bpf_probe_read_user_str_bytes_empty_dest",
"tests::load::pin_link",
"tests::bpf_probe_read::bpf_probe_read_user_str_bytes_truncate",
"tests::bpf_probe_read::bpf_probe_read_kernel_str_bytes",
"tests::log::log"
] |
[] |
auto_2025-06-07
|
|
aya-rs/aya
| 921
|
aya-rs__aya-921
|
[
"918"
] |
1d272f38bd19f64652ac8a278948f61e66164856
|
diff --git a/aya/src/programs/cgroup_device.rs b/aya/src/programs/cgroup_device.rs
--- a/aya/src/programs/cgroup_device.rs
+++ b/aya/src/programs/cgroup_device.rs
@@ -8,7 +8,7 @@ use crate::{
bpf_prog_get_fd_by_id, define_link_wrapper, load_program, query, CgroupAttachMode, FdLink,
Link, ProgAttachLink, ProgramData, ProgramError, ProgramFd,
},
- sys::{bpf_link_create, LinkTarget, SyscallError},
+ sys::{bpf_link_create, LinkTarget, ProgQueryTarget, SyscallError},
util::KernelVersion,
};
diff --git a/aya/src/programs/cgroup_device.rs b/aya/src/programs/cgroup_device.rs
--- a/aya/src/programs/cgroup_device.rs
+++ b/aya/src/programs/cgroup_device.rs
@@ -77,6 +77,7 @@ impl CgroupDevice {
BPF_CGROUP_DEVICE,
None,
mode.into(),
+ None,
)
.map_err(|(_, io_error)| SyscallError {
call: "bpf_link_create",
diff --git a/aya/src/programs/cgroup_device.rs b/aya/src/programs/cgroup_device.rs
--- a/aya/src/programs/cgroup_device.rs
+++ b/aya/src/programs/cgroup_device.rs
@@ -119,7 +120,12 @@ impl CgroupDevice {
/// Queries the cgroup for attached programs.
pub fn query<T: AsFd>(target_fd: T) -> Result<Vec<CgroupDeviceLink>, ProgramError> {
let target_fd = target_fd.as_fd();
- let prog_ids = query(target_fd, BPF_CGROUP_DEVICE, 0, &mut None)?;
+ let (_, prog_ids) = query(
+ ProgQueryTarget::Fd(target_fd),
+ BPF_CGROUP_DEVICE,
+ 0,
+ &mut None,
+ )?;
prog_ids
.into_iter()
diff --git a/aya/src/programs/cgroup_skb.rs b/aya/src/programs/cgroup_skb.rs
--- a/aya/src/programs/cgroup_skb.rs
+++ b/aya/src/programs/cgroup_skb.rs
@@ -105,6 +105,7 @@ impl CgroupSkb {
attach_type,
None,
mode.into(),
+ None,
)
.map_err(|(_, io_error)| SyscallError {
call: "bpf_link_create",
diff --git a/aya/src/programs/cgroup_sock.rs b/aya/src/programs/cgroup_sock.rs
--- a/aya/src/programs/cgroup_sock.rs
+++ b/aya/src/programs/cgroup_sock.rs
@@ -83,6 +83,7 @@ impl CgroupSock {
attach_type,
None,
mode.into(),
+ None,
)
.map_err(|(_, io_error)| SyscallError {
call: "bpf_link_create",
diff --git a/aya/src/programs/cgroup_sock_addr.rs b/aya/src/programs/cgroup_sock_addr.rs
--- a/aya/src/programs/cgroup_sock_addr.rs
+++ b/aya/src/programs/cgroup_sock_addr.rs
@@ -84,6 +84,7 @@ impl CgroupSockAddr {
attach_type,
None,
mode.into(),
+ None,
)
.map_err(|(_, io_error)| SyscallError {
call: "bpf_link_create",
diff --git a/aya/src/programs/cgroup_sockopt.rs b/aya/src/programs/cgroup_sockopt.rs
--- a/aya/src/programs/cgroup_sockopt.rs
+++ b/aya/src/programs/cgroup_sockopt.rs
@@ -81,6 +81,7 @@ impl CgroupSockopt {
attach_type,
None,
mode.into(),
+ None,
)
.map_err(|(_, io_error)| SyscallError {
call: "bpf_link_create",
diff --git a/aya/src/programs/cgroup_sysctl.rs b/aya/src/programs/cgroup_sysctl.rs
--- a/aya/src/programs/cgroup_sysctl.rs
+++ b/aya/src/programs/cgroup_sysctl.rs
@@ -76,6 +76,7 @@ impl CgroupSysctl {
BPF_CGROUP_SYSCTL,
None,
mode.into(),
+ None,
)
.map_err(|(_, io_error)| SyscallError {
call: "bpf_link_create",
diff --git a/aya/src/programs/extension.rs b/aya/src/programs/extension.rs
--- a/aya/src/programs/extension.rs
+++ b/aya/src/programs/extension.rs
@@ -103,6 +103,7 @@ impl Extension {
BPF_CGROUP_INET_INGRESS,
Some(btf_id),
0,
+ None,
)
.map_err(|(_, io_error)| SyscallError {
call: "bpf_link_create",
diff --git a/aya/src/programs/extension.rs b/aya/src/programs/extension.rs
--- a/aya/src/programs/extension.rs
+++ b/aya/src/programs/extension.rs
@@ -140,6 +141,7 @@ impl Extension {
BPF_CGROUP_INET_INGRESS,
Some(btf_id),
0,
+ None,
)
.map_err(|(_, io_error)| SyscallError {
call: "bpf_link_create",
diff --git a/aya/src/programs/links.rs b/aya/src/programs/links.rs
--- a/aya/src/programs/links.rs
+++ b/aya/src/programs/links.rs
@@ -10,9 +10,12 @@ use std::{
use thiserror::Error;
use crate::{
- generated::{bpf_attach_type, BPF_F_ALLOW_MULTI, BPF_F_ALLOW_OVERRIDE},
+ generated::{
+ bpf_attach_type, BPF_F_AFTER, BPF_F_ALLOW_MULTI, BPF_F_ALLOW_OVERRIDE, BPF_F_BEFORE,
+ BPF_F_ID, BPF_F_LINK, BPF_F_REPLACE,
+ },
pin::PinError,
- programs::{ProgramError, ProgramFd},
+ programs::{MultiProgLink, MultiProgram, ProgramError, ProgramFd, ProgramId},
sys::{bpf_get_object, bpf_pin_object, bpf_prog_attach, bpf_prog_detach, SyscallError},
};
diff --git a/aya/src/programs/links.rs b/aya/src/programs/links.rs
--- a/aya/src/programs/links.rs
+++ b/aya/src/programs/links.rs
@@ -116,7 +119,7 @@ pub struct FdLinkId(pub(crate) RawFd);
///
/// # Example
///
-///```no_run
+/// ```no_run
/// # let mut bpf = Ebpf::load_file("ebpf_programs.o")?;
/// use aya::{Ebpf, programs::{links::FdLink, KProbe}};
///
diff --git a/aya/src/programs/links.rs b/aya/src/programs/links.rs
--- a/aya/src/programs/links.rs
+++ b/aya/src/programs/links.rs
@@ -329,7 +332,7 @@ macro_rules! define_link_wrapper {
pub struct $wrapper(Option<$base>);
#[allow(dead_code)]
- // allow dead code since currently XDP is the only consumer of inner and
+ // allow dead code since currently XDP/TC are the only consumers of inner and
// into_inner
impl $wrapper {
fn new(base: $base) -> $wrapper {
diff --git a/aya/src/programs/lirc_mode2.rs b/aya/src/programs/lirc_mode2.rs
--- a/aya/src/programs/lirc_mode2.rs
+++ b/aya/src/programs/lirc_mode2.rs
@@ -7,7 +7,7 @@ use crate::{
load_program, query, CgroupAttachMode, Link, ProgramData, ProgramError, ProgramFd,
ProgramInfo,
},
- sys::{bpf_prog_attach, bpf_prog_detach, bpf_prog_get_fd_by_id},
+ sys::{bpf_prog_attach, bpf_prog_detach, bpf_prog_get_fd_by_id, ProgQueryTarget},
};
/// A program used to decode IR into key events for a lirc device.
diff --git a/aya/src/programs/lirc_mode2.rs b/aya/src/programs/lirc_mode2.rs
--- a/aya/src/programs/lirc_mode2.rs
+++ b/aya/src/programs/lirc_mode2.rs
@@ -100,7 +100,7 @@ impl LircMode2 {
/// Queries the lirc device for attached programs.
pub fn query<T: AsFd>(target_fd: T) -> Result<Vec<LircLink>, ProgramError> {
let target_fd = target_fd.as_fd();
- let prog_ids = query(target_fd, BPF_LIRC_MODE2, 0, &mut None)?;
+ let (_, prog_ids) = query(ProgQueryTarget::Fd(target_fd), BPF_LIRC_MODE2, 0, &mut None)?;
prog_ids
.into_iter()
diff --git a/aya/src/programs/mod.rs b/aya/src/programs/mod.rs
--- a/aya/src/programs/mod.rs
+++ b/aya/src/programs/mod.rs
@@ -72,7 +72,7 @@ pub mod xdp;
use std::{
ffi::CString,
io,
- os::fd::{AsFd, AsRawFd, BorrowedFd},
+ os::fd::{AsFd, BorrowedFd},
path::{Path, PathBuf},
sync::Arc,
};
diff --git a/aya/src/programs/mod.rs b/aya/src/programs/mod.rs
--- a/aya/src/programs/mod.rs
+++ b/aya/src/programs/mod.rs
@@ -80,6 +80,7 @@ use std::{
use info::impl_info;
pub use info::{loaded_programs, ProgramInfo, ProgramType};
use libc::ENOSPC;
+use tc::SchedClassifierLink;
use thiserror::Error;
// re-export the main items needed to load and attach
diff --git a/aya/src/programs/mod.rs b/aya/src/programs/mod.rs
--- a/aya/src/programs/mod.rs
+++ b/aya/src/programs/mod.rs
@@ -94,7 +95,7 @@ pub use crate::programs::{
fentry::FEntry,
fexit::FExit,
kprobe::{KProbe, KProbeError},
- links::{CgroupAttachMode, Link},
+ links::{CgroupAttachMode, Link, LinkOrder},
lirc_mode2::LircMode2,
lsm::Lsm,
perf_event::{PerfEvent, PerfEventScope, PerfTypeId, SamplePolicy},
diff --git a/aya/src/programs/mod.rs b/aya/src/programs/mod.rs
--- a/aya/src/programs/mod.rs
+++ b/aya/src/programs/mod.rs
@@ -120,7 +121,7 @@ use crate::{
sys::{
bpf_btf_get_fd_by_id, bpf_get_object, bpf_link_get_fd_by_id, bpf_link_get_info_by_fd,
bpf_load_program, bpf_pin_object, bpf_prog_get_fd_by_id, bpf_prog_query, iter_link_ids,
- retry_with_verifier_logs, EbpfLoadProgramAttrs, SyscallError,
+ retry_with_verifier_logs, EbpfLoadProgramAttrs, ProgQueryTarget, SyscallError,
},
util::KernelVersion,
VerifierLogLevel,
diff --git a/aya/src/programs/mod.rs b/aya/src/programs/mod.rs
--- a/aya/src/programs/mod.rs
+++ b/aya/src/programs/mod.rs
@@ -238,7 +239,20 @@ impl AsFd for ProgramFd {
}
}
-/// The various eBPF programs.
+/// A [`Program`] identifier.
+pub struct ProgramId(u32);
+
+impl ProgramId {
+ /// Create a new program id.
+ ///
+ /// This method is unsafe since it doesn't check that the given `id` is a
+ /// valid program id.
+ pub unsafe fn new(id: u32) -> Self {
+ Self(id)
+ }
+}
+
+/// eBPF program type.
#[derive(Debug)]
pub enum Program {
/// A [`KProbe`] program
diff --git a/aya/src/programs/mod.rs b/aya/src/programs/mod.rs
--- a/aya/src/programs/mod.rs
+++ b/aya/src/programs/mod.rs
@@ -668,28 +682,30 @@ fn load_program<T: Link>(
}
pub(crate) fn query(
- target_fd: BorrowedFd<'_>,
+ target: ProgQueryTarget<'_>,
attach_type: bpf_attach_type,
query_flags: u32,
attach_flags: &mut Option<u32>,
-) -> Result<Vec<u32>, ProgramError> {
+) -> Result<(u64, Vec<u32>), ProgramError> {
let mut prog_ids = vec![0u32; 64];
let mut prog_cnt = prog_ids.len() as u32;
+ let mut revision = 0;
let mut retries = 0;
loop {
match bpf_prog_query(
- target_fd.as_fd().as_raw_fd(),
+ &target,
attach_type,
query_flags,
attach_flags.as_mut(),
&mut prog_ids,
&mut prog_cnt,
+ &mut revision,
) {
Ok(_) => {
prog_ids.resize(prog_cnt as usize, 0);
- return Ok(prog_ids);
+ return Ok((revision, prog_ids));
}
Err((_, io_error)) => {
if retries == 0 && io_error.raw_os_error() == Some(ENOSPC) {
diff --git a/aya/src/programs/mod.rs b/aya/src/programs/mod.rs
--- a/aya/src/programs/mod.rs
+++ b/aya/src/programs/mod.rs
@@ -797,6 +813,57 @@ impl_fd!(
CgroupDevice,
);
+/// Trait implemented by the [`Program`] types which support the kernel's
+/// [generic multi-prog API](https://github.com/torvalds/linux/commit/053c8e1f235dc3f69d13375b32f4209228e1cb96).
+///
+/// # Minimum kernel version
+///
+/// The minimum kernel version required to use this feature is 6.6.0.
+pub trait MultiProgram {
+ /// Borrows the file descriptor.
+ fn fd(&self) -> Result<BorrowedFd<'_>, ProgramError>;
+}
+
+macro_rules! impl_multiprog_fd {
+ ($($struct_name:ident),+ $(,)?) => {
+ $(
+ impl MultiProgram for $struct_name {
+ fn fd(&self) -> Result<BorrowedFd<'_>, ProgramError> {
+ Ok(self.fd()?.as_fd())
+ }
+ }
+ )+
+ }
+}
+
+impl_multiprog_fd!(SchedClassifier);
+
+/// Trait implemented by the [`Link`] types which support the kernel's
+/// [generic multi-prog API](https://github.com/torvalds/linux/commit/053c8e1f235dc3f69d13375b32f4209228e1cb96).
+///
+/// # Minimum kernel version
+///
+/// The minimum kernel version required to use this feature is 6.6.0.
+pub trait MultiProgLink {
+ /// Borrows the file descriptor.
+ fn fd(&self) -> Result<BorrowedFd<'_>, LinkError>;
+}
+
+macro_rules! impl_multiproglink_fd {
+ ($($struct_name:ident),+ $(,)?) => {
+ $(
+ impl MultiProgLink for $struct_name {
+ fn fd(&self) -> Result<BorrowedFd<'_>, LinkError> {
+ let link: &FdLink = self.try_into()?;
+ Ok(link.fd.as_fd())
+ }
+ }
+ )+
+ }
+}
+
+impl_multiproglink_fd!(SchedClassifierLink);
+
macro_rules! impl_program_pin{
($($struct_name:ident),+ $(,)?) => {
$(
diff --git a/aya/src/programs/perf_attach.rs b/aya/src/programs/perf_attach.rs
--- a/aya/src/programs/perf_attach.rs
+++ b/aya/src/programs/perf_attach.rs
@@ -75,11 +75,18 @@ pub(crate) fn perf_attach(
fd: crate::MockableFd,
) -> Result<PerfLinkInner, ProgramError> {
if FEATURES.bpf_perf_link() {
- let link_fd = bpf_link_create(prog_fd, LinkTarget::Fd(fd.as_fd()), BPF_PERF_EVENT, None, 0)
- .map_err(|(_, io_error)| SyscallError {
- call: "bpf_link_create",
- io_error,
- })?;
+ let link_fd = bpf_link_create(
+ prog_fd,
+ LinkTarget::Fd(fd.as_fd()),
+ BPF_PERF_EVENT,
+ None,
+ 0,
+ None,
+ )
+ .map_err(|(_, io_error)| SyscallError {
+ call: "bpf_link_create",
+ io_error,
+ })?;
Ok(PerfLinkInner::FdLink(FdLink::new(link_fd)))
} else {
perf_attach_either(prog_fd, fd, None)
diff --git a/aya/src/programs/sk_lookup.rs b/aya/src/programs/sk_lookup.rs
--- a/aya/src/programs/sk_lookup.rs
+++ b/aya/src/programs/sk_lookup.rs
@@ -65,11 +65,18 @@ impl SkLookup {
let prog_fd = prog_fd.as_fd();
let netns_fd = netns.as_fd();
- let link_fd = bpf_link_create(prog_fd, LinkTarget::Fd(netns_fd), BPF_SK_LOOKUP, None, 0)
- .map_err(|(_, io_error)| SyscallError {
- call: "bpf_link_create",
- io_error,
- })?;
+ let link_fd = bpf_link_create(
+ prog_fd,
+ LinkTarget::Fd(netns_fd),
+ BPF_SK_LOOKUP,
+ None,
+ 0,
+ None,
+ )
+ .map_err(|(_, io_error)| SyscallError {
+ call: "bpf_link_create",
+ io_error,
+ })?;
self.data
.links
.insert(SkLookupLink::new(FdLink::new(link_fd)))
diff --git a/aya/src/programs/sock_ops.rs b/aya/src/programs/sock_ops.rs
--- a/aya/src/programs/sock_ops.rs
+++ b/aya/src/programs/sock_ops.rs
@@ -75,6 +75,7 @@ impl SockOps {
attach_type,
None,
mode.into(),
+ None,
)
.map_err(|(_, io_error)| SyscallError {
call: "bpf_link_create",
diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs
--- a/aya/src/programs/tc.rs
+++ b/aya/src/programs/tc.rs
@@ -8,16 +8,24 @@ use std::{
use thiserror::Error;
+use super::{FdLink, ProgramInfo};
use crate::{
generated::{
- bpf_prog_type::BPF_PROG_TYPE_SCHED_CLS, TC_H_CLSACT, TC_H_MIN_EGRESS, TC_H_MIN_INGRESS,
+ bpf_attach_type::{self, BPF_TCX_EGRESS, BPF_TCX_INGRESS},
+ bpf_link_type,
+ bpf_prog_type::BPF_PROG_TYPE_SCHED_CLS,
+ TC_H_CLSACT, TC_H_MIN_EGRESS, TC_H_MIN_INGRESS,
+ },
+ programs::{
+ define_link_wrapper, load_program, query, Link, LinkError, LinkOrder, ProgramData,
+ ProgramError,
},
- programs::{define_link_wrapper, load_program, Link, ProgramData, ProgramError},
sys::{
+ bpf_link_create, bpf_link_get_info_by_fd, bpf_link_update, bpf_prog_get_fd_by_id,
netlink_find_filter_with_name, netlink_qdisc_add_clsact, netlink_qdisc_attach,
- netlink_qdisc_detach,
+ netlink_qdisc_detach, LinkTarget, ProgQueryTarget, SyscallError,
},
- util::{ifindex_from_ifname, tc_handler_make},
+ util::{ifindex_from_ifname, tc_handler_make, KernelVersion},
VerifierLogLevel,
};
diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs
--- a/aya/src/programs/tc.rs
+++ b/aya/src/programs/tc.rs
@@ -89,21 +97,49 @@ pub enum TcError {
/// the clsact qdisc is already attached
#[error("the clsact qdisc is already attached")]
AlreadyAttached,
+ /// tcx links can only be attached to ingress or egress, custom attachment is not supported
+ #[error("tcx links can only be attached to ingress or egress, custom attachment: {0} is not supported")]
+ InvalidTcxAttach(u32),
+ /// operation not supported for programs loaded via tcx
+ #[error("operation not supported for programs loaded via tcx")]
+ InvalidLinkOperation,
}
impl TcAttachType {
- pub(crate) fn parent(&self) -> u32 {
+ pub(crate) fn tc_parent(&self) -> u32 {
match self {
Self::Custom(parent) => *parent,
Self::Ingress => tc_handler_make(TC_H_CLSACT, TC_H_MIN_INGRESS),
Self::Egress => tc_handler_make(TC_H_CLSACT, TC_H_MIN_EGRESS),
}
}
+
+ pub(crate) fn tcx_attach_type(&self) -> Result<bpf_attach_type, TcError> {
+ match self {
+ Self::Ingress => Ok(BPF_TCX_INGRESS),
+ Self::Egress => Ok(BPF_TCX_EGRESS),
+ Self::Custom(tcx_attach_type) => Err(TcError::InvalidTcxAttach(*tcx_attach_type)),
+ }
+ }
+}
+
+/// Options for a SchedClassifier attach operation.
+///
+/// The options vary based on what is supported by the current kernel. Kernels
+/// older than 6.6.0 must utilize netlink for attachments, while newer kernels
+/// can utilize the modern TCX eBPF link type which supports the kernel's
+/// multi-prog API.
+#[derive(Debug)]
+pub enum TcAttachOptions {
+ /// Netlink attach options.
+ Netlink(NlOptions),
+ /// Tcx attach options.
+ TcxOrder(LinkOrder),
}
-/// Options for SchedClassifier attach
-#[derive(Default)]
-pub struct TcOptions {
+/// Options for SchedClassifier attach via netlink.
+#[derive(Debug, Default, Hash, Eq, PartialEq)]
+pub struct NlOptions {
/// Priority assigned to tc program with lower number = higher priority.
/// If set to default (0), the system chooses the next highest priority or 49152 if no filters exist yet
pub priority: u16,
diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs
--- a/aya/src/programs/tc.rs
+++ b/aya/src/programs/tc.rs
@@ -118,25 +154,46 @@ impl SchedClassifier {
load_program(BPF_PROG_TYPE_SCHED_CLS, &mut self.data)
}
- /// Attaches the program to the given `interface` using the default options.
+ /// Attaches the program to the given `interface`.
+ ///
+ /// On kernels >= 6.6.0, it will attempt to use the TCX interface and attach as
+ /// the last TCX program. On older kernels, it will fallback to using the
+ /// legacy netlink interface.
+ ///
+ /// For finer grained control over link ordering use [`SchedClassifier::attach_with_options`].
///
/// The returned value can be used to detach, see [SchedClassifier::detach].
///
/// # Errors
///
- /// [`TcError::NetlinkError`] is returned if attaching fails. A common cause
- /// of failure is not having added the `clsact` qdisc to the given
- /// interface, see [`qdisc_add_clsact`]
+ /// When attaching fails, [`ProgramError::SyscallError`] is returned for
+ /// kernels `>= 6.6.0`, and [`TcError::NetlinkError`] is returned for
+ /// older kernels. A common cause of netlink attachment failure is not having added
+ /// the `clsact` qdisc to the given interface, see [`qdisc_add_clsact`]
///
pub fn attach(
&mut self,
interface: &str,
attach_type: TcAttachType,
) -> Result<SchedClassifierLinkId, ProgramError> {
- self.attach_with_options(interface, attach_type, TcOptions::default())
+ if !matches!(attach_type, TcAttachType::Custom(_))
+ && KernelVersion::current().unwrap() >= KernelVersion::new(6, 6, 0)
+ {
+ self.attach_with_options(
+ interface,
+ attach_type,
+ TcAttachOptions::TcxOrder(LinkOrder::default()),
+ )
+ } else {
+ self.attach_with_options(
+ interface,
+ attach_type,
+ TcAttachOptions::Netlink(NlOptions::default()),
+ )
+ }
}
- /// Attaches the program to the given `interface` with options defined in [`TcOptions`].
+ /// Attaches the program to the given `interface` with options defined in [`TcAttachOptions`].
///
/// The returned value can be used to detach, see [SchedClassifier::detach].
///
diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs
--- a/aya/src/programs/tc.rs
+++ b/aya/src/programs/tc.rs
@@ -150,11 +207,11 @@ impl SchedClassifier {
&mut self,
interface: &str,
attach_type: TcAttachType,
- options: TcOptions,
+ options: TcAttachOptions,
) -> Result<SchedClassifierLinkId, ProgramError> {
let if_index = ifindex_from_ifname(interface)
.map_err(|io_error| TcError::NetlinkError { io_error })?;
- self.do_attach(if_index as i32, attach_type, options, true)
+ self.do_attach(if_index, attach_type, options, true)
}
/// Atomically replaces the program referenced by the provided link.
diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs
--- a/aya/src/programs/tc.rs
+++ b/aya/src/programs/tc.rs
@@ -164,46 +221,98 @@ impl SchedClassifier {
&mut self,
link: SchedClassifierLink,
) -> Result<SchedClassifierLinkId, ProgramError> {
- let TcLink {
- if_index,
- attach_type,
- priority,
- handle,
- } = link.into_inner();
- self.do_attach(if_index, attach_type, TcOptions { priority, handle }, false)
+ let prog_fd = self.fd()?;
+ let prog_fd = prog_fd.as_fd();
+ match link.into_inner() {
+ TcLinkInner::FdLink(link) => {
+ let fd = link.fd;
+ let link_fd = fd.as_fd();
+
+ bpf_link_update(link_fd.as_fd(), prog_fd, None, 0).map_err(|(_, io_error)| {
+ SyscallError {
+ call: "bpf_link_update",
+ io_error,
+ }
+ })?;
+
+ self.data
+ .links
+ .insert(SchedClassifierLink::new(TcLinkInner::FdLink(FdLink::new(
+ fd,
+ ))))
+ }
+ TcLinkInner::NlLink(NlLink {
+ if_index,
+ attach_type,
+ priority,
+ handle,
+ }) => self.do_attach(
+ if_index,
+ attach_type,
+ TcAttachOptions::Netlink(NlOptions { priority, handle }),
+ false,
+ ),
+ }
}
fn do_attach(
&mut self,
- if_index: i32,
+ if_index: u32,
attach_type: TcAttachType,
- options: TcOptions,
+ options: TcAttachOptions,
create: bool,
) -> Result<SchedClassifierLinkId, ProgramError> {
let prog_fd = self.fd()?;
let prog_fd = prog_fd.as_fd();
- let name = self.data.name.as_deref().unwrap_or_default();
- // TODO: avoid this unwrap by adding a new error variant.
- let name = CString::new(name).unwrap();
- let (priority, handle) = unsafe {
- netlink_qdisc_attach(
- if_index,
- &attach_type,
- prog_fd,
- &name,
- options.priority,
- options.handle,
- create,
- )
- }
- .map_err(|io_error| TcError::NetlinkError { io_error })?;
- self.data.links.insert(SchedClassifierLink::new(TcLink {
- if_index,
- attach_type,
- priority,
- handle,
- }))
+ match options {
+ TcAttachOptions::Netlink(options) => {
+ let name = self.data.name.as_deref().unwrap_or_default();
+ // TODO: avoid this unwrap by adding a new error variant.
+ let name = CString::new(name).unwrap();
+ let (priority, handle) = unsafe {
+ netlink_qdisc_attach(
+ if_index as i32,
+ &attach_type,
+ prog_fd,
+ &name,
+ options.priority,
+ options.handle,
+ create,
+ )
+ }
+ .map_err(|io_error| TcError::NetlinkError { io_error })?;
+
+ self.data
+ .links
+ .insert(SchedClassifierLink::new(TcLinkInner::NlLink(NlLink {
+ if_index,
+ attach_type,
+ priority,
+ handle,
+ })))
+ }
+ TcAttachOptions::TcxOrder(options) => {
+ let link_fd = bpf_link_create(
+ prog_fd,
+ LinkTarget::IfIndex(if_index),
+ attach_type.tcx_attach_type()?,
+ None,
+ options.flags.bits(),
+ Some(&options.link_ref),
+ )
+ .map_err(|(_, io_error)| SyscallError {
+ call: "bpf_mprog_attach",
+ io_error,
+ })?;
+
+ self.data
+ .links
+ .insert(SchedClassifierLink::new(TcLinkInner::FdLink(FdLink::new(
+ link_fd,
+ ))))
+ }
+ }
}
/// Detaches the program.
diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs
--- a/aya/src/programs/tc.rs
+++ b/aya/src/programs/tc.rs
@@ -234,42 +343,153 @@ impl SchedClassifier {
let data = ProgramData::from_pinned_path(path, VerifierLogLevel::default())?;
Ok(Self { data })
}
+
+ /// Queries a given interface for attached TCX programs.
+ ///
+ /// # Example
+ ///
+ /// ```no_run
+ /// # use aya::programs::tc::{TcAttachType, SchedClassifier};
+ /// # #[derive(Debug, thiserror::Error)]
+ /// # enum Error {
+ /// # #[error(transparent)]
+ /// # Program(#[from] aya::programs::ProgramError),
+ /// # }
+ /// let (revision, programs) = SchedClassifier::query_tcx("eth0", TcAttachType::Ingress)?;
+ /// # Ok::<(), Error>(())
+ /// ```
+ pub fn query_tcx(
+ interface: &str,
+ attach_type: TcAttachType,
+ ) -> Result<(u64, Vec<ProgramInfo>), ProgramError> {
+ let if_index = ifindex_from_ifname(interface)
+ .map_err(|io_error| TcError::NetlinkError { io_error })?;
+
+ let (revision, prog_ids) = query(
+ ProgQueryTarget::IfIndex(if_index),
+ attach_type.tcx_attach_type()?,
+ 0,
+ &mut None,
+ )?;
+
+ let prog_infos = prog_ids
+ .into_iter()
+ .map(|prog_id| {
+ let prog_fd = bpf_prog_get_fd_by_id(prog_id)?;
+ let prog_info = ProgramInfo::new_from_fd(prog_fd.as_fd())?;
+ Ok::<ProgramInfo, ProgramError>(prog_info)
+ })
+ .collect::<Result<_, _>>()?;
+
+ Ok((revision, prog_infos))
+ }
}
#[derive(Debug, Hash, Eq, PartialEq)]
-pub(crate) struct TcLinkId(i32, TcAttachType, u16, u32);
+pub(crate) struct NlLinkId(u32, TcAttachType, u16, u32);
#[derive(Debug)]
-struct TcLink {
- if_index: i32,
+pub(crate) struct NlLink {
+ if_index: u32,
attach_type: TcAttachType,
priority: u16,
handle: u32,
}
-impl Link for TcLink {
- type Id = TcLinkId;
+impl Link for NlLink {
+ type Id = NlLinkId;
fn id(&self) -> Self::Id {
- TcLinkId(self.if_index, self.attach_type, self.priority, self.handle)
+ NlLinkId(self.if_index, self.attach_type, self.priority, self.handle)
}
fn detach(self) -> Result<(), ProgramError> {
unsafe {
- netlink_qdisc_detach(self.if_index, &self.attach_type, self.priority, self.handle)
+ netlink_qdisc_detach(
+ self.if_index as i32,
+ &self.attach_type,
+ self.priority,
+ self.handle,
+ )
}
.map_err(|io_error| TcError::NetlinkError { io_error })?;
Ok(())
}
}
+#[derive(Debug, Hash, Eq, PartialEq)]
+pub(crate) enum TcLinkIdInner {
+ FdLinkId(<FdLink as Link>::Id),
+ NlLinkId(<NlLink as Link>::Id),
+}
+
+#[derive(Debug)]
+pub(crate) enum TcLinkInner {
+ FdLink(FdLink),
+ NlLink(NlLink),
+}
+
+impl Link for TcLinkInner {
+ type Id = TcLinkIdInner;
+
+ fn id(&self) -> Self::Id {
+ match self {
+ Self::FdLink(link) => TcLinkIdInner::FdLinkId(link.id()),
+ Self::NlLink(link) => TcLinkIdInner::NlLinkId(link.id()),
+ }
+ }
+
+ fn detach(self) -> Result<(), ProgramError> {
+ match self {
+ Self::FdLink(link) => link.detach(),
+ Self::NlLink(link) => link.detach(),
+ }
+ }
+}
+
+impl<'a> TryFrom<&'a SchedClassifierLink> for &'a FdLink {
+ type Error = LinkError;
+
+ fn try_from(value: &'a SchedClassifierLink) -> Result<Self, Self::Error> {
+ if let TcLinkInner::FdLink(fd) = value.inner() {
+ Ok(fd)
+ } else {
+ Err(LinkError::InvalidLink)
+ }
+ }
+}
+
+impl TryFrom<SchedClassifierLink> for FdLink {
+ type Error = LinkError;
+
+ fn try_from(value: SchedClassifierLink) -> Result<Self, Self::Error> {
+ if let TcLinkInner::FdLink(fd) = value.into_inner() {
+ Ok(fd)
+ } else {
+ Err(LinkError::InvalidLink)
+ }
+ }
+}
+
+impl TryFrom<FdLink> for SchedClassifierLink {
+ type Error = LinkError;
+
+ fn try_from(fd_link: FdLink) -> Result<Self, Self::Error> {
+ let info = bpf_link_get_info_by_fd(fd_link.fd.as_fd())?;
+ if info.type_ == (bpf_link_type::BPF_LINK_TYPE_TCX as u32) {
+ return Ok(Self::new(TcLinkInner::FdLink(fd_link)));
+ }
+ Err(LinkError::InvalidLink)
+ }
+}
+
define_link_wrapper!(
/// The link used by [SchedClassifier] programs.
SchedClassifierLink,
/// The type returned by [SchedClassifier::attach]. Can be passed to [SchedClassifier::detach].
SchedClassifierLinkId,
- TcLink,
- TcLinkId
+ TcLinkInner,
+ TcLinkIdInner
);
impl SchedClassifierLink {
diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs
--- a/aya/src/programs/tc.rs
+++ b/aya/src/programs/tc.rs
@@ -311,27 +531,39 @@ impl SchedClassifierLink {
handle: u32,
) -> Result<Self, io::Error> {
let if_index = ifindex_from_ifname(if_name)?;
- Ok(Self(Some(TcLink {
- if_index: if_index as i32,
+ Ok(Self(Some(TcLinkInner::NlLink(NlLink {
+ if_index,
attach_type,
priority,
handle,
- })))
+ }))))
}
/// Returns the attach type.
- pub fn attach_type(&self) -> TcAttachType {
- self.inner().attach_type
+ pub fn attach_type(&self) -> Result<TcAttachType, ProgramError> {
+ if let TcLinkInner::NlLink(n) = self.inner() {
+ Ok(n.attach_type)
+ } else {
+ Err(TcError::InvalidLinkOperation.into())
+ }
}
/// Returns the allocated priority. If none was provided at attach time, this was allocated for you.
- pub fn priority(&self) -> u16 {
- self.inner().priority
+ pub fn priority(&self) -> Result<u16, ProgramError> {
+ if let TcLinkInner::NlLink(n) = self.inner() {
+ Ok(n.priority)
+ } else {
+ Err(TcError::InvalidLinkOperation.into())
+ }
}
/// Returns the assigned handle. If none was provided at attach time, this was allocated for you.
- pub fn handle(&self) -> u32 {
- self.inner().handle
+ pub fn handle(&self) -> Result<u32, ProgramError> {
+ if let TcLinkInner::NlLink(n) = self.inner() {
+ Ok(n.handle)
+ } else {
+ Err(TcError::InvalidLinkOperation.into())
+ }
}
}
diff --git a/aya/src/programs/xdp.rs b/aya/src/programs/xdp.rs
--- a/aya/src/programs/xdp.rs
+++ b/aya/src/programs/xdp.rs
@@ -140,7 +140,7 @@ impl Xdp {
// if the program has been loaded, i.e. there is an fd. We get one by:
// - Using `Xdp::from_pin` that sets `expected_attach_type`
// - Calling `Xdp::attach` that sets `expected_attach_type`, as geting an `Xdp`
- // instance trhough `Xdp:try_from(Program)` does not set any fd.
+ // instance through `Xdp:try_from(Program)` does not set any fd.
// So, in all cases where we have an fd, we have an expected_attach_type. Thus, if we
// reach this point, expected_attach_type is guaranteed to be Some(_).
let attach_type = self.data.expected_attach_type.unwrap();
diff --git a/aya/src/programs/xdp.rs b/aya/src/programs/xdp.rs
--- a/aya/src/programs/xdp.rs
+++ b/aya/src/programs/xdp.rs
@@ -150,6 +150,7 @@ impl Xdp {
attach_type,
None,
flags.bits(),
+ None,
)
.map_err(|(_, io_error)| SyscallError {
call: "bpf_link_create",
diff --git a/aya/src/sys/bpf.rs b/aya/src/sys/bpf.rs
--- a/aya/src/sys/bpf.rs
+++ b/aya/src/sys/bpf.rs
@@ -30,6 +30,7 @@ use crate::{
},
copy_instructions,
},
+ programs::links::LinkRef,
sys::{syscall, SysResult, Syscall, SyscallError},
util::KernelVersion,
Btf, Pod, VerifierLogLevel, BPF_OBJ_NAME_LEN, FEATURES,
diff --git a/aya/src/sys/bpf.rs b/aya/src/sys/bpf.rs
--- a/aya/src/sys/bpf.rs
+++ b/aya/src/sys/bpf.rs
@@ -385,6 +386,7 @@ pub(crate) fn bpf_link_create(
attach_type: bpf_attach_type,
btf_id: Option<u32>,
flags: u32,
+ link_ref: Option<&LinkRef>,
) -> SysResult<crate::MockableFd> {
let mut attr = unsafe { mem::zeroed::<bpf_attr>() };
diff --git a/aya/src/sys/bpf.rs b/aya/src/sys/bpf.rs
--- a/aya/src/sys/bpf.rs
+++ b/aya/src/sys/bpf.rs
@@ -399,11 +401,32 @@ pub(crate) fn bpf_link_create(
}
};
attr.link_create.attach_type = attach_type as u32;
- attr.link_create.flags = flags;
+
if let Some(btf_id) = btf_id {
attr.link_create.__bindgen_anon_3.target_btf_id = btf_id;
}
+ attr.link_create.flags = flags;
+
+ // since kernel 6.6
+ match link_ref {
+ Some(LinkRef::Fd(fd)) => {
+ attr.link_create
+ .__bindgen_anon_3
+ .tcx
+ .__bindgen_anon_1
+ .relative_fd = fd.to_owned() as u32;
+ }
+ Some(LinkRef::Id(id)) => {
+ attr.link_create
+ .__bindgen_anon_3
+ .tcx
+ .__bindgen_anon_1
+ .relative_id = id.to_owned();
+ }
+ None => {}
+ };
+
// SAFETY: BPF_LINK_CREATE returns a new file descriptor.
unsafe { fd_sys_bpf(bpf_cmd::BPF_LINK_CREATE, &mut attr) }
}
diff --git a/aya/src/sys/bpf.rs b/aya/src/sys/bpf.rs
--- a/aya/src/sys/bpf.rs
+++ b/aya/src/sys/bpf.rs
@@ -475,25 +498,39 @@ pub(crate) fn bpf_prog_detach(
Ok(())
}
+#[derive(Debug)]
+pub(crate) enum ProgQueryTarget<'a> {
+ Fd(BorrowedFd<'a>),
+ IfIndex(u32),
+}
+
pub(crate) fn bpf_prog_query(
- target_fd: RawFd,
+ target: &ProgQueryTarget<'_>,
attach_type: bpf_attach_type,
query_flags: u32,
attach_flags: Option<&mut u32>,
prog_ids: &mut [u32],
prog_cnt: &mut u32,
+ revision: &mut u64,
) -> SysResult<i64> {
let mut attr = unsafe { mem::zeroed::<bpf_attr>() };
- attr.query.__bindgen_anon_1.target_fd = target_fd as u32;
+ match target {
+ ProgQueryTarget::Fd(fd) => {
+ attr.query.__bindgen_anon_1.target_fd = fd.as_raw_fd() as u32;
+ }
+ ProgQueryTarget::IfIndex(ifindex) => {
+ attr.query.__bindgen_anon_1.target_ifindex = *ifindex;
+ }
+ }
attr.query.attach_type = attach_type as u32;
attr.query.query_flags = query_flags;
attr.query.__bindgen_anon_2.prog_cnt = prog_ids.len() as u32;
attr.query.prog_ids = prog_ids.as_mut_ptr() as u64;
-
let ret = sys_bpf(bpf_cmd::BPF_PROG_QUERY, &mut attr);
*prog_cnt = unsafe { attr.query.__bindgen_anon_2.prog_cnt };
+ *revision = unsafe { attr.query.revision };
if let Some(attach_flags) = attach_flags {
*attach_flags = unsafe { attr.query.attach_flags };
diff --git a/aya/src/sys/bpf.rs b/aya/src/sys/bpf.rs
--- a/aya/src/sys/bpf.rs
+++ b/aya/src/sys/bpf.rs
@@ -826,7 +863,7 @@ pub(crate) fn is_perf_link_supported() -> bool {
let fd = fd.as_fd();
matches!(
// Uses an invalid target FD so we get EBADF if supported.
- bpf_link_create(fd, LinkTarget::IfIndex(u32::MAX), bpf_attach_type::BPF_PERF_EVENT, None, 0),
+ bpf_link_create(fd, LinkTarget::IfIndex(u32::MAX), bpf_attach_type::BPF_PERF_EVENT, None, 0, None),
// Returns EINVAL if unsupported. EBADF if supported.
Err((_, e)) if e.raw_os_error() == Some(libc::EBADF),
)
diff --git a/aya/src/sys/netlink.rs b/aya/src/sys/netlink.rs
--- a/aya/src/sys/netlink.rs
+++ b/aya/src/sys/netlink.rs
@@ -146,7 +146,7 @@ pub(crate) unsafe fn netlink_qdisc_attach(
req.tc_info.tcm_family = AF_UNSPEC as u8;
req.tc_info.tcm_handle = handle; // auto-assigned, if zero
req.tc_info.tcm_ifindex = if_index;
- req.tc_info.tcm_parent = attach_type.parent();
+ req.tc_info.tcm_parent = attach_type.tc_parent();
req.tc_info.tcm_info = tc_handler_make((priority as u32) << 16, htons(ETH_P_ALL as u16) as u32);
let attrs_buf = request_attributes(&mut req, nlmsg_len);
diff --git a/aya/src/sys/netlink.rs b/aya/src/sys/netlink.rs
--- a/aya/src/sys/netlink.rs
+++ b/aya/src/sys/netlink.rs
@@ -207,7 +207,7 @@ pub(crate) unsafe fn netlink_qdisc_detach(
req.tc_info.tcm_family = AF_UNSPEC as u8;
req.tc_info.tcm_handle = handle; // auto-assigned, if zero
req.tc_info.tcm_info = tc_handler_make((priority as u32) << 16, htons(ETH_P_ALL as u16) as u32);
- req.tc_info.tcm_parent = attach_type.parent();
+ req.tc_info.tcm_parent = attach_type.tc_parent();
req.tc_info.tcm_ifindex = if_index;
sock.send(&bytes_of(&req)[..req.header.nlmsg_len as usize])?;
diff --git a/aya/src/sys/netlink.rs b/aya/src/sys/netlink.rs
--- a/aya/src/sys/netlink.rs
+++ b/aya/src/sys/netlink.rs
@@ -236,7 +236,7 @@ pub(crate) unsafe fn netlink_find_filter_with_name(
req.tc_info.tcm_family = AF_UNSPEC as u8;
req.tc_info.tcm_handle = 0; // auto-assigned, if zero
req.tc_info.tcm_ifindex = if_index;
- req.tc_info.tcm_parent = attach_type.parent();
+ req.tc_info.tcm_parent = attach_type.tc_parent();
let sock = NetlinkSocket::open()?;
sock.send(&bytes_of(&req)[..req.header.nlmsg_len as usize])?;
diff --git a/xtask/public-api/aya.txt b/xtask/public-api/aya.txt
--- a/xtask/public-api/aya.txt
+++ b/xtask/public-api/aya.txt
@@ -3907,6 +3907,9 @@ pub fn aya::programs::kprobe::KProbeLink::try_from(fd_link: aya::programs::links
impl core::convert::TryFrom<aya::programs::links::FdLink> for aya::programs::perf_event::PerfEventLink
pub type aya::programs::perf_event::PerfEventLink::Error = aya::programs::links::LinkError
pub fn aya::programs::perf_event::PerfEventLink::try_from(fd_link: aya::programs::links::FdLink) -> core::result::Result<Self, Self::Error>
+impl core::convert::TryFrom<aya::programs::links::FdLink> for aya::programs::tc::SchedClassifierLink
+pub type aya::programs::tc::SchedClassifierLink::Error = aya::programs::links::LinkError
+pub fn aya::programs::tc::SchedClassifierLink::try_from(fd_link: aya::programs::links::FdLink) -> core::result::Result<Self, Self::Error>
impl core::convert::TryFrom<aya::programs::links::FdLink> for aya::programs::trace_point::TracePointLink
pub type aya::programs::trace_point::TracePointLink::Error = aya::programs::links::LinkError
pub fn aya::programs::trace_point::TracePointLink::try_from(fd_link: aya::programs::links::FdLink) -> core::result::Result<Self, Self::Error>
diff --git a/xtask/public-api/aya.txt b/xtask/public-api/aya.txt
--- a/xtask/public-api/aya.txt
+++ b/xtask/public-api/aya.txt
@@ -3919,6 +3922,9 @@ pub fn aya::programs::xdp::XdpLink::try_from(fd_link: aya::programs::links::FdLi
impl core::convert::TryFrom<aya::programs::perf_event::PerfEventLink> for aya::programs::links::FdLink
pub type aya::programs::links::FdLink::Error = aya::programs::links::LinkError
pub fn aya::programs::links::FdLink::try_from(value: aya::programs::perf_event::PerfEventLink) -> core::result::Result<Self, Self::Error>
+impl core::convert::TryFrom<aya::programs::tc::SchedClassifierLink> for aya::programs::links::FdLink
+pub type aya::programs::links::FdLink::Error = aya::programs::links::LinkError
+pub fn aya::programs::links::FdLink::try_from(value: aya::programs::tc::SchedClassifierLink) -> core::result::Result<Self, Self::Error>
impl core::convert::TryFrom<aya::programs::trace_point::TracePointLink> for aya::programs::links::FdLink
pub type aya::programs::links::FdLink::Error = aya::programs::links::LinkError
pub fn aya::programs::links::FdLink::try_from(value: aya::programs::trace_point::TracePointLink) -> core::result::Result<Self, Self::Error>
diff --git a/xtask/public-api/aya.txt b/xtask/public-api/aya.txt
--- a/xtask/public-api/aya.txt
+++ b/xtask/public-api/aya.txt
@@ -3930,6 +3936,9 @@ pub type aya::programs::links::FdLink::Error = aya::programs::links::LinkError
pub fn aya::programs::links::FdLink::try_from(value: aya::programs::xdp::XdpLink) -> core::result::Result<Self, Self::Error>
impl core::fmt::Debug for aya::programs::links::FdLink
pub fn aya::programs::links::FdLink::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
+impl<'a> core::convert::TryFrom<&'a aya::programs::tc::SchedClassifierLink> for &'a aya::programs::links::FdLink
+pub type &'a aya::programs::links::FdLink::Error = aya::programs::links::LinkError
+pub fn &'a aya::programs::links::FdLink::try_from(value: &'a aya::programs::tc::SchedClassifierLink) -> core::result::Result<Self, Self::Error>
impl core::marker::Freeze for aya::programs::links::FdLink
impl core::marker::Send for aya::programs::links::FdLink
impl core::marker::Sync for aya::programs::links::FdLink
diff --git a/xtask/public-api/aya.txt b/xtask/public-api/aya.txt
--- a/xtask/public-api/aya.txt
+++ b/xtask/public-api/aya.txt
@@ -3985,6 +3994,42 @@ impl<T> core::borrow::BorrowMut<T> for aya::programs::links::FdLinkId where T: c
pub fn aya::programs::links::FdLinkId::borrow_mut(&mut self) -> &mut T
impl<T> core::convert::From<T> for aya::programs::links::FdLinkId
pub fn aya::programs::links::FdLinkId::from(t: T) -> T
+pub struct aya::programs::links::LinkOrder
+impl aya::programs::links::LinkOrder
+pub fn aya::programs::links::LinkOrder::after_link<L: aya::programs::MultiProgLink>(link: &L) -> core::result::Result<Self, aya::programs::links::LinkError>
+pub fn aya::programs::links::LinkOrder::after_program<P: aya::programs::MultiProgram>(program: &P) -> core::result::Result<Self, aya::programs::ProgramError>
+pub fn aya::programs::links::LinkOrder::after_program_id(id: aya::programs::ProgramId) -> Self
+pub fn aya::programs::links::LinkOrder::before_link<L: aya::programs::MultiProgLink>(link: &L) -> core::result::Result<Self, aya::programs::links::LinkError>
+pub fn aya::programs::links::LinkOrder::before_program<P: aya::programs::MultiProgram>(program: &P) -> core::result::Result<Self, aya::programs::ProgramError>
+pub fn aya::programs::links::LinkOrder::before_program_id(id: aya::programs::ProgramId) -> Self
+pub fn aya::programs::links::LinkOrder::first() -> Self
+pub fn aya::programs::links::LinkOrder::last() -> Self
+impl core::default::Default for aya::programs::links::LinkOrder
+pub fn aya::programs::links::LinkOrder::default() -> Self
+impl core::fmt::Debug for aya::programs::links::LinkOrder
+pub fn aya::programs::links::LinkOrder::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
+impl core::marker::Freeze for aya::programs::links::LinkOrder
+impl core::marker::Send for aya::programs::links::LinkOrder
+impl core::marker::Sync for aya::programs::links::LinkOrder
+impl core::marker::Unpin for aya::programs::links::LinkOrder
+impl core::panic::unwind_safe::RefUnwindSafe for aya::programs::links::LinkOrder
+impl core::panic::unwind_safe::UnwindSafe for aya::programs::links::LinkOrder
+impl<T, U> core::convert::Into<U> for aya::programs::links::LinkOrder where U: core::convert::From<T>
+pub fn aya::programs::links::LinkOrder::into(self) -> U
+impl<T, U> core::convert::TryFrom<U> for aya::programs::links::LinkOrder where U: core::convert::Into<T>
+pub type aya::programs::links::LinkOrder::Error = core::convert::Infallible
+pub fn aya::programs::links::LinkOrder::try_from(value: U) -> core::result::Result<T, <T as core::convert::TryFrom<U>>::Error>
+impl<T, U> core::convert::TryInto<U> for aya::programs::links::LinkOrder where U: core::convert::TryFrom<T>
+pub type aya::programs::links::LinkOrder::Error = <U as core::convert::TryFrom<T>>::Error
+pub fn aya::programs::links::LinkOrder::try_into(self) -> core::result::Result<U, <U as core::convert::TryFrom<T>>::Error>
+impl<T> core::any::Any for aya::programs::links::LinkOrder where T: 'static + core::marker::Sized
+pub fn aya::programs::links::LinkOrder::type_id(&self) -> core::any::TypeId
+impl<T> core::borrow::Borrow<T> for aya::programs::links::LinkOrder where T: core::marker::Sized
+pub fn aya::programs::links::LinkOrder::borrow(&self) -> &T
+impl<T> core::borrow::BorrowMut<T> for aya::programs::links::LinkOrder where T: core::marker::Sized
+pub fn aya::programs::links::LinkOrder::borrow_mut(&mut self) -> &mut T
+impl<T> core::convert::From<T> for aya::programs::links::LinkOrder
+pub fn aya::programs::links::LinkOrder::from(t: T) -> T
pub struct aya::programs::links::PinnedLink
impl aya::programs::links::PinnedLink
pub fn aya::programs::links::PinnedLink::from_pin<P: core::convert::AsRef<std::path::Path>>(path: P) -> core::result::Result<Self, aya::programs::links::LinkError>
diff --git a/xtask/public-api/aya.txt b/xtask/public-api/aya.txt
--- a/xtask/public-api/aya.txt
+++ b/xtask/public-api/aya.txt
@@ -5504,6 +5549,33 @@ pub fn aya::programs::socket_filter::SocketFilterLinkId::borrow_mut(&mut self) -
impl<T> core::convert::From<T> for aya::programs::socket_filter::SocketFilterLinkId
pub fn aya::programs::socket_filter::SocketFilterLinkId::from(t: T) -> T
pub mod aya::programs::tc
+pub enum aya::programs::tc::TcAttachOptions
+pub aya::programs::tc::TcAttachOptions::Netlink(aya::programs::tc::NlOptions)
+pub aya::programs::tc::TcAttachOptions::TcxOrder(aya::programs::links::LinkOrder)
+impl core::fmt::Debug for aya::programs::tc::TcAttachOptions
+pub fn aya::programs::tc::TcAttachOptions::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
+impl core::marker::Freeze for aya::programs::tc::TcAttachOptions
+impl core::marker::Send for aya::programs::tc::TcAttachOptions
+impl core::marker::Sync for aya::programs::tc::TcAttachOptions
+impl core::marker::Unpin for aya::programs::tc::TcAttachOptions
+impl core::panic::unwind_safe::RefUnwindSafe for aya::programs::tc::TcAttachOptions
+impl core::panic::unwind_safe::UnwindSafe for aya::programs::tc::TcAttachOptions
+impl<T, U> core::convert::Into<U> for aya::programs::tc::TcAttachOptions where U: core::convert::From<T>
+pub fn aya::programs::tc::TcAttachOptions::into(self) -> U
+impl<T, U> core::convert::TryFrom<U> for aya::programs::tc::TcAttachOptions where U: core::convert::Into<T>
+pub type aya::programs::tc::TcAttachOptions::Error = core::convert::Infallible
+pub fn aya::programs::tc::TcAttachOptions::try_from(value: U) -> core::result::Result<T, <T as core::convert::TryFrom<U>>::Error>
+impl<T, U> core::convert::TryInto<U> for aya::programs::tc::TcAttachOptions where U: core::convert::TryFrom<T>
+pub type aya::programs::tc::TcAttachOptions::Error = <U as core::convert::TryFrom<T>>::Error
+pub fn aya::programs::tc::TcAttachOptions::try_into(self) -> core::result::Result<U, <U as core::convert::TryFrom<T>>::Error>
+impl<T> core::any::Any for aya::programs::tc::TcAttachOptions where T: 'static + core::marker::Sized
+pub fn aya::programs::tc::TcAttachOptions::type_id(&self) -> core::any::TypeId
+impl<T> core::borrow::Borrow<T> for aya::programs::tc::TcAttachOptions where T: core::marker::Sized
+pub fn aya::programs::tc::TcAttachOptions::borrow(&self) -> &T
+impl<T> core::borrow::BorrowMut<T> for aya::programs::tc::TcAttachOptions where T: core::marker::Sized
+pub fn aya::programs::tc::TcAttachOptions::borrow_mut(&mut self) -> &mut T
+impl<T> core::convert::From<T> for aya::programs::tc::TcAttachOptions
+pub fn aya::programs::tc::TcAttachOptions::from(t: T) -> T
pub enum aya::programs::tc::TcAttachType
pub aya::programs::tc::TcAttachType::Custom(u32)
pub aya::programs::tc::TcAttachType::Egress
diff --git a/xtask/public-api/aya.txt b/xtask/public-api/aya.txt
--- a/xtask/public-api/aya.txt
+++ b/xtask/public-api/aya.txt
@@ -5551,6 +5623,8 @@ impl<T> core::convert::From<T> for aya::programs::tc::TcAttachType
pub fn aya::programs::tc::TcAttachType::from(t: T) -> T
pub enum aya::programs::tc::TcError
pub aya::programs::tc::TcError::AlreadyAttached
+pub aya::programs::tc::TcError::InvalidLinkOperation
+pub aya::programs::tc::TcError::InvalidTcxAttach(u32)
pub aya::programs::tc::TcError::NetlinkError
pub aya::programs::tc::TcError::NetlinkError::io_error: std::io::error::Error
impl core::convert::From<aya::programs::tc::TcError> for aya::programs::ProgramError
diff --git a/xtask/public-api/aya.txt b/xtask/public-api/aya.txt
--- a/xtask/public-api/aya.txt
+++ b/xtask/public-api/aya.txt
@@ -5585,14 +5659,52 @@ impl<T> core::borrow::BorrowMut<T> for aya::programs::tc::TcError where T: core:
pub fn aya::programs::tc::TcError::borrow_mut(&mut self) -> &mut T
impl<T> core::convert::From<T> for aya::programs::tc::TcError
pub fn aya::programs::tc::TcError::from(t: T) -> T
+pub struct aya::programs::tc::NlOptions
+pub aya::programs::tc::NlOptions::handle: u32
+pub aya::programs::tc::NlOptions::priority: u16
+impl core::cmp::Eq for aya::programs::tc::NlOptions
+impl core::cmp::PartialEq for aya::programs::tc::NlOptions
+pub fn aya::programs::tc::NlOptions::eq(&self, other: &aya::programs::tc::NlOptions) -> bool
+impl core::default::Default for aya::programs::tc::NlOptions
+pub fn aya::programs::tc::NlOptions::default() -> aya::programs::tc::NlOptions
+impl core::fmt::Debug for aya::programs::tc::NlOptions
+pub fn aya::programs::tc::NlOptions::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
+impl core::hash::Hash for aya::programs::tc::NlOptions
+pub fn aya::programs::tc::NlOptions::hash<__H: core::hash::Hasher>(&self, state: &mut __H)
+impl core::marker::StructuralPartialEq for aya::programs::tc::NlOptions
+impl core::marker::Freeze for aya::programs::tc::NlOptions
+impl core::marker::Send for aya::programs::tc::NlOptions
+impl core::marker::Sync for aya::programs::tc::NlOptions
+impl core::marker::Unpin for aya::programs::tc::NlOptions
+impl core::panic::unwind_safe::RefUnwindSafe for aya::programs::tc::NlOptions
+impl core::panic::unwind_safe::UnwindSafe for aya::programs::tc::NlOptions
+impl<Q, K> equivalent::Equivalent<K> for aya::programs::tc::NlOptions where Q: core::cmp::Eq + core::marker::Sized, K: core::borrow::Borrow<Q> + core::marker::Sized
+pub fn aya::programs::tc::NlOptions::equivalent(&self, key: &K) -> bool
+impl<T, U> core::convert::Into<U> for aya::programs::tc::NlOptions where U: core::convert::From<T>
+pub fn aya::programs::tc::NlOptions::into(self) -> U
+impl<T, U> core::convert::TryFrom<U> for aya::programs::tc::NlOptions where U: core::convert::Into<T>
+pub type aya::programs::tc::NlOptions::Error = core::convert::Infallible
+pub fn aya::programs::tc::NlOptions::try_from(value: U) -> core::result::Result<T, <T as core::convert::TryFrom<U>>::Error>
+impl<T, U> core::convert::TryInto<U> for aya::programs::tc::NlOptions where U: core::convert::TryFrom<T>
+pub type aya::programs::tc::NlOptions::Error = <U as core::convert::TryFrom<T>>::Error
+pub fn aya::programs::tc::NlOptions::try_into(self) -> core::result::Result<U, <U as core::convert::TryFrom<T>>::Error>
+impl<T> core::any::Any for aya::programs::tc::NlOptions where T: 'static + core::marker::Sized
+pub fn aya::programs::tc::NlOptions::type_id(&self) -> core::any::TypeId
+impl<T> core::borrow::Borrow<T> for aya::programs::tc::NlOptions where T: core::marker::Sized
+pub fn aya::programs::tc::NlOptions::borrow(&self) -> &T
+impl<T> core::borrow::BorrowMut<T> for aya::programs::tc::NlOptions where T: core::marker::Sized
+pub fn aya::programs::tc::NlOptions::borrow_mut(&mut self) -> &mut T
+impl<T> core::convert::From<T> for aya::programs::tc::NlOptions
+pub fn aya::programs::tc::NlOptions::from(t: T) -> T
pub struct aya::programs::tc::SchedClassifier
impl aya::programs::tc::SchedClassifier
pub fn aya::programs::tc::SchedClassifier::attach(&mut self, interface: &str, attach_type: aya::programs::tc::TcAttachType) -> core::result::Result<aya::programs::tc::SchedClassifierLinkId, aya::programs::ProgramError>
pub fn aya::programs::tc::SchedClassifier::attach_to_link(&mut self, link: aya::programs::tc::SchedClassifierLink) -> core::result::Result<aya::programs::tc::SchedClassifierLinkId, aya::programs::ProgramError>
-pub fn aya::programs::tc::SchedClassifier::attach_with_options(&mut self, interface: &str, attach_type: aya::programs::tc::TcAttachType, options: aya::programs::tc::TcOptions) -> core::result::Result<aya::programs::tc::SchedClassifierLinkId, aya::programs::ProgramError>
+pub fn aya::programs::tc::SchedClassifier::attach_with_options(&mut self, interface: &str, attach_type: aya::programs::tc::TcAttachType, options: aya::programs::tc::TcAttachOptions) -> core::result::Result<aya::programs::tc::SchedClassifierLinkId, aya::programs::ProgramError>
pub fn aya::programs::tc::SchedClassifier::detach(&mut self, link_id: aya::programs::tc::SchedClassifierLinkId) -> core::result::Result<(), aya::programs::ProgramError>
pub fn aya::programs::tc::SchedClassifier::from_pin<P: core::convert::AsRef<std::path::Path>>(path: P) -> core::result::Result<Self, aya::programs::ProgramError>
pub fn aya::programs::tc::SchedClassifier::load(&mut self) -> core::result::Result<(), aya::programs::ProgramError>
+pub fn aya::programs::tc::SchedClassifier::query_tcx(interface: &str, attach_type: aya::programs::tc::TcAttachType) -> core::result::Result<(u64, alloc::vec::Vec<aya::programs::ProgramInfo>), aya::programs::ProgramError>
pub fn aya::programs::tc::SchedClassifier::take_link(&mut self, link_id: aya::programs::tc::SchedClassifierLinkId) -> core::result::Result<aya::programs::tc::SchedClassifierLink, aya::programs::ProgramError>
impl aya::programs::tc::SchedClassifier
pub fn aya::programs::tc::SchedClassifier::fd(&self) -> core::result::Result<&aya::programs::ProgramFd, aya::programs::ProgramError>
diff --git a/xtask/public-api/aya.txt b/xtask/public-api/aya.txt
--- a/xtask/public-api/aya.txt
+++ b/xtask/public-api/aya.txt
@@ -5603,6 +5715,8 @@ pub fn aya::programs::tc::SchedClassifier::pin<P: core::convert::AsRef<std::path
pub fn aya::programs::tc::SchedClassifier::unpin(self) -> core::result::Result<(), std::io::error::Error>
impl aya::programs::tc::SchedClassifier
pub fn aya::programs::tc::SchedClassifier::unload(&mut self) -> core::result::Result<(), aya::programs::ProgramError>
+impl aya::programs::MultiProgram for aya::programs::tc::SchedClassifier
+pub fn aya::programs::tc::SchedClassifier::fd(&self) -> core::result::Result<std::os::fd::owned::BorrowedFd<'_>, aya::programs::ProgramError>
impl core::fmt::Debug for aya::programs::tc::SchedClassifier
pub fn aya::programs::tc::SchedClassifier::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
impl core::ops::drop::Drop for aya::programs::tc::SchedClassifier
diff --git a/xtask/public-api/aya.txt b/xtask/public-api/aya.txt
--- a/xtask/public-api/aya.txt
+++ b/xtask/public-api/aya.txt
@@ -5637,18 +5751,29 @@ impl<T> core::convert::From<T> for aya::programs::tc::SchedClassifier
pub fn aya::programs::tc::SchedClassifier::from(t: T) -> T
pub struct aya::programs::tc::SchedClassifierLink(_)
impl aya::programs::tc::SchedClassifierLink
-pub fn aya::programs::tc::SchedClassifierLink::attach_type(&self) -> aya::programs::tc::TcAttachType
+pub fn aya::programs::tc::SchedClassifierLink::attach_type(&self) -> core::result::Result<aya::programs::tc::TcAttachType, aya::programs::ProgramError>
pub fn aya::programs::tc::SchedClassifierLink::attached(if_name: &str, attach_type: aya::programs::tc::TcAttachType, priority: u16, handle: u32) -> core::result::Result<Self, std::io::error::Error>
-pub fn aya::programs::tc::SchedClassifierLink::handle(&self) -> u32
-pub fn aya::programs::tc::SchedClassifierLink::priority(&self) -> u16
+pub fn aya::programs::tc::SchedClassifierLink::handle(&self) -> core::result::Result<u32, aya::programs::ProgramError>
+pub fn aya::programs::tc::SchedClassifierLink::priority(&self) -> core::result::Result<u16, aya::programs::ProgramError>
+impl aya::programs::MultiProgLink for aya::programs::tc::SchedClassifierLink
+pub fn aya::programs::tc::SchedClassifierLink::fd(&self) -> core::result::Result<std::os::fd::owned::BorrowedFd<'_>, aya::programs::links::LinkError>
impl aya::programs::links::Link for aya::programs::tc::SchedClassifierLink
pub type aya::programs::tc::SchedClassifierLink::Id = aya::programs::tc::SchedClassifierLinkId
pub fn aya::programs::tc::SchedClassifierLink::detach(self) -> core::result::Result<(), aya::programs::ProgramError>
pub fn aya::programs::tc::SchedClassifierLink::id(&self) -> Self::Id
+impl core::convert::TryFrom<aya::programs::links::FdLink> for aya::programs::tc::SchedClassifierLink
+pub type aya::programs::tc::SchedClassifierLink::Error = aya::programs::links::LinkError
+pub fn aya::programs::tc::SchedClassifierLink::try_from(fd_link: aya::programs::links::FdLink) -> core::result::Result<Self, Self::Error>
+impl core::convert::TryFrom<aya::programs::tc::SchedClassifierLink> for aya::programs::links::FdLink
+pub type aya::programs::links::FdLink::Error = aya::programs::links::LinkError
+pub fn aya::programs::links::FdLink::try_from(value: aya::programs::tc::SchedClassifierLink) -> core::result::Result<Self, Self::Error>
impl core::fmt::Debug for aya::programs::tc::SchedClassifierLink
pub fn aya::programs::tc::SchedClassifierLink::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
impl core::ops::drop::Drop for aya::programs::tc::SchedClassifierLink
pub fn aya::programs::tc::SchedClassifierLink::drop(&mut self)
+impl<'a> core::convert::TryFrom<&'a aya::programs::tc::SchedClassifierLink> for &'a aya::programs::links::FdLink
+pub type &'a aya::programs::links::FdLink::Error = aya::programs::links::LinkError
+pub fn &'a aya::programs::links::FdLink::try_from(value: &'a aya::programs::tc::SchedClassifierLink) -> core::result::Result<Self, Self::Error>
impl core::marker::Freeze for aya::programs::tc::SchedClassifierLink
impl core::marker::Send for aya::programs::tc::SchedClassifierLink
impl core::marker::Sync for aya::programs::tc::SchedClassifierLink
diff --git a/xtask/public-api/aya.txt b/xtask/public-api/aya.txt
--- a/xtask/public-api/aya.txt
+++ b/xtask/public-api/aya.txt
@@ -5704,33 +5829,6 @@ impl<T> core::borrow::BorrowMut<T> for aya::programs::tc::SchedClassifierLinkId
pub fn aya::programs::tc::SchedClassifierLinkId::borrow_mut(&mut self) -> &mut T
impl<T> core::convert::From<T> for aya::programs::tc::SchedClassifierLinkId
pub fn aya::programs::tc::SchedClassifierLinkId::from(t: T) -> T
-pub struct aya::programs::tc::TcOptions
-pub aya::programs::tc::TcOptions::handle: u32
-pub aya::programs::tc::TcOptions::priority: u16
-impl core::default::Default for aya::programs::tc::TcOptions
-pub fn aya::programs::tc::TcOptions::default() -> aya::programs::tc::TcOptions
-impl core::marker::Freeze for aya::programs::tc::TcOptions
-impl core::marker::Send for aya::programs::tc::TcOptions
-impl core::marker::Sync for aya::programs::tc::TcOptions
-impl core::marker::Unpin for aya::programs::tc::TcOptions
-impl core::panic::unwind_safe::RefUnwindSafe for aya::programs::tc::TcOptions
-impl core::panic::unwind_safe::UnwindSafe for aya::programs::tc::TcOptions
-impl<T, U> core::convert::Into<U> for aya::programs::tc::TcOptions where U: core::convert::From<T>
-pub fn aya::programs::tc::TcOptions::into(self) -> U
-impl<T, U> core::convert::TryFrom<U> for aya::programs::tc::TcOptions where U: core::convert::Into<T>
-pub type aya::programs::tc::TcOptions::Error = core::convert::Infallible
-pub fn aya::programs::tc::TcOptions::try_from(value: U) -> core::result::Result<T, <T as core::convert::TryFrom<U>>::Error>
-impl<T, U> core::convert::TryInto<U> for aya::programs::tc::TcOptions where U: core::convert::TryFrom<T>
-pub type aya::programs::tc::TcOptions::Error = <U as core::convert::TryFrom<T>>::Error
-pub fn aya::programs::tc::TcOptions::try_into(self) -> core::result::Result<U, <U as core::convert::TryFrom<T>>::Error>
-impl<T> core::any::Any for aya::programs::tc::TcOptions where T: 'static + core::marker::Sized
-pub fn aya::programs::tc::TcOptions::type_id(&self) -> core::any::TypeId
-impl<T> core::borrow::Borrow<T> for aya::programs::tc::TcOptions where T: core::marker::Sized
-pub fn aya::programs::tc::TcOptions::borrow(&self) -> &T
-impl<T> core::borrow::BorrowMut<T> for aya::programs::tc::TcOptions where T: core::marker::Sized
-pub fn aya::programs::tc::TcOptions::borrow_mut(&mut self) -> &mut T
-impl<T> core::convert::From<T> for aya::programs::tc::TcOptions
-pub fn aya::programs::tc::TcOptions::from(t: T) -> T
pub fn aya::programs::tc::qdisc_add_clsact(if_name: &str) -> core::result::Result<(), std::io::error::Error>
pub fn aya::programs::tc::qdisc_detach_program(if_name: &str, attach_type: aya::programs::tc::TcAttachType, name: &str) -> core::result::Result<(), std::io::error::Error>
pub mod aya::programs::tp_btf
diff --git a/xtask/public-api/aya.txt b/xtask/public-api/aya.txt
--- a/xtask/public-api/aya.txt
+++ b/xtask/public-api/aya.txt
@@ -7208,6 +7306,8 @@ impl<T> core::convert::From<T> for aya::programs::tc::TcAttachType
pub fn aya::programs::tc::TcAttachType::from(t: T) -> T
pub enum aya::programs::TcError
pub aya::programs::TcError::AlreadyAttached
+pub aya::programs::TcError::InvalidLinkOperation
+pub aya::programs::TcError::InvalidTcxAttach(u32)
pub aya::programs::TcError::NetlinkError
pub aya::programs::TcError::NetlinkError::io_error: std::io::error::Error
impl core::convert::From<aya::programs::tc::TcError> for aya::programs::ProgramError
diff --git a/xtask/public-api/aya.txt b/xtask/public-api/aya.txt
--- a/xtask/public-api/aya.txt
+++ b/xtask/public-api/aya.txt
@@ -7894,6 +7994,42 @@ impl<T> core::borrow::BorrowMut<T> for aya::programs::kprobe::KProbe where T: co
pub fn aya::programs::kprobe::KProbe::borrow_mut(&mut self) -> &mut T
impl<T> core::convert::From<T> for aya::programs::kprobe::KProbe
pub fn aya::programs::kprobe::KProbe::from(t: T) -> T
+pub struct aya::programs::LinkOrder
+impl aya::programs::links::LinkOrder
+pub fn aya::programs::links::LinkOrder::after_link<L: aya::programs::MultiProgLink>(link: &L) -> core::result::Result<Self, aya::programs::links::LinkError>
+pub fn aya::programs::links::LinkOrder::after_program<P: aya::programs::MultiProgram>(program: &P) -> core::result::Result<Self, aya::programs::ProgramError>
+pub fn aya::programs::links::LinkOrder::after_program_id(id: aya::programs::ProgramId) -> Self
+pub fn aya::programs::links::LinkOrder::before_link<L: aya::programs::MultiProgLink>(link: &L) -> core::result::Result<Self, aya::programs::links::LinkError>
+pub fn aya::programs::links::LinkOrder::before_program<P: aya::programs::MultiProgram>(program: &P) -> core::result::Result<Self, aya::programs::ProgramError>
+pub fn aya::programs::links::LinkOrder::before_program_id(id: aya::programs::ProgramId) -> Self
+pub fn aya::programs::links::LinkOrder::first() -> Self
+pub fn aya::programs::links::LinkOrder::last() -> Self
+impl core::default::Default for aya::programs::links::LinkOrder
+pub fn aya::programs::links::LinkOrder::default() -> Self
+impl core::fmt::Debug for aya::programs::links::LinkOrder
+pub fn aya::programs::links::LinkOrder::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
+impl core::marker::Freeze for aya::programs::links::LinkOrder
+impl core::marker::Send for aya::programs::links::LinkOrder
+impl core::marker::Sync for aya::programs::links::LinkOrder
+impl core::marker::Unpin for aya::programs::links::LinkOrder
+impl core::panic::unwind_safe::RefUnwindSafe for aya::programs::links::LinkOrder
+impl core::panic::unwind_safe::UnwindSafe for aya::programs::links::LinkOrder
+impl<T, U> core::convert::Into<U> for aya::programs::links::LinkOrder where U: core::convert::From<T>
+pub fn aya::programs::links::LinkOrder::into(self) -> U
+impl<T, U> core::convert::TryFrom<U> for aya::programs::links::LinkOrder where U: core::convert::Into<T>
+pub type aya::programs::links::LinkOrder::Error = core::convert::Infallible
+pub fn aya::programs::links::LinkOrder::try_from(value: U) -> core::result::Result<T, <T as core::convert::TryFrom<U>>::Error>
+impl<T, U> core::convert::TryInto<U> for aya::programs::links::LinkOrder where U: core::convert::TryFrom<T>
+pub type aya::programs::links::LinkOrder::Error = <U as core::convert::TryFrom<T>>::Error
+pub fn aya::programs::links::LinkOrder::try_into(self) -> core::result::Result<U, <U as core::convert::TryFrom<T>>::Error>
+impl<T> core::any::Any for aya::programs::links::LinkOrder where T: 'static + core::marker::Sized
+pub fn aya::programs::links::LinkOrder::type_id(&self) -> core::any::TypeId
+impl<T> core::borrow::Borrow<T> for aya::programs::links::LinkOrder where T: core::marker::Sized
+pub fn aya::programs::links::LinkOrder::borrow(&self) -> &T
+impl<T> core::borrow::BorrowMut<T> for aya::programs::links::LinkOrder where T: core::marker::Sized
+pub fn aya::programs::links::LinkOrder::borrow_mut(&mut self) -> &mut T
+impl<T> core::convert::From<T> for aya::programs::links::LinkOrder
+pub fn aya::programs::links::LinkOrder::from(t: T) -> T
pub struct aya::programs::LircMode2
impl aya::programs::lirc_mode2::LircMode2
pub fn aya::programs::lirc_mode2::LircMode2::attach<T: std::os::fd::owned::AsFd>(&mut self, lircdev: T) -> core::result::Result<aya::programs::lirc_mode2::LircLinkId, aya::programs::ProgramError>
diff --git a/xtask/public-api/aya.txt b/xtask/public-api/aya.txt
--- a/xtask/public-api/aya.txt
+++ b/xtask/public-api/aya.txt
@@ -8071,6 +8207,31 @@ impl<T> core::borrow::BorrowMut<T> for aya::programs::ProgramFd where T: core::m
pub fn aya::programs::ProgramFd::borrow_mut(&mut self) -> &mut T
impl<T> core::convert::From<T> for aya::programs::ProgramFd
pub fn aya::programs::ProgramFd::from(t: T) -> T
+pub struct aya::programs::ProgramId(_)
+impl aya::programs::ProgramId
+pub unsafe fn aya::programs::ProgramId::new(id: u32) -> Self
+impl core::marker::Freeze for aya::programs::ProgramId
+impl core::marker::Send for aya::programs::ProgramId
+impl core::marker::Sync for aya::programs::ProgramId
+impl core::marker::Unpin for aya::programs::ProgramId
+impl core::panic::unwind_safe::RefUnwindSafe for aya::programs::ProgramId
+impl core::panic::unwind_safe::UnwindSafe for aya::programs::ProgramId
+impl<T, U> core::convert::Into<U> for aya::programs::ProgramId where U: core::convert::From<T>
+pub fn aya::programs::ProgramId::into(self) -> U
+impl<T, U> core::convert::TryFrom<U> for aya::programs::ProgramId where U: core::convert::Into<T>
+pub type aya::programs::ProgramId::Error = core::convert::Infallible
+pub fn aya::programs::ProgramId::try_from(value: U) -> core::result::Result<T, <T as core::convert::TryFrom<U>>::Error>
+impl<T, U> core::convert::TryInto<U> for aya::programs::ProgramId where U: core::convert::TryFrom<T>
+pub type aya::programs::ProgramId::Error = <U as core::convert::TryFrom<T>>::Error
+pub fn aya::programs::ProgramId::try_into(self) -> core::result::Result<U, <U as core::convert::TryFrom<T>>::Error>
+impl<T> core::any::Any for aya::programs::ProgramId where T: 'static + core::marker::Sized
+pub fn aya::programs::ProgramId::type_id(&self) -> core::any::TypeId
+impl<T> core::borrow::Borrow<T> for aya::programs::ProgramId where T: core::marker::Sized
+pub fn aya::programs::ProgramId::borrow(&self) -> &T
+impl<T> core::borrow::BorrowMut<T> for aya::programs::ProgramId where T: core::marker::Sized
+pub fn aya::programs::ProgramId::borrow_mut(&mut self) -> &mut T
+impl<T> core::convert::From<T> for aya::programs::ProgramId
+pub fn aya::programs::ProgramId::from(t: T) -> T
pub struct aya::programs::ProgramInfo(_)
impl aya::programs::ProgramInfo
pub fn aya::programs::ProgramInfo::btf_id(&self) -> core::option::Option<u32>
diff --git a/xtask/public-api/aya.txt b/xtask/public-api/aya.txt
--- a/xtask/public-api/aya.txt
+++ b/xtask/public-api/aya.txt
@@ -8168,10 +8329,11 @@ pub struct aya::programs::SchedClassifier
impl aya::programs::tc::SchedClassifier
pub fn aya::programs::tc::SchedClassifier::attach(&mut self, interface: &str, attach_type: aya::programs::tc::TcAttachType) -> core::result::Result<aya::programs::tc::SchedClassifierLinkId, aya::programs::ProgramError>
pub fn aya::programs::tc::SchedClassifier::attach_to_link(&mut self, link: aya::programs::tc::SchedClassifierLink) -> core::result::Result<aya::programs::tc::SchedClassifierLinkId, aya::programs::ProgramError>
-pub fn aya::programs::tc::SchedClassifier::attach_with_options(&mut self, interface: &str, attach_type: aya::programs::tc::TcAttachType, options: aya::programs::tc::TcOptions) -> core::result::Result<aya::programs::tc::SchedClassifierLinkId, aya::programs::ProgramError>
+pub fn aya::programs::tc::SchedClassifier::attach_with_options(&mut self, interface: &str, attach_type: aya::programs::tc::TcAttachType, options: aya::programs::tc::TcAttachOptions) -> core::result::Result<aya::programs::tc::SchedClassifierLinkId, aya::programs::ProgramError>
pub fn aya::programs::tc::SchedClassifier::detach(&mut self, link_id: aya::programs::tc::SchedClassifierLinkId) -> core::result::Result<(), aya::programs::ProgramError>
pub fn aya::programs::tc::SchedClassifier::from_pin<P: core::convert::AsRef<std::path::Path>>(path: P) -> core::result::Result<Self, aya::programs::ProgramError>
pub fn aya::programs::tc::SchedClassifier::load(&mut self) -> core::result::Result<(), aya::programs::ProgramError>
+pub fn aya::programs::tc::SchedClassifier::query_tcx(interface: &str, attach_type: aya::programs::tc::TcAttachType) -> core::result::Result<(u64, alloc::vec::Vec<aya::programs::ProgramInfo>), aya::programs::ProgramError>
pub fn aya::programs::tc::SchedClassifier::take_link(&mut self, link_id: aya::programs::tc::SchedClassifierLinkId) -> core::result::Result<aya::programs::tc::SchedClassifierLink, aya::programs::ProgramError>
impl aya::programs::tc::SchedClassifier
pub fn aya::programs::tc::SchedClassifier::fd(&self) -> core::result::Result<&aya::programs::ProgramFd, aya::programs::ProgramError>
diff --git a/xtask/public-api/aya.txt b/xtask/public-api/aya.txt
--- a/xtask/public-api/aya.txt
+++ b/xtask/public-api/aya.txt
@@ -8182,6 +8344,8 @@ pub fn aya::programs::tc::SchedClassifier::pin<P: core::convert::AsRef<std::path
pub fn aya::programs::tc::SchedClassifier::unpin(self) -> core::result::Result<(), std::io::error::Error>
impl aya::programs::tc::SchedClassifier
pub fn aya::programs::tc::SchedClassifier::unload(&mut self) -> core::result::Result<(), aya::programs::ProgramError>
+impl aya::programs::MultiProgram for aya::programs::tc::SchedClassifier
+pub fn aya::programs::tc::SchedClassifier::fd(&self) -> core::result::Result<std::os::fd::owned::BorrowedFd<'_>, aya::programs::ProgramError>
impl core::fmt::Debug for aya::programs::tc::SchedClassifier
pub fn aya::programs::tc::SchedClassifier::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
impl core::ops::drop::Drop for aya::programs::tc::SchedClassifier
diff --git a/xtask/public-api/aya.txt b/xtask/public-api/aya.txt
--- a/xtask/public-api/aya.txt
+++ b/xtask/public-api/aya.txt
@@ -8831,6 +8995,14 @@ impl aya::programs::links::Link for aya::programs::xdp::XdpLink
pub type aya::programs::xdp::XdpLink::Id = aya::programs::xdp::XdpLinkId
pub fn aya::programs::xdp::XdpLink::detach(self) -> core::result::Result<(), aya::programs::ProgramError>
pub fn aya::programs::xdp::XdpLink::id(&self) -> Self::Id
+pub trait aya::programs::MultiProgLink
+pub fn aya::programs::MultiProgLink::fd(&self) -> core::result::Result<std::os::fd::owned::BorrowedFd<'_>, aya::programs::links::LinkError>
+impl aya::programs::MultiProgLink for aya::programs::tc::SchedClassifierLink
+pub fn aya::programs::tc::SchedClassifierLink::fd(&self) -> core::result::Result<std::os::fd::owned::BorrowedFd<'_>, aya::programs::links::LinkError>
+pub trait aya::programs::MultiProgram
+pub fn aya::programs::MultiProgram::fd(&self) -> core::result::Result<std::os::fd::owned::BorrowedFd<'_>, aya::programs::ProgramError>
+impl aya::programs::MultiProgram for aya::programs::tc::SchedClassifier
+pub fn aya::programs::tc::SchedClassifier::fd(&self) -> core::result::Result<std::os::fd::owned::BorrowedFd<'_>, aya::programs::ProgramError>
pub fn aya::programs::loaded_programs() -> impl core::iter::traits::iterator::Iterator<Item = core::result::Result<aya::programs::ProgramInfo, aya::programs::ProgramError>>
pub mod aya::sys
#[non_exhaustive] pub enum aya::sys::Stats
|
diff --git a/aya/src/programs/links.rs b/aya/src/programs/links.rs
--- a/aya/src/programs/links.rs
+++ b/aya/src/programs/links.rs
@@ -394,6 +397,125 @@ pub enum LinkError {
SyscallError(#[from] SyscallError),
}
+#[derive(Debug)]
+pub(crate) enum LinkRef {
+ Id(u32),
+ Fd(RawFd),
+}
+
+bitflags::bitflags! {
+ /// Flags which are use to build a set of MprogOptions.
+ #[derive(Clone, Copy, Debug, Default)]
+ pub(crate) struct MprogFlags: u32 {
+ const REPLACE = BPF_F_REPLACE;
+ const BEFORE = BPF_F_BEFORE;
+ const AFTER = BPF_F_AFTER;
+ const ID = BPF_F_ID;
+ const LINK = BPF_F_LINK;
+ }
+}
+
+/// Arguments required for interacting with the kernel's multi-prog API.
+///
+/// # Minimum kernel version
+///
+/// The minimum kernel version required to use this feature is 6.6.0.
+///
+/// # Example
+///
+/// ```no_run
+/// # let mut bpf = aya::Ebpf::load(&[])?;
+/// use aya::programs::{tc, SchedClassifier, TcAttachType, tc::TcAttachOptions, LinkOrder};
+///
+/// let prog: &mut SchedClassifier = bpf.program_mut("redirect_ingress").unwrap().try_into()?;
+/// prog.load()?;
+/// let options = TcAttachOptions::TcxOrder(LinkOrder::first());
+/// prog.attach_with_options("eth0", TcAttachType::Ingress, options)?;
+///
+/// # Ok::<(), aya::EbpfError>(())
+/// ```
+#[derive(Debug)]
+pub struct LinkOrder {
+ pub(crate) link_ref: LinkRef,
+ pub(crate) flags: MprogFlags,
+}
+
+/// Ensure that default link ordering is to be attached last.
+impl Default for LinkOrder {
+ fn default() -> Self {
+ Self {
+ link_ref: LinkRef::Fd(0),
+ flags: MprogFlags::AFTER,
+ }
+ }
+}
+
+impl LinkOrder {
+ /// Attach before all other links.
+ pub fn first() -> Self {
+ Self {
+ link_ref: LinkRef::Id(0),
+ flags: MprogFlags::BEFORE,
+ }
+ }
+
+ /// Attach after all other links.
+ pub fn last() -> Self {
+ Self {
+ link_ref: LinkRef::Id(0),
+ flags: MprogFlags::AFTER,
+ }
+ }
+
+ /// Attach before the given link.
+ pub fn before_link<L: MultiProgLink>(link: &L) -> Result<Self, LinkError> {
+ Ok(Self {
+ link_ref: LinkRef::Fd(link.fd()?.as_raw_fd()),
+ flags: MprogFlags::BEFORE | MprogFlags::LINK,
+ })
+ }
+
+ /// Attach after the given link.
+ pub fn after_link<L: MultiProgLink>(link: &L) -> Result<Self, LinkError> {
+ Ok(Self {
+ link_ref: LinkRef::Fd(link.fd()?.as_raw_fd()),
+ flags: MprogFlags::AFTER | MprogFlags::LINK,
+ })
+ }
+
+ /// Attach before the given program.
+ pub fn before_program<P: MultiProgram>(program: &P) -> Result<Self, ProgramError> {
+ Ok(Self {
+ link_ref: LinkRef::Fd(program.fd()?.as_raw_fd()),
+ flags: MprogFlags::BEFORE,
+ })
+ }
+
+ /// Attach after the given program.
+ pub fn after_program<P: MultiProgram>(program: &P) -> Result<Self, ProgramError> {
+ Ok(Self {
+ link_ref: LinkRef::Fd(program.fd()?.as_raw_fd()),
+ flags: MprogFlags::AFTER,
+ })
+ }
+
+ /// Attach before the program with the given id.
+ pub fn before_program_id(id: ProgramId) -> Self {
+ Self {
+ link_ref: LinkRef::Id(id.0),
+ flags: MprogFlags::BEFORE | MprogFlags::ID,
+ }
+ }
+
+ /// Attach after the program with the given id.
+ pub fn after_program_id(id: ProgramId) -> Self {
+ Self {
+ link_ref: LinkRef::Id(id.0),
+ flags: MprogFlags::AFTER | MprogFlags::ID,
+ }
+ }
+}
+
#[cfg(test)]
mod tests {
use std::{cell::RefCell, fs::File, rc::Rc};
diff --git a/test/integration-ebpf/Cargo.toml b/test/integration-ebpf/Cargo.toml
--- a/test/integration-ebpf/Cargo.toml
+++ b/test/integration-ebpf/Cargo.toml
@@ -37,6 +37,10 @@ path = "src/pass.rs"
name = "test"
path = "src/test.rs"
+[[bin]]
+name = "tcx"
+path = "src/tcx.rs"
+
[[bin]]
name = "relocations"
path = "src/relocations.rs"
diff --git /dev/null b/test/integration-ebpf/src/tcx.rs
new file mode 100644
--- /dev/null
+++ b/test/integration-ebpf/src/tcx.rs
@@ -0,0 +1,15 @@
+#![no_std]
+#![no_main]
+
+use aya_ebpf::{bindings::tcx_action_base::TCX_NEXT, macros::classifier, programs::TcContext};
+
+#[classifier]
+pub fn tcx_next(_ctx: TcContext) -> i32 {
+ TCX_NEXT
+}
+
+#[cfg(not(test))]
+#[panic_handler]
+fn panic(_info: &core::panic::PanicInfo) -> ! {
+ loop {}
+}
diff --git a/test/integration-test/src/lib.rs b/test/integration-test/src/lib.rs
--- a/test/integration-test/src/lib.rs
+++ b/test/integration-test/src/lib.rs
@@ -14,6 +14,7 @@ pub const LOG: &[u8] = include_bytes_aligned!(concat!(env!("OUT_DIR"), "/log"));
pub const MAP_TEST: &[u8] = include_bytes_aligned!(concat!(env!("OUT_DIR"), "/map_test"));
pub const NAME_TEST: &[u8] = include_bytes_aligned!(concat!(env!("OUT_DIR"), "/name_test"));
pub const PASS: &[u8] = include_bytes_aligned!(concat!(env!("OUT_DIR"), "/pass"));
+pub const TCX: &[u8] = include_bytes_aligned!(concat!(env!("OUT_DIR"), "/tcx"));
pub const TEST: &[u8] = include_bytes_aligned!(concat!(env!("OUT_DIR"), "/test"));
pub const RELOCATIONS: &[u8] = include_bytes_aligned!(concat!(env!("OUT_DIR"), "/relocations"));
pub const TWO_PROGS: &[u8] = include_bytes_aligned!(concat!(env!("OUT_DIR"), "/two_progs"));
diff --git a/test/integration-test/src/tests.rs b/test/integration-test/src/tests.rs
--- a/test/integration-test/src/tests.rs
+++ b/test/integration-test/src/tests.rs
@@ -8,4 +8,5 @@ mod rbpf;
mod relocations;
mod ring_buf;
mod smoke;
+mod tcx;
mod xdp;
diff --git /dev/null b/test/integration-test/src/tests/tcx.rs
new file mode 100644
--- /dev/null
+++ b/test/integration-test/src/tests/tcx.rs
@@ -0,0 +1,102 @@
+use aya::{
+ programs::{tc::TcAttachOptions, LinkOrder, ProgramId, SchedClassifier, TcAttachType},
+ util::KernelVersion,
+ Ebpf,
+};
+use test_log::test;
+
+use crate::utils::NetNsGuard;
+
+#[test]
+fn tcx() {
+ let kernel_version = KernelVersion::current().unwrap();
+ if kernel_version < KernelVersion::new(6, 6, 0) {
+ eprintln!("skipping tcx_attach test on kernel {kernel_version:?}");
+ return;
+ }
+
+ let _netns = NetNsGuard::new();
+
+ // We need a dedicated `Ebpf` instance for each program that we load
+ // since TCX does not allow the same program ID to be attached multiple
+ // times to the same interface/direction.
+ //
+ // Variables declared within this macro are within a closure scope to avoid
+ // variable name conflicts.
+ //
+ // Yields a tuple of the `Ebpf` which must remain in scope for the duration
+ // of the test, and the link ID of the attached program.
+ macro_rules! attach_program_with_link_order_inner {
+ ($program_name:ident, $link_order:expr) => {
+ let mut ebpf = Ebpf::load(crate::TCX).unwrap();
+ let $program_name: &mut SchedClassifier =
+ ebpf.program_mut("tcx_next").unwrap().try_into().unwrap();
+ $program_name.load().unwrap();
+ };
+ }
+ macro_rules! attach_program_with_link_order {
+ ($program_name:ident, $link_order:expr) => {
+ attach_program_with_link_order_inner!($program_name, $link_order);
+ $program_name
+ .attach_with_options(
+ "lo",
+ TcAttachType::Ingress,
+ TcAttachOptions::TcxOrder($link_order),
+ )
+ .unwrap();
+ };
+ ($program_name:ident, $link_id_name:ident, $link_order:expr) => {
+ attach_program_with_link_order_inner!($program_name, $link_order);
+ let $link_id_name = $program_name
+ .attach_with_options(
+ "lo",
+ TcAttachType::Ingress,
+ TcAttachOptions::TcxOrder($link_order),
+ )
+ .unwrap();
+ };
+ }
+
+ attach_program_with_link_order!(default, LinkOrder::default());
+ attach_program_with_link_order!(first, LinkOrder::first());
+ attach_program_with_link_order!(last, last_link_id, LinkOrder::last());
+
+ let last_link = last.take_link(last_link_id).unwrap();
+
+ attach_program_with_link_order!(before_last, LinkOrder::before_link(&last_link).unwrap());
+ attach_program_with_link_order!(after_last, LinkOrder::after_link(&last_link).unwrap());
+
+ attach_program_with_link_order!(before_default, LinkOrder::before_program(default).unwrap());
+ attach_program_with_link_order!(after_default, LinkOrder::after_program(default).unwrap());
+
+ attach_program_with_link_order!(
+ before_first,
+ LinkOrder::before_program_id(unsafe { ProgramId::new(first.info().unwrap().id()) })
+ );
+ attach_program_with_link_order!(
+ after_first,
+ LinkOrder::after_program_id(unsafe { ProgramId::new(first.info().unwrap().id()) })
+ );
+
+ let expected_order = [
+ before_first,
+ first,
+ after_first,
+ before_default,
+ default,
+ after_default,
+ before_last,
+ last,
+ after_last,
+ ]
+ .iter()
+ .map(|program| program.info().unwrap().id())
+ .collect::<Vec<_>>();
+
+ let (revision, got_order) = SchedClassifier::query_tcx("lo", TcAttachType::Ingress).unwrap();
+ assert_eq!(revision, (expected_order.len() + 1) as u64);
+ assert_eq!(
+ got_order.iter().map(|p| p.id()).collect::<Vec<_>>(),
+ expected_order
+ );
+}
|
Add TCX link support
Following the recent addition of [link support for TC programs](https://lwn.net/Articles/938632/) we should add the necessary bits to support this in aya as well.
The [commit adding support to the cilium ebpf library](https://github.com/cilium/ebpf/commit/417f8a264d2e691649ede9b995fb334e6c58ca71) can sort of pave the way for us here
|
2024-04-05T15:21:29Z
|
1.5
|
2024-10-09T09:31:40Z
|
1d272f38bd19f64652ac8a278948f61e66164856
|
[
"bpf::tests::test_adjust_to_page_size",
"bpf::tests::test_max_entries_override",
"maps::bloom_filter::tests::test_contains_syscall_error",
"maps::bloom_filter::tests::test_contains_not_found",
"maps::bloom_filter::tests::test_insert_ok",
"maps::bloom_filter::tests::test_insert_syscall_error",
"maps::bloom_filter::tests::test_new_ok",
"maps::bloom_filter::tests::test_try_from_ok",
"maps::bloom_filter::tests::test_try_from_wrong_map",
"maps::bloom_filter::tests::test_wrong_value_size",
"maps::hash_map::hash_map::tests::test_get_not_found",
"maps::hash_map::hash_map::tests::test_get_syscall_error",
"maps::hash_map::hash_map::tests::test_insert_boxed_ok",
"maps::hash_map::hash_map::tests::test_insert_ok",
"maps::hash_map::hash_map::tests::test_insert_syscall_error",
"maps::hash_map::hash_map::tests::test_iter",
"maps::hash_map::hash_map::tests::test_iter_key_deleted",
"maps::hash_map::hash_map::tests::test_iter_key_error",
"maps::hash_map::hash_map::tests::test_iter_value_error",
"maps::hash_map::hash_map::tests::test_keys",
"maps::hash_map::hash_map::tests::test_keys_empty",
"maps::hash_map::hash_map::tests::test_keys_error",
"maps::hash_map::hash_map::tests::test_new_ok",
"maps::hash_map::hash_map::tests::test_remove_ok",
"maps::hash_map::hash_map::tests::test_remove_syscall_error",
"maps::hash_map::hash_map::tests::test_try_from_ok",
"maps::hash_map::hash_map::tests::test_try_from_ok_lru",
"maps::hash_map::hash_map::tests::test_try_from_wrong_map",
"maps::hash_map::hash_map::tests::test_try_from_wrong_map_values",
"maps::hash_map::hash_map::tests::test_wrong_key_size",
"maps::hash_map::hash_map::tests::test_wrong_value_size",
"maps::hash_map::per_cpu_hash_map::tests::test_try_from_ok",
"maps::hash_map::per_cpu_hash_map::tests::test_try_from_ok_lru",
"maps::lpm_trie::tests::test_get_not_found",
"maps::lpm_trie::tests::test_get_syscall_error",
"maps::lpm_trie::tests::test_insert_ok",
"maps::lpm_trie::tests::test_insert_syscall_error",
"maps::lpm_trie::tests::test_new_ok",
"maps::lpm_trie::tests::test_remove_ok",
"maps::lpm_trie::tests::test_remove_syscall_error",
"maps::lpm_trie::tests::test_try_from_ok",
"maps::lpm_trie::tests::test_try_from_wrong_map",
"maps::lpm_trie::tests::test_wrong_key_size",
"maps::lpm_trie::tests::test_wrong_value_size",
"maps::perf::perf_buffer::tests::test_invalid_page_count",
"maps::perf::perf_buffer::tests::test_no_events",
"maps::perf::perf_buffer::tests::test_no_out_bufs",
"maps::perf::perf_buffer::tests::test_read_first_lost",
"maps::perf::perf_buffer::tests::test_read_first_sample",
"maps::perf::perf_buffer::tests::test_read_last_sample",
"maps::perf::perf_buffer::tests::test_read_many_with_many_reads",
"maps::perf::perf_buffer::tests::test_read_many_with_one_read",
"maps::perf::perf_buffer::tests::test_read_wrapping_sample_size",
"maps::perf::perf_buffer::tests::test_read_wrapping_value",
"maps::tests::test_create",
"maps::tests::test_create_failed",
"maps::tests::test_from_map_id",
"maps::tests::test_loaded_maps",
"maps::tests::test_create_perf_event_array",
"programs::links::tests::test_already_attached",
"programs::links::tests::test_cgroup_attach_flag",
"maps::tests::test_name",
"programs::links::tests::test_drop_detach",
"programs::links::tests::test_link_map",
"programs::links::tests::test_not_attached",
"programs::links::tests::test_owned_detach",
"programs::uprobe::tests::test_absolute_path",
"programs::uprobe::tests::test_relative_path_with_parent",
"programs::uprobe::tests::test_relative_path_without_parent",
"programs::uprobe::tests::test_find_debug_path_success",
"programs::links::tests::test_pin",
"sys::bpf::tests::test_attach_with_attributes",
"programs::uprobe::tests::test_verify_build_ids_different",
"sys::bpf::tests::test_perf_link_supported",
"sys::bpf::tests::test_prog_id_supported",
"programs::uprobe::tests::test_verify_build_ids_same",
"sys::netlink::tests::test_nested_attrs",
"sys::netlink::tests::test_nlattr_iterator_empty",
"sys::netlink::tests::test_nlattr_iterator_many",
"sys::bpf::tests::test_prog_id_supported_reject_types - should panic",
"sys::netlink::tests::test_nlattr_iterator_nested",
"sys::netlink::tests::test_nlattr_iterator_one",
"util::tests::test_parse_kernel_version_string",
"util::tests::test_parse_kernel_symbols",
"util::tests::test_parse_online_cpus",
"programs::uprobe::test_resolve_attach_path",
"aya/src/bpf.rs - bpf::Ebpf::maps (line 952) - compile",
"aya/src/bpf.rs - bpf::Ebpf::load (line 896) - compile",
"aya/src/bpf.rs - bpf::Ebpf::load_file (line 874) - compile",
"aya/src/bpf.rs - bpf::EbpfLoader<'a>::load_file (line 362) - compile",
"aya/src/bpf.rs - bpf::EbpfLoader<'a>::set_global (line 254) - compile",
"aya/src/bpf.rs - bpf::EbpfLoader<'a>::set_global (line 261) - compile",
"aya/src/bpf.rs - bpf::EbpfLoader<'a>::btf (line 188) - compile",
"aya/src/bpf.rs - bpf::EbpfLoader<'a>::allow_unsupported_maps (line 213) - compile",
"aya/src/bpf.rs - bpf::EbpfLoader<'a>::extension (line 326) - compile",
"aya/src/bpf.rs - bpf::Ebpf::program_mut (line 1016) - compile",
"aya/src/bpf.rs - bpf::EbpfLoader<'a>::set_max_entries (line 304) - compile",
"aya/src/bpf.rs - bpf::Ebpf::programs (line 1032) - compile",
"aya/src/bpf.rs - bpf::Ebpf::maps_mut (line 969) - compile",
"aya/src/maps/mod.rs - maps::MapData::pin (line 720) - compile",
"aya/src/maps/lpm_trie.rs - maps::lpm_trie::Key<K>::new (line 82) - compile",
"aya/src/bpf.rs - bpf::Ebpf::program (line 999) - compile",
"aya/src/bpf.rs - bpf::EbpfLoader (line 118) - compile",
"aya/src/programs/extension.rs - programs::extension::Extension (line 37) - compile",
"aya/src/maps/hash_map/hash_map.rs - maps::hash_map::hash_map::HashMap (line 21) - compile",
"aya/src/bpf.rs - bpf::EbpfLoader<'a>::load (line 380) - compile",
"aya/src/maps/array/array.rs - maps::array::array::Array (line 23) - compile",
"aya/src/bpf.rs - bpf::EbpfLoader<'a>::set_global (line 277) - compile",
"aya/src/bpf.rs - bpf::EbpfLoader<'a>::verifier_log_level (line 344) - compile",
"aya/src/bpf.rs - bpf::EbpfLoader<'a>::map_pin_path (line 234) - compile",
"aya/src/maps/xdp/dev_map.rs - maps::xdp::dev_map::DevMap (line 29) - compile",
"aya/src/maps/ring_buf.rs - maps::ring_buf::RingBuf (line 57) - compile",
"aya/src/maps/bloom_filter.rs - maps::bloom_filter::BloomFilter (line 22) - compile",
"aya/src/sys/mod.rs - sys::enable_stats (line 183) - compile",
"aya/src/maps/xdp/xsk_map.rs - maps::xdp::xsk_map::XskMap (line 23) - compile",
"aya/src/maps/xdp/dev_map_hash.rs - maps::xdp::dev_map_hash::DevMapHash (line 29) - compile",
"aya/src/maps/lpm_trie.rs - maps::lpm_trie::LpmTrie (line 22) - compile",
"aya/src/maps/xdp/cpu_map.rs - maps::xdp::cpu_map::CpuMap (line 29) - compile",
"aya/src/programs/xdp.rs - programs::xdp::Xdp (line 73) - compile",
"aya/src/maps/stack.rs - maps::stack::Stack (line 21) - compile",
"aya/src/maps/hash_map/per_cpu_hash_map.rs - maps::hash_map::per_cpu_hash_map::PerCpuHashMap (line 28) - compile",
"aya/src/maps/lpm_trie.rs - maps::lpm_trie::Key (line 59) - compile",
"aya/src/programs/mod.rs - programs (line 16) - compile",
"aya/src/programs/sock_ops.rs - programs::sock_ops::SockOps (line 26) - compile",
"aya/src/maps/mod.rs - maps (line 20) - compile",
"aya/src/maps/queue.rs - maps::queue::Queue (line 21) - compile",
"aya/src/util.rs - util::syscall_prefix (line 276) - compile",
"aya/src/programs/trace_point.rs - programs::trace_point::TracePoint (line 43) - compile",
"aya/src/bpf.rs - bpf::Ebpf::programs_mut (line 1050) - compile",
"aya/src/maps/sock/sock_map.rs - maps::sock::sock_map::SockMap (line 28) - compile",
"aya/src/programs/cgroup_sock_addr.rs - programs::cgroup_sock_addr::CgroupSockAddr (line 32) - compile",
"aya/src/programs/cgroup_sockopt.rs - programs::cgroup_sockopt::CgroupSockopt (line 29) - compile",
"aya/src/maps/array/program_array.rs - maps::array::program_array::ProgramArray (line 25) - compile",
"aya/src/programs/kprobe.rs - programs::kprobe::KProbe (line 37) - compile",
"aya/src/programs/raw_trace_point.rs - programs::raw_trace_point::RawTracePoint (line 27) - compile",
"aya/src/maps/hash_map/per_cpu_hash_map.rs - maps::hash_map::per_cpu_hash_map::PerCpuHashMap<T,K,V>::insert (line 92) - compile",
"aya/src/maps/sock/sock_hash.rs - maps::sock::sock_hash::SockHash (line 31) - compile",
"aya/src/programs/cgroup_skb.rs - programs::cgroup_skb::CgroupSkb (line 33) - compile",
"aya/src/maps/mod.rs - maps::PerCpuValues (line 868) - compile",
"aya/src/programs/cgroup_sock.rs - programs::cgroup_sock::CgroupSock (line 31) - compile",
"aya/src/maps/array/per_cpu_array.rs - maps::array::per_cpu_array::PerCpuArray (line 23) - compile",
"aya/src/programs/tp_btf.rs - programs::tp_btf::BtfTracePoint (line 25) - compile",
"aya/src/programs/socket_filter.rs - programs::socket_filter::SocketFilter (line 38) - compile",
"aya/src/programs/cgroup_device.rs - programs::cgroup_device::CgroupDevice (line 28) - compile",
"aya/src/programs/sk_skb.rs - programs::sk_skb::SkSkb (line 39) - compile",
"aya/src/programs/fentry.rs - programs::fentry::FEntry (line 26) - compile",
"aya/src/programs/fexit.rs - programs::fexit::FExit (line 26) - compile",
"aya/src/maps/stack_trace.rs - maps::stack_trace::StackTraceMap (line 30) - compile",
"aya/src/programs/perf_event.rs - programs::perf_event::PerfEvent (line 91) - compile",
"aya/src/programs/lsm.rs - programs::lsm::Lsm (line 28) - compile",
"aya/src/maps/perf/perf_event_array.rs - maps::perf::perf_event_array::PerfEventArray (line 91) - compile",
"aya/src/programs/sk_lookup.rs - programs::sk_lookup::SkLookup (line 25) - compile",
"aya/src/maps/perf/async_perf_event_array.rs - maps::perf::async_perf_event_array::AsyncPerfEventArray (line 37) - compile",
"aya/src/programs/cgroup_sysctl.rs - programs::cgroup_sysctl::CgroupSysctl (line 26) - compile",
"aya/src/programs/lirc_mode2.rs - programs::lirc_mode2::LircMode2 (line 26) - compile",
"aya/src/programs/sk_msg.rs - programs::sk_msg::SkMsg (line 26) - compile",
"aya/src/maps/info.rs - maps::info::loaded_maps (line 141)",
"aya/src/programs/info.rs - programs::info::loaded_programs (line 257)",
"tests::btf_relocations::relocation_tests::_enum_signed_32_checked_variants_false_some_kernelversion_new_6_0_0_https_github_com_torvalds_linux_commit_6089fb3_0x7aaaaaaai32_as_u64_expects",
"tests::btf_relocations::relocation_tests::_enum_signed_32_checked_variants_true_some_kernelversion_new_6_0_0_https_github_com_torvalds_linux_commit_6089fb3_0x7bbbbbbbi32_as_u64_expects",
"tests::btf_relocations::relocation_tests::_enum_signed_32_false_some_kernelversion_new_6_0_0_https_github_com_torvalds_linux_commit_6089fb3_0x7aaaaaaai32_as_u64_expects",
"tests::btf_relocations::relocation_tests::_enum_signed_32_true_some_kernelversion_new_6_0_0_https_github_com_torvalds_linux_commit_6089fb3_0x7bbbbbbbi32_as_u64_expects",
"tests::btf_relocations::relocation_tests::_enum_signed_64_checked_variants_false_some_kernelversion_new_6_0_0_https_github_com_torvalds_linux_commit_6089fb3_0xaaaaaaabbbbbbbi64_as_u64_expects",
"tests::btf_relocations::relocation_tests::_enum_signed_64_checked_variants_true_some_kernelversion_new_6_0_0_https_github_com_torvalds_linux_commit_6089fb3_0xcccccccdddddddi64_as_u64_expects",
"tests::btf_relocations::relocation_tests::_enum_signed_64_false_some_kernelversion_new_6_0_0_https_github_com_torvalds_linux_commit_6089fb3_0xaaaaaaabbbbbbbbi64_as_u64_expects",
"tests::btf_relocations::relocation_tests::_enum_signed_64_true_some_kernelversion_new_6_0_0_https_github_com_torvalds_linux_commit_6089fb3_0xcccccccddddddddi64_as_u64_expects",
"tests::btf_relocations::relocation_tests::_enum_unsigned_64_checked_variants_false_some_kernelversion_new_6_0_0_https_github_com_torvalds_linux_commit_6089fb3_0xaaaaaaaabbbbbbbb_expects",
"tests::btf_relocations::relocation_tests::_enum_unsigned_64_checked_variants_true_some_kernelversion_new_6_0_0_https_github_com_torvalds_linux_commit_6089fb3_0xccccccccdddddddd_expects",
"tests::btf_relocations::relocation_tests::_enum_unsigned_64_false_some_kernelversion_new_6_0_0_https_github_com_torvalds_linux_commit_6089fb3_0xaaaaaaaabbbbbbbb_expects",
"tests::btf_relocations::relocation_tests::_enum_unsigned_64_true_some_kernelversion_new_6_0_0_https_github_com_torvalds_linux_commit_6089fb3_0xccccccccdddddddd_expects",
"tests::info::test_prog_stats",
"tests::load::pin_lifecycle",
"tests::smoke::xdp"
] |
[] |
[] |
[] |
auto_2025-06-07
|
|
aya-rs/aya
| 897
|
aya-rs__aya-897
|
[
"896"
] |
b6a84b658ae00f23d0f1721c30d11f2e57f99eab
|
diff --git a/aya-bpf-macros/src/cgroup_skb.rs b/aya-bpf-macros/src/cgroup_skb.rs
--- a/aya-bpf-macros/src/cgroup_skb.rs
+++ b/aya-bpf-macros/src/cgroup_skb.rs
@@ -29,7 +29,7 @@ impl CgroupSkb {
let section_name: Cow<'_, _> = if self.attach_type.is_some() {
format!("cgroup_skb/{}", self.attach_type.as_ref().unwrap()).into()
} else {
- "cgroup_skb".into()
+ "cgroup/skb".into()
};
let fn_vis = &self.item.vis;
let fn_name = self.item.sig.ident.clone();
|
diff --git a/aya-bpf-macros/src/cgroup_skb.rs b/aya-bpf-macros/src/cgroup_skb.rs
--- a/aya-bpf-macros/src/cgroup_skb.rs
+++ b/aya-bpf-macros/src/cgroup_skb.rs
@@ -66,7 +66,7 @@ mod tests {
let expanded = prog.expand().unwrap();
let expected = quote! {
#[no_mangle]
- #[link_section = "cgroup_skb"]
+ #[link_section = "cgroup/skb"]
fn foo(ctx: *mut ::aya_bpf::bindings::__sk_buff) -> i32 {
return foo(::aya_bpf::programs::SkBuffContext::new(ctx));
|
Error: error parsing BPF object: invalid program section `cgroup_skb`
**My program code:
```
#[cgroup_skb]
pub fn cg01(ctx: SkBuffContext) -> i32 {
match try_cg02(ctx) {
Ok(ret) => ret,
Err(ret) => ret,
}
}
fn try_cg01(ctx: SkBuffContext) -> Result<i32, i32> {
info!(&ctx, "received a packet");
Ok(0)
}**
==========================================================
**cargo xtask build-ebpf --> Compilation passed**
**cargo xtask run --> Failed to run `sudo -E target/debug/cg01` invalid program section `cgroup_skb`**
```
|
Change
```
#[cgroup_skb]
```
to
```
#[cgroup_skb(ingress)]
```
if you want to hook to ingress or
```
#[cgroup_skb(egress)]
```
if you want to hook to egress
@dave-tucker looks like this was broken in https://github.com/aya-rs/aya/commit/c72aab5f7b809b48273cd2fed4554ddff6b66bdf#diff-748602d38469d68a9e1066e81e7675656a5bc2052f844ea8f0dd4d350101154fL379
the section name when no attrs are passed must be `cgroup/skb`
|
2024-03-04T07:45:13Z
|
1.5
|
2024-03-04T08:53:45Z
|
1d272f38bd19f64652ac8a278948f61e66164856
|
[
"cgroup_skb::tests::cgroup_skb"
] |
[
"cgroup_device::tests::test_cgroup_device",
"btf_tracepoint::tests::test_btf_tracepoint",
"cgroup_skb::tests::cgroup_skb_egress",
"btf_tracepoint::tests::test_btf_tracepoint_with_function",
"cgroup_skb::tests::cgroup_skb_ingress",
"cgroup_skb::tests::priv_function",
"cgroup_skb::tests::pub_crate_function",
"cgroup_sock::tests::cgroup_sock_post_bind4",
"cgroup_sock::tests::cgroup_sock_post_bind6",
"cgroup_skb::tests::pub_function",
"cgroup_sock::tests::cgroup_sock_sock_create",
"cgroup_sock::tests::cgroup_sock_sock_release",
"cgroup_sock_addr::tests::cgroup_sock_addr_bind4",
"cgroup_sock_addr::tests::cgroup_sock_addr_bind6",
"cgroup_sock_addr::tests::cgroup_sock_addr_connect6",
"cgroup_sock_addr::tests::cgroup_sock_addr_connect4",
"cgroup_sock_addr::tests::cgroup_sock_addr_getpeername6",
"cgroup_sock_addr::tests::cgroup_sock_addr_getpeername4",
"cgroup_sock_addr::tests::cgroup_sock_addr_getsockname4",
"cgroup_sock_addr::tests::cgroup_sock_addr_recvmsg6",
"cgroup_sock_addr::tests::cgroup_sock_addr_getsockname6",
"cgroup_sock_addr::tests::cgroup_sock_addr_recvmsg4",
"cgroup_sock_addr::tests::cgroup_sock_addr_sendmsg4",
"cgroup_sock_addr::tests::cgroup_sock_addr_sendmsg6",
"cgroup_sockopt::tests::cgroup_sockopt_setsockopt",
"cgroup_sysctl::tests::test_cgroup_sysctl",
"cgroup_sockopt::tests::cgroup_sockopt_getsockopt",
"fentry::tests::test_fentry",
"fentry::tests::test_fentry_sleepable",
"fentry::tests::test_fentry_with_function",
"kprobe::tests::test_kprobe",
"fexit::tests::test_fexit",
"fexit::tests::test_fexit_sleepable",
"fexit::tests::test_fexit_with_function",
"kprobe::tests::test_kprobe_with_function",
"kprobe::tests::test_kretprobe",
"map::tests::test_map_no_name",
"lsm::tests::test_lsm",
"lsm::tests::test_lsm_sleepable",
"map::tests::test_map_with_name",
"kprobe::tests::test_kprobe_with_function_and_offset",
"perf_event::tests::test_perf_event",
"sk_skb::tests::test_stream_parser",
"sk_msg::tests::test_sk_msg",
"sk_lookup::tests::test_sk_lookup",
"raw_tracepoint::tests::test_raw_tracepoint",
"sk_skb::tests::test_stream_verdict",
"sock_ops::tests::test_sock_ops",
"socket_filter::tests::test_socket_filter",
"tc::tests::test_sched_classifier",
"tracepoint::tests::test_tracepoint",
"uprobe::tests::test_uretprobe",
"uprobe::tests::uprobe_sleepable",
"uprobe::tests::test_uprobe_with_path_and_offset",
"uprobe::tests::uprobe",
"uprobe::tests::uprobe_with_path",
"xdp::tests::test_xdp",
"xdp::tests::test_xdp_cpumap",
"xdp::tests::test_xdp_devmap",
"xdp::tests::test_xdp_bad_map - should panic",
"xdp::tests::test_xdp_frags_cpumap",
"xdp::tests::test_xdp_frags_devmap",
"xdp::tests::test_xdp_frags",
"aya-bpf-macros/src/lib.rs - stream_verdict (line 458) - compile",
"aya-bpf-macros/src/lib.rs - sk_lookup (line 617) - compile",
"aya-bpf-macros/src/lib.rs - xdp (line 144) - compile",
"aya-bpf-macros/src/lib.rs - lsm (line 349) - compile",
"aya-bpf-macros/src/lib.rs - fentry (line 530) - compile",
"aya-bpf-macros/src/lib.rs - socket_filter (line 499) - compile",
"aya-bpf-macros/src/lib.rs - raw_tracepoint (line 302) - compile",
"aya-bpf-macros/src/lib.rs - cgroup_device (line 647) - compile",
"aya-bpf-macros/src/lib.rs - fexit (line 575) - compile",
"aya-bpf-macros/src/lib.rs - stream_parser (line 427) - compile",
"aya-bpf-macros/src/lib.rs - btf_tracepoint (line 389) - compile",
"aya-bpf-macros/src/lib.rs - cgroup_sock_addr (line 224) - compile"
] |
[] |
[] |
auto_2025-06-07
|
aya-rs/aya
| 431
|
aya-rs__aya-431
|
[
"427"
] |
82773f46c8cff830b36b8b4f57100952eb6ec8d2
|
diff --git a/aya/src/maps/array/array.rs b/aya/src/maps/array/array.rs
--- a/aya/src/maps/array/array.rs
+++ b/aya/src/maps/array/array.rs
@@ -1,4 +1,5 @@
use std::{
+ borrow::Borrow,
convert::{AsMut, AsRef},
marker::PhantomData,
};
diff --git a/aya/src/maps/array/array.rs b/aya/src/maps/array/array.rs
--- a/aya/src/maps/array/array.rs
+++ b/aya/src/maps/array/array.rs
@@ -88,11 +89,11 @@ impl<T: AsMut<MapData>, V: Pod> Array<T, V> {
///
/// Returns [`MapError::OutOfBounds`] if `index` is out of bounds, [`MapError::SyscallError`]
/// if `bpf_map_update_elem` fails.
- pub fn set(&mut self, index: u32, value: V, flags: u64) -> Result<(), MapError> {
+ pub fn set(&mut self, index: u32, value: impl Borrow<V>, flags: u64) -> Result<(), MapError> {
let data = self.inner.as_mut();
check_bounds(data, index)?;
let fd = data.fd_or_err()?;
- bpf_map_update_elem(fd, Some(&index), &value, flags).map_err(|(_, io_error)| {
+ bpf_map_update_elem(fd, Some(&index), value.borrow(), flags).map_err(|(_, io_error)| {
MapError::SyscallError {
call: "bpf_map_update_elem".to_owned(),
io_error,
diff --git a/aya/src/maps/bloom_filter.rs b/aya/src/maps/bloom_filter.rs
--- a/aya/src/maps/bloom_filter.rs
+++ b/aya/src/maps/bloom_filter.rs
@@ -1,5 +1,5 @@
//! A Bloom Filter.
-use std::{convert::AsRef, marker::PhantomData};
+use std::{borrow::Borrow, convert::AsRef, marker::PhantomData};
use crate::{
maps::{check_v_size, MapData, MapError},
diff --git a/aya/src/maps/bloom_filter.rs b/aya/src/maps/bloom_filter.rs
--- a/aya/src/maps/bloom_filter.rs
+++ b/aya/src/maps/bloom_filter.rs
@@ -62,11 +62,13 @@ impl<T: AsRef<MapData>, V: Pod> BloomFilter<T, V> {
}
/// Inserts a value into the map.
- pub fn insert(&self, value: V, flags: u64) -> Result<(), MapError> {
+ pub fn insert(&self, value: impl Borrow<V>, flags: u64) -> Result<(), MapError> {
let fd = self.inner.as_ref().fd_or_err()?;
- bpf_map_push_elem(fd, &value, flags).map_err(|(_, io_error)| MapError::SyscallError {
- call: "bpf_map_push_elem".to_owned(),
- io_error,
+ bpf_map_push_elem(fd, value.borrow(), flags).map_err(|(_, io_error)| {
+ MapError::SyscallError {
+ call: "bpf_map_push_elem".to_owned(),
+ io_error,
+ }
})?;
Ok(())
}
diff --git a/aya/src/maps/hash_map/hash_map.rs b/aya/src/maps/hash_map/hash_map.rs
--- a/aya/src/maps/hash_map/hash_map.rs
+++ b/aya/src/maps/hash_map/hash_map.rs
@@ -1,4 +1,5 @@
use std::{
+ borrow::Borrow,
convert::{AsMut, AsRef},
marker::PhantomData,
};
diff --git a/aya/src/maps/hash_map/hash_map.rs b/aya/src/maps/hash_map/hash_map.rs
--- a/aya/src/maps/hash_map/hash_map.rs
+++ b/aya/src/maps/hash_map/hash_map.rs
@@ -78,8 +79,13 @@ impl<T: AsRef<MapData>, K: Pod, V: Pod> HashMap<T, K, V> {
impl<T: AsMut<MapData>, K: Pod, V: Pod> HashMap<T, K, V> {
/// Inserts a key-value pair into the map.
- pub fn insert(&mut self, key: K, value: V, flags: u64) -> Result<(), MapError> {
- hash_map::insert(self.inner.as_mut(), key, value, flags)
+ pub fn insert(
+ &mut self,
+ key: impl Borrow<K>,
+ value: impl Borrow<V>,
+ flags: u64,
+ ) -> Result<(), MapError> {
+ hash_map::insert(self.inner.as_mut(), key.borrow(), value.borrow(), flags)
}
/// Removes a key from the map.
diff --git a/aya/src/maps/hash_map/mod.rs b/aya/src/maps/hash_map/mod.rs
--- a/aya/src/maps/hash_map/mod.rs
+++ b/aya/src/maps/hash_map/mod.rs
@@ -2,6 +2,7 @@
use crate::{
maps::MapError,
sys::{bpf_map_delete_elem, bpf_map_update_elem},
+ Pod,
};
#[allow(clippy::module_inception)]
diff --git a/aya/src/maps/hash_map/mod.rs b/aya/src/maps/hash_map/mod.rs
--- a/aya/src/maps/hash_map/mod.rs
+++ b/aya/src/maps/hash_map/mod.rs
@@ -13,14 +14,14 @@ pub use per_cpu_hash_map::*;
use super::MapData;
-pub(crate) fn insert<K, V>(
+pub(crate) fn insert<K: Pod, V: Pod>(
map: &mut MapData,
- key: K,
- value: V,
+ key: &K,
+ value: &V,
flags: u64,
) -> Result<(), MapError> {
let fd = map.fd_or_err()?;
- bpf_map_update_elem(fd, Some(&key), &value, flags).map_err(|(_, io_error)| {
+ bpf_map_update_elem(fd, Some(key), value, flags).map_err(|(_, io_error)| {
MapError::SyscallError {
call: "bpf_map_update_elem".to_owned(),
io_error,
diff --git a/aya/src/maps/hash_map/mod.rs b/aya/src/maps/hash_map/mod.rs
--- a/aya/src/maps/hash_map/mod.rs
+++ b/aya/src/maps/hash_map/mod.rs
@@ -30,7 +31,7 @@ pub(crate) fn insert<K, V>(
Ok(())
}
-pub(crate) fn remove<K>(map: &mut MapData, key: &K) -> Result<(), MapError> {
+pub(crate) fn remove<K: Pod>(map: &mut MapData, key: &K) -> Result<(), MapError> {
let fd = map.fd_or_err()?;
bpf_map_delete_elem(fd, key)
.map(|_| ())
diff --git a/aya/src/maps/hash_map/per_cpu_hash_map.rs b/aya/src/maps/hash_map/per_cpu_hash_map.rs
--- a/aya/src/maps/hash_map/per_cpu_hash_map.rs
+++ b/aya/src/maps/hash_map/per_cpu_hash_map.rs
@@ -1,5 +1,6 @@
//! Per-CPU hash map.
use std::{
+ borrow::Borrow,
convert::{AsMut, AsRef},
marker::PhantomData,
};
diff --git a/aya/src/maps/hash_map/per_cpu_hash_map.rs b/aya/src/maps/hash_map/per_cpu_hash_map.rs
--- a/aya/src/maps/hash_map/per_cpu_hash_map.rs
+++ b/aya/src/maps/hash_map/per_cpu_hash_map.rs
@@ -115,14 +116,19 @@ impl<T: AsMut<MapData>, K: Pod, V: Pod> PerCpuHashMap<T, K, V> {
/// )?;
/// # Ok::<(), Error>(())
/// ```
- pub fn insert(&mut self, key: K, values: PerCpuValues<V>, flags: u64) -> Result<(), MapError> {
+ pub fn insert(
+ &mut self,
+ key: impl Borrow<K>,
+ values: PerCpuValues<V>,
+ flags: u64,
+ ) -> Result<(), MapError> {
let fd = self.inner.as_mut().fd_or_err()?;
- bpf_map_update_elem_per_cpu(fd, &key, &values, flags).map_err(|(_, io_error)| {
- MapError::SyscallError {
+ bpf_map_update_elem_per_cpu(fd, key.borrow(), &values, flags).map_err(
+ |(_, io_error)| MapError::SyscallError {
call: "bpf_map_update_elem".to_owned(),
io_error,
- }
- })?;
+ },
+ )?;
Ok(())
}
diff --git a/aya/src/maps/lpm_trie.rs b/aya/src/maps/lpm_trie.rs
--- a/aya/src/maps/lpm_trie.rs
+++ b/aya/src/maps/lpm_trie.rs
@@ -1,5 +1,6 @@
//! A LPM Trie.
use std::{
+ borrow::Borrow,
convert::{AsMut, AsRef},
marker::PhantomData,
mem,
diff --git a/aya/src/maps/lpm_trie.rs b/aya/src/maps/lpm_trie.rs
--- a/aya/src/maps/lpm_trie.rs
+++ b/aya/src/maps/lpm_trie.rs
@@ -128,9 +129,14 @@ impl<T: AsRef<MapData>, K: Pod, V: Pod> LpmTrie<T, K, V> {
impl<T: AsMut<MapData>, K: Pod, V: Pod> LpmTrie<T, K, V> {
/// Inserts a key value pair into the map.
- pub fn insert(&mut self, key: &Key<K>, value: V, flags: u64) -> Result<(), MapError> {
+ pub fn insert(
+ &mut self,
+ key: &Key<K>,
+ value: impl Borrow<V>,
+ flags: u64,
+ ) -> Result<(), MapError> {
let fd = self.inner.as_mut().fd_or_err()?;
- bpf_map_update_elem(fd, Some(key), &value, flags).map_err(|(_, io_error)| {
+ bpf_map_update_elem(fd, Some(key), value.borrow(), flags).map_err(|(_, io_error)| {
MapError::SyscallError {
call: "bpf_map_update_elem".to_owned(),
io_error,
diff --git a/aya/src/maps/queue.rs b/aya/src/maps/queue.rs
--- a/aya/src/maps/queue.rs
+++ b/aya/src/maps/queue.rs
@@ -1,5 +1,6 @@
//! A FIFO queue.
use std::{
+ borrow::Borrow,
convert::{AsMut, AsRef},
marker::PhantomData,
};
diff --git a/aya/src/maps/queue.rs b/aya/src/maps/queue.rs
--- a/aya/src/maps/queue.rs
+++ b/aya/src/maps/queue.rs
@@ -78,11 +79,13 @@ impl<T: AsMut<MapData>, V: Pod> Queue<T, V> {
/// # Errors
///
/// [`MapError::SyscallError`] if `bpf_map_update_elem` fails.
- pub fn push(&mut self, value: V, flags: u64) -> Result<(), MapError> {
+ pub fn push(&mut self, value: impl Borrow<V>, flags: u64) -> Result<(), MapError> {
let fd = self.inner.as_mut().fd_or_err()?;
- bpf_map_push_elem(fd, &value, flags).map_err(|(_, io_error)| MapError::SyscallError {
- call: "bpf_map_push_elem".to_owned(),
- io_error,
+ bpf_map_push_elem(fd, value.borrow(), flags).map_err(|(_, io_error)| {
+ MapError::SyscallError {
+ call: "bpf_map_push_elem".to_owned(),
+ io_error,
+ }
})?;
Ok(())
}
diff --git a/aya/src/maps/sock/sock_hash.rs b/aya/src/maps/sock/sock_hash.rs
--- a/aya/src/maps/sock/sock_hash.rs
+++ b/aya/src/maps/sock/sock_hash.rs
@@ -1,4 +1,5 @@
use std::{
+ borrow::Borrow,
convert::{AsMut, AsRef},
marker::PhantomData,
os::unix::io::{AsRawFd, RawFd},
diff --git a/aya/src/maps/sock/sock_hash.rs b/aya/src/maps/sock/sock_hash.rs
--- a/aya/src/maps/sock/sock_hash.rs
+++ b/aya/src/maps/sock/sock_hash.rs
@@ -115,8 +116,13 @@ impl<T: AsRef<MapData>, K: Pod> SockHash<T, K> {
impl<T: AsMut<MapData>, K: Pod> SockHash<T, K> {
/// Inserts a socket under the given key.
- pub fn insert<I: AsRawFd>(&mut self, key: K, value: I, flags: u64) -> Result<(), MapError> {
- hash_map::insert(self.inner.as_mut(), key, value.as_raw_fd(), flags)
+ pub fn insert<I: AsRawFd>(
+ &mut self,
+ key: impl Borrow<K>,
+ value: I,
+ flags: u64,
+ ) -> Result<(), MapError> {
+ hash_map::insert(self.inner.as_mut(), key.borrow(), &value.as_raw_fd(), flags)
}
/// Removes a socket from the map.
diff --git a/aya/src/maps/stack.rs b/aya/src/maps/stack.rs
--- a/aya/src/maps/stack.rs
+++ b/aya/src/maps/stack.rs
@@ -1,5 +1,6 @@
//! A LIFO stack.
use std::{
+ borrow::Borrow,
convert::{AsMut, AsRef},
marker::PhantomData,
};
diff --git a/aya/src/maps/stack.rs b/aya/src/maps/stack.rs
--- a/aya/src/maps/stack.rs
+++ b/aya/src/maps/stack.rs
@@ -78,9 +79,9 @@ impl<T: AsMut<MapData>, V: Pod> Stack<T, V> {
/// # Errors
///
/// [`MapError::SyscallError`] if `bpf_map_update_elem` fails.
- pub fn push(&mut self, value: V, flags: u64) -> Result<(), MapError> {
+ pub fn push(&mut self, value: impl Borrow<V>, flags: u64) -> Result<(), MapError> {
let fd = self.inner.as_mut().fd_or_err()?;
- bpf_map_update_elem(fd, None::<&u32>, &value, flags).map_err(|(_, io_error)| {
+ bpf_map_update_elem(fd, None::<&u32>, value.borrow(), flags).map_err(|(_, io_error)| {
MapError::SyscallError {
call: "bpf_map_update_elem".to_owned(),
io_error,
diff --git a/aya/src/sys/bpf.rs b/aya/src/sys/bpf.rs
--- a/aya/src/sys/bpf.rs
+++ b/aya/src/sys/bpf.rs
@@ -232,7 +232,7 @@ pub(crate) fn bpf_map_lookup_elem_ptr<K: Pod, V>(
}
}
-pub(crate) fn bpf_map_update_elem<K, V>(
+pub(crate) fn bpf_map_update_elem<K: Pod, V: Pod>(
fd: RawFd,
key: Option<&K>,
value: &V,
diff --git a/aya/src/sys/bpf.rs b/aya/src/sys/bpf.rs
--- a/aya/src/sys/bpf.rs
+++ b/aya/src/sys/bpf.rs
@@ -251,7 +251,7 @@ pub(crate) fn bpf_map_update_elem<K, V>(
sys_bpf(bpf_cmd::BPF_MAP_UPDATE_ELEM, &attr)
}
-pub(crate) fn bpf_map_push_elem<V>(fd: RawFd, value: &V, flags: u64) -> SysResult {
+pub(crate) fn bpf_map_push_elem<V: Pod>(fd: RawFd, value: &V, flags: u64) -> SysResult {
let mut attr = unsafe { mem::zeroed::<bpf_attr>() };
let u = unsafe { &mut attr.__bindgen_anon_2 };
diff --git a/aya/src/sys/bpf.rs b/aya/src/sys/bpf.rs
--- a/aya/src/sys/bpf.rs
+++ b/aya/src/sys/bpf.rs
@@ -279,7 +279,7 @@ pub(crate) fn bpf_map_update_elem_ptr<K, V>(
sys_bpf(bpf_cmd::BPF_MAP_UPDATE_ELEM, &attr)
}
-pub(crate) fn bpf_map_update_elem_per_cpu<K, V: Pod>(
+pub(crate) fn bpf_map_update_elem_per_cpu<K: Pod, V: Pod>(
fd: RawFd,
key: &K,
values: &PerCpuValues<V>,
diff --git a/aya/src/sys/bpf.rs b/aya/src/sys/bpf.rs
--- a/aya/src/sys/bpf.rs
+++ b/aya/src/sys/bpf.rs
@@ -289,7 +289,7 @@ pub(crate) fn bpf_map_update_elem_per_cpu<K, V: Pod>(
bpf_map_update_elem_ptr(fd, key, mem.as_mut_ptr(), flags)
}
-pub(crate) fn bpf_map_delete_elem<K>(fd: RawFd, key: &K) -> SysResult {
+pub(crate) fn bpf_map_delete_elem<K: Pod>(fd: RawFd, key: &K) -> SysResult {
let mut attr = unsafe { mem::zeroed::<bpf_attr>() };
let u = unsafe { &mut attr.__bindgen_anon_2 };
diff --git a/aya/src/sys/bpf.rs b/aya/src/sys/bpf.rs
--- a/aya/src/sys/bpf.rs
+++ b/aya/src/sys/bpf.rs
@@ -299,7 +299,7 @@ pub(crate) fn bpf_map_delete_elem<K>(fd: RawFd, key: &K) -> SysResult {
sys_bpf(bpf_cmd::BPF_MAP_DELETE_ELEM, &attr)
}
-pub(crate) fn bpf_map_get_next_key<K>(
+pub(crate) fn bpf_map_get_next_key<K: Pod>(
fd: RawFd,
key: Option<&K>,
) -> Result<Option<K>, (c_long, io::Error)> {
diff --git a/bpf/aya-bpf/src/maps/sock_hash.rs b/bpf/aya-bpf/src/maps/sock_hash.rs
--- a/bpf/aya-bpf/src/maps/sock_hash.rs
+++ b/bpf/aya-bpf/src/maps/sock_hash.rs
@@ -1,4 +1,4 @@
-use core::{cell::UnsafeCell, marker::PhantomData, mem};
+use core::{borrow::Borrow, cell::UnsafeCell, marker::PhantomData, mem};
use aya_bpf_cty::c_void;
diff --git a/bpf/aya-bpf/src/maps/sock_hash.rs b/bpf/aya-bpf/src/maps/sock_hash.rs
--- a/bpf/aya-bpf/src/maps/sock_hash.rs
+++ b/bpf/aya-bpf/src/maps/sock_hash.rs
@@ -89,7 +89,7 @@ impl<K> SockHash<K> {
pub fn redirect_sk_lookup(
&mut self,
ctx: &SkLookupContext,
- key: K,
+ key: impl Borrow<K>,
flags: u64,
) -> Result<(), u32> {
unsafe {
|
diff --git a/aya/src/maps/hash_map/hash_map.rs b/aya/src/maps/hash_map/hash_map.rs
--- a/aya/src/maps/hash_map/hash_map.rs
+++ b/aya/src/maps/hash_map/hash_map.rs
@@ -311,6 +317,27 @@ mod tests {
assert!(hm.insert(1, 42, 0).is_ok());
}
+ #[test]
+ fn test_insert_boxed_ok() {
+ override_syscall(|call| match call {
+ Syscall::Bpf {
+ cmd: bpf_cmd::BPF_MAP_UPDATE_ELEM,
+ ..
+ } => Ok(1),
+ _ => sys_error(EFAULT),
+ });
+
+ let mut map = MapData {
+ obj: new_obj_map(),
+ fd: Some(42),
+ pinned: false,
+ btf_fd: None,
+ };
+ let mut hm = HashMap::<_, u32, u32>::new(&mut map).unwrap();
+
+ assert!(hm.insert(Box::new(1), Box::new(42), 0).is_ok());
+ }
+
#[test]
fn test_remove_syscall_error() {
override_syscall(|_| sys_error(EFAULT));
|
API for updating maps with large Pod
Although Rust is memory safe, it does not have any stack overflow protection. The default Rust stack is 2MB which is plenty for most applications. However, when dealing with Pod with large arrays embedded, it's possible to overflow the user space Rust stack.
Here's an example:
```rust
#[derive(Clone, Copy)]
pub struct Data {
arr: [u8; 2 << 10 << 10],
}
```
Now, in order to prevent this, we need to `Box` the struct. However, since `Box` can't be `Copy`. So such structs are unable to implement `aya::Pod`.
|
We can change the insert() calls to take `AsRef<K>` and `AsRef<V>` so they work with both values and references (including boxes)
|
2022-11-01T20:35:41Z
|
0.11
|
2023-02-23T09:59:02Z
|
61608e64583f9dc599eef9b8db098f38a765b285
|
[
"maps::bloom_filter::tests::test_contains_syscall_error",
"maps::bloom_filter::tests::test_contains_not_found",
"maps::bloom_filter::tests::test_insert_ok",
"maps::bloom_filter::tests::test_insert_syscall_error",
"maps::bloom_filter::tests::test_new_not_created",
"maps::bloom_filter::tests::test_new_ok",
"maps::bloom_filter::tests::test_try_from_wrong_map",
"maps::bloom_filter::tests::test_try_from_ok",
"maps::bloom_filter::tests::test_wrong_value_size",
"maps::hash_map::hash_map::tests::test_get_not_found",
"maps::hash_map::hash_map::tests::test_get_syscall_error",
"maps::hash_map::hash_map::tests::test_insert_ok",
"maps::hash_map::hash_map::tests::test_insert_syscall_error",
"maps::hash_map::hash_map::tests::test_iter",
"maps::hash_map::hash_map::tests::test_iter_key_deleted",
"maps::hash_map::hash_map::tests::test_iter_key_error",
"maps::hash_map::hash_map::tests::test_iter_value_error",
"maps::hash_map::hash_map::tests::test_keys",
"maps::hash_map::hash_map::tests::test_keys_empty",
"maps::hash_map::hash_map::tests::test_keys_error",
"maps::hash_map::hash_map::tests::test_new_not_created",
"maps::hash_map::hash_map::tests::test_new_ok",
"maps::hash_map::hash_map::tests::test_remove_ok",
"maps::hash_map::hash_map::tests::test_remove_syscall_error",
"maps::hash_map::hash_map::tests::test_try_from_ok",
"maps::hash_map::hash_map::tests::test_try_from_ok_lru",
"maps::hash_map::hash_map::tests::test_try_from_wrong_map",
"maps::hash_map::hash_map::tests::test_try_from_wrong_map_values",
"maps::hash_map::hash_map::tests::test_wrong_key_size",
"maps::hash_map::hash_map::tests::test_wrong_value_size",
"maps::lpm_trie::tests::test_get_not_found",
"maps::lpm_trie::tests::test_get_syscall_error",
"maps::lpm_trie::tests::test_insert_ok",
"maps::lpm_trie::tests::test_insert_syscall_error",
"maps::lpm_trie::tests::test_new_not_created",
"maps::lpm_trie::tests::test_new_ok",
"maps::lpm_trie::tests::test_remove_ok",
"maps::lpm_trie::tests::test_remove_syscall_error",
"maps::lpm_trie::tests::test_try_from_ok",
"maps::lpm_trie::tests::test_try_from_wrong_map",
"maps::lpm_trie::tests::test_wrong_key_size",
"maps::lpm_trie::tests::test_wrong_value_size",
"maps::perf::perf_buffer::tests::test_invalid_page_count",
"maps::perf::perf_buffer::tests::test_no_events",
"maps::perf::perf_buffer::tests::test_no_out_bufs",
"maps::perf::perf_buffer::tests::test_read_first_lost",
"maps::perf::perf_buffer::tests::test_read_last_sample",
"maps::perf::perf_buffer::tests::test_read_first_sample",
"maps::perf::perf_buffer::tests::test_read_many_with_many_reads",
"maps::perf::perf_buffer::tests::test_read_many_with_one_read",
"maps::perf::perf_buffer::tests::test_read_wrapping_sample_size",
"maps::perf::perf_buffer::tests::test_read_wrapping_value",
"maps::tests::test_create",
"maps::tests::test_create_failed",
"obj::btf::btf::tests::test_fixup_func_proto",
"obj::btf::btf::tests::test_fixup_ptr",
"obj::btf::btf::tests::test_fixup_datasec",
"obj::btf::btf::tests::test_parse_header",
"obj::btf::btf::tests::test_sanitize_datasec",
"obj::btf::btf::tests::test_parse_btf",
"obj::btf::btf::tests::test_sanitize_decl_tag",
"obj::btf::btf::tests::test_sanitize_float",
"obj::btf::btf::tests::test_sanitize_func_and_proto",
"obj::btf::btf::tests::test_sanitize_func_global",
"obj::btf::btf::tests::test_sanitize_type_tag",
"obj::btf::btf::tests::test_sanitize_var",
"obj::btf::btf::tests::test_write_btf",
"obj::btf::types::tests::test_read_btf_type_array",
"obj::btf::types::tests::test_read_btf_type_const",
"obj::btf::types::tests::test_read_btf_type_enum",
"obj::btf::types::tests::test_read_btf_type_float",
"obj::btf::types::tests::test_read_btf_type_func",
"obj::btf::types::tests::test_read_btf_type_func_datasec",
"obj::btf::types::tests::test_read_btf_type_func_proto",
"obj::btf::types::tests::test_read_btf_type_func_var",
"obj::btf::types::tests::test_read_btf_type_fwd",
"obj::btf::types::tests::test_read_btf_type_int",
"obj::btf::types::tests::test_read_btf_type_ptr",
"obj::btf::types::tests::test_read_btf_type_restrict",
"obj::btf::types::tests::test_read_btf_type_typedef",
"obj::btf::types::tests::test_read_btf_type_union",
"obj::btf::types::tests::test_read_btf_type_volatile",
"obj::btf::types::tests::test_read_btf_type_struct",
"obj::btf::types::tests::test_write_btf_long_unsigned_int",
"obj::btf::types::tests::test_types_are_compatible",
"obj::btf::types::tests::test_write_btf_signed_short_int",
"obj::btf::types::tests::test_write_btf_func_proto",
"obj::btf::types::tests::test_write_btf_uchar",
"obj::relocation::test::test_multiple_btf_map_relocation",
"obj::relocation::test::test_multiple_legacy_map_relocation",
"obj::relocation::test::test_single_btf_map_relocation",
"obj::relocation::test::test_single_legacy_map_relocation",
"obj::tests::test_parse_generic_error",
"obj::tests::test_parse_license",
"obj::tests::test_parse_map",
"obj::tests::test_parse_map_data",
"obj::tests::test_parse_map_def",
"obj::tests::test_parse_btf_map_section",
"obj::tests::test_parse_map_def_error",
"obj::tests::test_parse_map_def_with_padding",
"obj::tests::test_parse_map_short",
"obj::tests::test_parse_map_error",
"obj::tests::test_parse_program",
"obj::tests::test_parse_program_error",
"obj::tests::test_parse_section_btf_tracepoint",
"obj::tests::test_parse_section_cgroup_skb_ingress_named",
"obj::tests::test_parse_section_cgroup_skb_ingress_unnamed",
"obj::tests::test_parse_section_cgroup_skb_no_direction_unamed",
"obj::tests::test_parse_section_cgroup_skb_no_direction_named",
"obj::tests::test_parse_section_fexit",
"obj::tests::test_parse_section_data",
"obj::tests::test_parse_section_fentry",
"obj::tests::test_parse_section_kprobe",
"obj::tests::test_parse_section_lsm",
"obj::tests::test_parse_section_map",
"obj::tests::test_parse_section_multiple_maps",
"obj::tests::test_parse_section_raw_tp",
"obj::tests::test_parse_section_sock_addr_named",
"obj::tests::test_parse_section_skskb_named",
"obj::tests::test_parse_section_sockopt_unnamed",
"obj::tests::test_parse_section_sockopt_named",
"obj::tests::test_parse_section_skskb_unnamed",
"obj::tests::test_parse_section_trace_point",
"obj::tests::test_parse_section_uprobe",
"obj::tests::test_parse_section_xdp",
"obj::tests::test_parse_section_sock_addr_unnamed",
"obj::tests::test_parse_section_socket_filter",
"obj::tests::test_parse_version",
"programs::links::tests::test_already_attached",
"obj::tests::test_patch_map_data",
"programs::links::tests::test_drop_detach",
"programs::links::tests::test_not_attached",
"programs::links::tests::test_link_map",
"programs::links::tests::test_owned_detach",
"sys::netlink::tests::test_nested_attrs",
"sys::netlink::tests::test_nlattr_iterator_empty",
"sys::netlink::tests::test_nlattr_iterator_many",
"sys::netlink::tests::test_nlattr_iterator_nested",
"sys::netlink::tests::test_nlattr_iterator_one",
"util::tests::test_parse_kernel_symbols",
"util::tests::test_parse_online_cpus",
"programs::links::tests::test_pin",
"obj::btf::btf::tests::test_read_btf_from_sys_fs",
"src/bpf.rs - bpf::BpfLoader<'a>::set_global (line 290) - compile",
"src/bpf.rs - bpf::BpfLoader<'a>::set_global (line 284) - compile",
"src/bpf.rs - bpf::Bpf::program (line 804) - compile",
"src/bpf.rs - bpf::BpfLoader (line 176) - compile",
"src/bpf.rs - bpf::Bpf::maps (line 780) - compile",
"src/bpf.rs - bpf::Bpf::programs (line 837) - compile",
"src/bpf.rs - bpf::BpfLoader<'a>::verifier_log_level (line 367) - compile",
"src/bpf.rs - bpf::Bpf::load (line 724) - compile",
"src/bpf.rs - bpf::BpfLoader<'a>::map_pin_path (line 267) - compile",
"src/bpf.rs - bpf::Bpf::program_mut (line 821) - compile",
"src/bpf.rs - bpf::Bpf::load_file (line 702) - compile",
"src/bpf.rs - bpf::BpfLoader<'a>::btf (line 245) - compile",
"src/programs/extension.rs - programs::extension::Extension (line 36) - compile",
"src/bpf.rs - bpf::Bpf::programs_mut (line 855) - compile",
"src/bpf.rs - bpf::BpfLoader<'a>::set_global (line 304) - compile",
"src/bpf.rs - bpf::BpfLoader<'a>::load (line 403) - compile",
"src/maps/bloom_filter.rs - maps::bloom_filter::BloomFilter (line 18) - compile",
"src/maps/array/per_cpu_array.rs - maps::array::per_cpu_array::PerCpuArray (line 22) - compile",
"src/maps/mod.rs - maps (line 20) - compile",
"src/programs/sk_skb.rs - programs::sk_skb::SkSkb (line 39) - compile",
"src/bpf.rs - bpf::BpfLoader<'a>::load_file (line 385) - compile",
"src/bpf.rs - bpf::BpfLoader<'a>::set_max_entries (line 327) - compile",
"src/programs/xdp.rs - programs::xdp::Xdp (line 66) - compile",
"src/programs/kprobe.rs - programs::kprobe::KProbe (line 29) - compile",
"src/bpf.rs - bpf::BpfLoader<'a>::extension (line 349) - compile",
"src/programs/raw_trace_point.rs - programs::raw_trace_point::RawTracePoint (line 26) - compile",
"src/maps/sock/sock_map.rs - maps::sock::sock_map::SockMap (line 28) - compile",
"src/maps/array/program_array.rs - maps::array::program_array::ProgramArray (line 25) - compile",
"src/programs/cgroup_sockopt.rs - programs::cgroup_sockopt::CgroupSockopt (line 29) - compile",
"src/programs/mod.rs - programs (line 16) - compile",
"src/programs/cgroup_sock.rs - programs::cgroup_sock::CgroupSock (line 31) - compile",
"src/programs/sock_ops.rs - programs::sock_ops::SockOps (line 25) - compile",
"src/programs/tc.rs - programs::tc::SchedClassifier (line 45) - compile",
"src/programs/fexit.rs - programs::fexit::FExit (line 26) - compile",
"src/maps/mod.rs - maps::PerCpuValues (line 791) - compile",
"src/programs/cgroup_sock_addr.rs - programs::cgroup_sock_addr::CgroupSockAddr (line 32) - compile",
"src/programs/cgroup_sysctl.rs - programs::cgroup_sysctl::CgroupSysctl (line 26) - compile",
"src/programs/perf_event.rs - programs::perf_event::PerfEvent (line 87) - compile",
"src/programs/links.rs - programs::links::FdLink::pin (line 104) - compile",
"src/maps/stack_trace.rs - maps::stack_trace::StackTraceMap (line 24) - compile",
"src/programs/lsm.rs - programs::lsm::Lsm (line 27) - compile",
"src/programs/lirc_mode2.rs - programs::lirc_mode2::LircMode2 (line 25) - compile",
"src/programs/fentry.rs - programs::fentry::FEntry (line 26) - compile",
"src/programs/trace_point.rs - programs::trace_point::TracePoint (line 41) - compile",
"src/maps/perf/async_perf_event_array.rs - maps::perf::async_perf_event_array::AsyncPerfEventArray (line 34) - compile",
"src/programs/cgroup_skb.rs - programs::cgroup_skb::CgroupSkb (line 32) - compile",
"src/programs/sk_lookup.rs - programs::sk_lookup::SkLookup (line 25) - compile",
"src/maps/perf/perf_event_array.rs - maps::perf::perf_event_array::PerfEventArray (line 84) - compile",
"src/programs/tp_btf.rs - programs::tp_btf::BtfTracePoint (line 24) - compile",
"src/programs/socket_filter.rs - programs::socket_filter::SocketFilter (line 37) - compile",
"src/programs/sk_msg.rs - programs::sk_msg::SkMsg (line 27) - compile"
] |
[] |
[] |
[] |
auto_2025-06-07
|
aya-rs/aya
| 90
|
aya-rs__aya-90
|
[
"88"
] |
3a8e4fe9b91538a0fafd8c91ae96185c1a017651
|
diff --git a/aya/src/obj/mod.rs b/aya/src/obj/mod.rs
--- a/aya/src/obj/mod.rs
+++ b/aya/src/obj/mod.rs
@@ -410,6 +410,7 @@ struct Section<'a> {
address: u64,
name: &'a str,
data: &'a [u8],
+ size: u64,
relocations: Vec<Relocation>,
}
diff --git a/aya/src/obj/mod.rs b/aya/src/obj/mod.rs
--- a/aya/src/obj/mod.rs
+++ b/aya/src/obj/mod.rs
@@ -428,6 +429,7 @@ impl<'data, 'file, 'a> TryFrom<&'a ObjSection<'data, 'file>> for Section<'a> {
address: section.address(),
name: section.name().map_err(map_err)?,
data: section.data().map_err(map_err)?,
+ size: section.size(),
relocations: section
.relocations()
.map(|(offset, r)| {
diff --git a/aya/src/obj/mod.rs b/aya/src/obj/mod.rs
--- a/aya/src/obj/mod.rs
+++ b/aya/src/obj/mod.rs
@@ -505,7 +507,9 @@ fn parse_map(section: &Section, name: &str) -> Result<Map, ParseError> {
let def = bpf_map_def {
map_type: BPF_MAP_TYPE_ARRAY as u32,
key_size: mem::size_of::<u32>() as u32,
- value_size: section.data.len() as u32,
+ // We need to use section.size here since
+ // .bss will always have data.len() == 0
+ value_size: section.size as u32,
max_entries: 1,
map_flags: 0, /* FIXME: set rodata readonly */
..Default::default()
|
diff --git a/aya/src/obj/mod.rs b/aya/src/obj/mod.rs
--- a/aya/src/obj/mod.rs
+++ b/aya/src/obj/mod.rs
@@ -607,6 +611,7 @@ mod tests {
address: 0,
name,
data,
+ size: data.len() as u64,
relocations: Vec::new(),
}
}
|
bpf(2) fails with invalid argument when creating .bss map
I wanted to test out a simple example of using .data, .rodata, and .bss maps in Aya. It seems that .data and .rodata work just fine, but creating the .bss map always seems to fail with an invalid argument error. Inspecting the strace dump (shown below), the offending part of the bpf_attr struct appears to be an incorrect map value size of 0.
Here is my minimal reproduction aya-bpf code:
```rust
#![no_std]
#![no_main]
#[used]
static TEST_RODATA: i32 = 0;
#[used]
static mut TEST_DATA: i32 = 1;
#[used]
static mut TEST_BSS: i32 = 0;
```
Relevant strace dump (offending bpf syscall is the last one, others included for context):
```
46537 bpf(BPF_MAP_CREATE, {map_type=BPF_MAP_TYPE_ARRAY, key_size=4, value_size=4, max_entries=1, map_flags=0, inner_map_fd=0, map_name=".rodata", map_ifindex=0, btf_fd=0, btf_key_type_id=0, btf_value_type_id=0, btf_vmlinux_value_type_id=0}, 128) = 3
46537 bpf(BPF_MAP_UPDATE_ELEM, {map_fd=3, key=0x563ce3ec1204, value=0x563ce4ea7020, flags=BPF_ANY}, 128) = 0
46537 bpf(BPF_MAP_CREATE, {map_type=BPF_MAP_TYPE_ARRAY, key_size=4, value_size=4, max_entries=1, map_flags=0, inner_map_fd=0, map_name=".data", map_ifindex=0, btf_fd=0, btf_key_type_id=0, btf_value_type_id=0, btf_vmlinux_value_type_id=0}, 128) = 4
46537 bpf(BPF_MAP_UPDATE_ELEM, {map_fd=4, key=0x563ce3ec1204, value=0x563ce4eaec90, flags=BPF_ANY}, 128) = 0
46537 bpf(BPF_MAP_CREATE, {map_type=BPF_MAP_TYPE_ARRAY, key_size=4, value_size=0, max_entries=1, map_flags=0, inner_map_fd=0, map_name=".bss", map_ifindex=0, btf_fd=0, btf_key_type_id=0, btf_value_type_id=0, btf_vmlinux_value_type_id=0}, 128) = -1 EINVAL (Invalid argument)
```
|
2021-10-31T00:02:13Z
|
0.10
|
2021-11-04T06:00:06Z
|
b9a544831c5b4cd8728e9cca6580c14a623b7793
|
[
"maps::hash_map::hash_map::tests::test_get_syscall_error",
"maps::hash_map::hash_map::tests::test_insert_ok",
"maps::hash_map::hash_map::tests::test_get_not_found",
"maps::hash_map::hash_map::tests::test_insert_syscall_error",
"maps::hash_map::hash_map::tests::test_iter",
"maps::hash_map::hash_map::tests::test_iter_key_deleted",
"maps::hash_map::hash_map::tests::test_iter_key_error",
"maps::hash_map::hash_map::tests::test_iter_value_error",
"maps::hash_map::hash_map::tests::test_keys",
"maps::hash_map::hash_map::tests::test_keys_empty",
"maps::hash_map::hash_map::tests::test_new_not_created",
"maps::hash_map::hash_map::tests::test_keys_error",
"maps::hash_map::hash_map::tests::test_new_ok",
"maps::hash_map::hash_map::tests::test_remove_ok",
"maps::hash_map::hash_map::tests::test_remove_syscall_error",
"maps::hash_map::hash_map::tests::test_try_from_ok",
"maps::hash_map::hash_map::tests::test_try_from_ok_lru",
"maps::hash_map::hash_map::tests::test_try_from_wrong_map",
"maps::hash_map::hash_map::tests::test_wrong_key_size",
"maps::hash_map::hash_map::tests::test_wrong_value_size",
"maps::perf::perf_buffer::tests::test_invalid_page_count",
"maps::perf::perf_buffer::tests::test_no_events",
"maps::perf::perf_buffer::tests::test_no_out_bufs",
"maps::perf::perf_buffer::tests::test_read_first_lost",
"maps::perf::perf_buffer::tests::test_read_first_sample",
"maps::perf::perf_buffer::tests::test_read_last_sample",
"maps::perf::perf_buffer::tests::test_read_many_with_many_reads",
"maps::tests::test_create",
"maps::perf::perf_buffer::tests::test_read_many_with_one_read",
"maps::perf::perf_buffer::tests::test_read_wrapping_value",
"maps::perf::perf_buffer::tests::test_read_wrapping_sample_size",
"maps::tests::test_create_failed",
"obj::btf::btf::tests::test_parse_header",
"obj::btf::types::tests::test_read_btf_type_array",
"obj::btf::types::tests::test_read_btf_type_const",
"obj::btf::types::tests::test_read_btf_type_enum",
"obj::btf::types::tests::test_read_btf_type_float",
"obj::btf::types::tests::test_read_btf_type_func",
"obj::btf::types::tests::test_read_btf_type_func_datasec",
"obj::btf::types::tests::test_read_btf_type_func_proto",
"obj::btf::types::tests::test_read_btf_type_func_var",
"obj::btf::types::tests::test_read_btf_type_fwd",
"obj::btf::types::tests::test_read_btf_type_int",
"obj::btf::types::tests::test_read_btf_type_ptr",
"obj::btf::types::tests::test_read_btf_type_restrict",
"obj::btf::types::tests::test_read_btf_type_struct",
"obj::btf::types::tests::test_read_btf_type_typedef",
"obj::btf::types::tests::test_read_btf_type_union",
"obj::btf::types::tests::test_read_btf_type_volatile",
"obj::tests::test_parse_generic_error",
"obj::tests::test_parse_license",
"obj::tests::test_parse_map",
"obj::tests::test_parse_map_data",
"obj::tests::test_parse_map_def",
"obj::tests::test_parse_map_def_error",
"obj::tests::test_parse_map_def_with_padding",
"obj::tests::test_parse_map_error",
"obj::tests::test_parse_map_short",
"obj::tests::test_parse_program",
"obj::tests::test_parse_program_error",
"obj::tests::test_parse_section_data",
"obj::tests::test_parse_section_btf_tracepoint",
"obj::tests::test_parse_section_kprobe",
"obj::tests::test_parse_section_map",
"obj::tests::test_parse_section_lsm",
"obj::tests::test_parse_section_raw_tp",
"obj::tests::test_parse_section_socket_filter",
"obj::tests::test_parse_section_trace_point",
"obj::tests::test_parse_section_uprobe",
"obj::tests::test_parse_section_xdp",
"obj::tests::test_parse_version",
"sys::netlink::tests::test_nested_attrs",
"sys::netlink::tests::test_nlattr_iterator_empty",
"sys::netlink::tests::test_nlattr_iterator_many",
"sys::netlink::tests::test_nlattr_iterator_nested",
"sys::netlink::tests::test_nlattr_iterator_one",
"util::tests::test_parse_kernel_symbols",
"util::tests::test_parse_online_cpus",
"src/bpf.rs - bpf::Bpf::program_mut (line 502) - compile",
"src/bpf.rs - bpf::BpfLoader::btf (line 122) - compile",
"src/maps/mod.rs - maps (line 17) - compile",
"src/maps/hash_map/hash_map.rs - maps::hash_map::hash_map::HashMap (line 22) - compile",
"src/bpf.rs - bpf::BpfLoader (line 87) - compile",
"src/maps/sock/sock_map.rs - maps::sock::sock_map::SockMap (line 31) - compile",
"src/maps/array/program_array.rs - maps::array::program_array::ProgramArray (line 28) - compile",
"src/programs/kprobe.rs - programs::kprobe::KProbe (line 28) - compile",
"src/bpf.rs - bpf::BpfLoader::load_file (line 161) - compile",
"src/maps/hash_map/per_cpu_hash_map.rs - maps::hash_map::per_cpu_hash_map::PerCpuHashMap (line 29) - compile",
"src/programs/sk_skb.rs - programs::sk_skb::SkSkb (line 30) - compile",
"src/programs/mod.rs - programs (line 16) - compile",
"src/bpf.rs - bpf::Bpf::programs (line 523) - compile",
"src/bpf.rs - bpf::Bpf::load (line 373) - compile",
"src/bpf.rs - bpf::Bpf::program (line 477) - compile",
"src/bpf.rs - bpf::Bpf::maps (line 441) - compile",
"src/bpf.rs - bpf::BpfLoader::load (line 179) - compile",
"src/bpf.rs - bpf::BpfLoader::map_pin_path (line 143) - compile",
"src/bpf.rs - bpf::Bpf::load_file (line 351) - compile",
"src/programs/xdp.rs - programs::xdp::Xdp (line 55) - compile",
"src/programs/cgroup_skb.rs - programs::cgroup_skb::CgroupSkb (line 28) - compile",
"src/programs/raw_trace_point.rs - programs::raw_trace_point::RawTracePoint (line 24) - compile",
"src/maps/queue.rs - maps::queue::Queue (line 23) - compile",
"src/programs/socket_filter.rs - programs::socket_filter::SocketFilter (line 35) - compile",
"src/maps/stack_trace.rs - maps::stack_trace::StackTraceMap (line 27) - compile",
"src/programs/sock_ops.rs - programs::sock_ops::SockOps (line 21) - compile",
"src/maps/array/array.rs - maps::array::array::Array (line 25) - compile",
"src/maps/stack.rs - maps::stack::Stack (line 23) - compile",
"src/maps/perf/perf_event_array.rs - maps::perf::perf_event_array::PerfEventArray (line 88) - compile",
"src/programs/tp_btf.rs - programs::tp_btf::BtfTracePoint (line 26) - compile",
"src/maps/mod.rs - maps::PerCpuValues (line 391) - compile",
"src/programs/tc.rs - programs::tc::SchedClassifier (line 42) - compile",
"src/maps/hash_map/per_cpu_hash_map.rs - maps::hash_map::per_cpu_hash_map::PerCpuHashMap<T, K, V>::insert (line 106) - compile",
"src/programs/lirc_mode2.rs - programs::lirc_mode2::LircMode2 (line 24) - compile",
"src/programs/perf_event.rs - programs::perf_event::PerfEvent (line 50) - compile",
"src/programs/trace_point.rs - programs::trace_point::TracePoint (line 31) - compile",
"src/maps/sock/sock_hash.rs - maps::sock::sock_hash::SockHash (line 32) - compile",
"src/maps/array/per_cpu_array.rs - maps::array::per_cpu_array::PerCpuArray (line 25) - compile",
"src/programs/sk_msg.rs - programs::sk_msg::SkMsg (line 20) - compile",
"src/maps/perf/async_perf_event_array.rs - maps::perf::async_perf_event_array::AsyncPerfEventArray (line 35) - compile",
"src/programs/lsm.rs - programs::lsm::Lsm (line 29) - compile"
] |
[] |
[] |
[] |
auto_2025-06-07
|
|
aya-rs/aya
| 85
|
aya-rs__aya-85
|
[
"84"
] |
c4b6970774930540ece21df329a1abd8dcb4ceb7
| "diff --git a/aya/src/bpf.rs b/aya/src/bpf.rs\n--- a/aya/src/bpf.rs\n+++ b/aya/src/bpf.rs\n@@ -20,9 (...TRUNCATED)
| "diff --git a/aya/src/obj/mod.rs b/aya/src/obj/mod.rs\n--- a/aya/src/obj/mod.rs\n+++ b/aya/src/obj/m(...TRUNCATED)
| "Support BTF tracepoints (tp_btf/*, also called \"BTF-enabled raw tracepoints\")\n#68 added support (...TRUNCATED)
|
2021-10-28T21:14:42Z
|
0.10
|
2021-10-29T16:37:08Z
|
b9a544831c5b4cd8728e9cca6580c14a623b7793
| ["maps::hash_map::hash_map::tests::test_get_syscall_error","maps::hash_map::hash_map::tests::test_ge(...TRUNCATED)
|
[] |
[] |
[] |
auto_2025-06-07
|
|
aya-rs/aya
| 253
|
aya-rs__aya-253
|
[
"51"
] |
b9a544831c5b4cd8728e9cca6580c14a623b7793
| "diff --git a/aya/src/programs/cgroup_skb.rs b/aya/src/programs/cgroup_skb.rs\n--- a/aya/src/program(...TRUNCATED)
| "diff --git a/aya/src/programs/links.rs b/aya/src/programs/links.rs\n--- a/aya/src/programs/links.rs(...TRUNCATED)
| "lifecyle: Add a `forget()` API for `Link`\nDefault behaviour is that the `Drop` trait calls `detach(...TRUNCATED)
| "I'm not sure it should be called `forget()`, but then again I am struggling to come up with a bette(...TRUNCATED)
|
2022-05-06T23:27:37Z
|
0.10
|
2022-05-12T18:56:36Z
|
b9a544831c5b4cd8728e9cca6580c14a623b7793
| ["maps::hash_map::hash_map::tests::test_insert_ok","maps::hash_map::hash_map::tests::test_get_not_fo(...TRUNCATED)
|
[] |
[] |
[] |
auto_2025-06-07
|
fschutt/azul
| 2
|
fschutt__azul-2
|
[
"1"
] |
af100e8cbddaeb26cf97cb9910518aaf6bd2ed3a
| "diff --git a/Cargo.toml b/Cargo.toml\n--- a/Cargo.toml\n+++ b/Cargo.toml\n@@ -4,7 +4,7 @@ version =(...TRUNCATED)
| "diff --git a/examples/test_content.css b/examples/test_content.css\n--- a/examples/test_content.css(...TRUNCATED)
| "\"debug\" example crashes\nI am not sure if it is expected on the current state of the project deve(...TRUNCATED)
|
2018-03-20T08:12:26Z
|
0.1
|
2018-03-20T08:28:37Z
|
56d6c2bac9b752264871afab1119a34365aceacb
| ["css_parser::test_parse_box_shadow_1","css_parser::test_parse_box_shadow_10","css_parser::test_pars(...TRUNCATED)
|
[] |
[] |
[] |
auto_2025-06-07
|
|
imsnif/bandwhich
| 23
|
imsnif__bandwhich-23
|
[
"16"
] |
408ec397c81bb99d6727f01d5dc058e814012714
| "diff --git a/README.md b/README.md\n--- a/README.md\n+++ b/README.md\n@@ -29,7 +29,7 @@ Windows is (...TRUNCATED)
| "diff --git a/README.md b/README.md\n--- a/README.md\n+++ b/README.md\n@@ -46,14 +46,14 @@ Note that(...TRUNCATED)
| "Listen on all interfaces\n`what` now listens on the interface given by the `-i` flag. The default b(...TRUNCATED)
|
2019-12-10T22:07:27Z
|
0.4
|
2019-12-22T09:53:02Z
|
408ec397c81bb99d6727f01d5dc058e814012714
| ["tests::cases::ui::basic_startup","tests::cases::ui::layout_under_120_width_under_30_height","tests(...TRUNCATED)
|
[] |
[] |
[] |
auto_2025-06-07
|
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 1