From 40b7da6655aca6aed5dfe72a0db80bf0e67c2ce1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alessandro=C2=A0Decina?= Date: Thu, 13 May 2021 08:52:19 +0000 Subject: [PATCH] aya: add id and pinning fields to bpf_map_def --- aya/src/bpf.rs | 2 ++ aya/src/maps/hash_map/hash_map.rs | 6 ++++++ aya/src/maps/mod.rs | 2 ++ aya/src/obj/mod.rs | 22 ++++++++++++++++++---- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/aya/src/bpf.rs b/aya/src/bpf.rs index f3b24a60..55b6084e 100644 --- a/aya/src/bpf.rs +++ b/aya/src/bpf.rs @@ -54,6 +54,8 @@ pub(crate) struct bpf_map_def { pub(crate) value_size: u32, pub(crate) max_entries: u32, pub(crate) map_flags: u32, + pub(crate) id: u32, + pub(crate) pinning: u32, } /// The main entry point into the library, used to work with eBPF programs and maps. diff --git a/aya/src/maps/hash_map/hash_map.rs b/aya/src/maps/hash_map/hash_map.rs index fdf2e2cc..865f1e34 100644 --- a/aya/src/maps/hash_map/hash_map.rs +++ b/aya/src/maps/hash_map/hash_map.rs @@ -163,6 +163,8 @@ mod tests { value_size: 4, max_entries: 1024, map_flags: 0, + id: 0, + pinning: 0, }, section_index: 0, data: Vec::new(), @@ -214,6 +216,8 @@ mod tests { value_size: 4, max_entries: 1024, map_flags: 0, + id: 0, + pinning: 0, }, section_index: 0, data: Vec::new(), @@ -270,6 +274,8 @@ mod tests { value_size: 4, max_entries: 1024, map_flags: 0, + id: 0, + pinning: 0, }, section_index: 0, data: Vec::new(), diff --git a/aya/src/maps/mod.rs b/aya/src/maps/mod.rs index 65b793d5..2436846e 100644 --- a/aya/src/maps/mod.rs +++ b/aya/src/maps/mod.rs @@ -415,6 +415,8 @@ mod tests { value_size: 4, max_entries: 1024, map_flags: 0, + id: 0, + pinning: 0, }, section_index: 0, data: Vec::new(), diff --git a/aya/src/obj/mod.rs b/aya/src/obj/mod.rs index 00b8051a..2f8be56b 100644 --- a/aya/src/obj/mod.rs +++ b/aya/src/obj/mod.rs @@ -464,6 +464,8 @@ fn parse_map(section: &Section, name: &str) -> Result { value_size: section.data.len() as u32, max_entries: 1, map_flags: 0, /* FIXME: set rodata readonly */ + id: 0, + pinning: 0, }; (def, section.data.to_vec()) } else { @@ -610,7 +612,9 @@ mod tests { key_size: 2, value_size: 3, max_entries: 4, - map_flags: 5 + map_flags: 5, + id: 0, + pinning: 0 }) ), Ok(bpf_map_def { @@ -618,7 +622,9 @@ mod tests { key_size: 2, value_size: 3, max_entries: 4, - map_flags: 5 + map_flags: 5, + id: 0, + pinning: 0 }) )); } @@ -642,7 +648,9 @@ mod tests { key_size: 2, value_size: 3, max_entries: 4, - map_flags: 5 + map_flags: 5, + id: 0, + pinning: 0 }) ), "foo" @@ -656,6 +664,8 @@ mod tests { value_size: 3, max_entries: 4, map_flags: 5, + id: 0, + pinning: 0 }, data }) if name == "foo" && data.is_empty() @@ -682,6 +692,8 @@ mod tests { value_size, max_entries: 1, map_flags: 0, + id: 0, + pinning: 0 }, data }) if name == ".bss" && data == map_data && value_size == map_data.len() as u32 @@ -743,7 +755,9 @@ mod tests { key_size: 2, value_size: 3, max_entries: 4, - map_flags: 5 + map_flags: 5, + id: 0, + pinning: 0 }) ),), Ok(())