From 0a493baed6b4d020ed7d5d87191d912662eb2159 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Wed, 24 Feb 2021 05:57:37 +0000 Subject: [PATCH] aya: add Bpf::maps() to get all the maps --- aya/src/bpf.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/aya/src/bpf.rs b/aya/src/bpf.rs index ea407f4e..aee4be4e 100644 --- a/aya/src/bpf.rs +++ b/aya/src/bpf.rs @@ -183,6 +183,17 @@ impl Bpf { .transpose() } + pub fn maps<'a>(&'a self) -> impl Iterator)> + 'a { + let ret = self.maps.iter().map(|(name, lock)| { + ( + name.as_str(), + lock.try_read() + .map_err(|_| MapError::BorrowError { name: name.clone() }), + ) + }); + ret + } + pub fn program<'a, 'slf: 'a, T: TryFrom<&'a Program>>( &'slf self, name: &str,