pub struct ProgramData { /* private fields */ }
Expand description
ProgramData stores information about bpf programs that are loaded and managed by bpfman.
Implementations§
Source§impl ProgramData
impl ProgramData
Sourcepub fn new(
location: Location,
name: String,
metadata: HashMap<String, String>,
global_data: HashMap<String, Vec<u8>>,
map_owner_id: Option<u32>,
) -> Result<Self, BpfmanError>
pub fn new( location: Location, name: String, metadata: HashMap<String, String>, global_data: HashMap<String, Vec<u8>>, map_owner_id: Option<u32>, ) -> Result<Self, BpfmanError>
Creates a new ProgramData
instance.
§Arguments
location
- The location of the BPF program (file or image).name
- The name of the BPF program.metadata
- Metadata associated with the BPF program.global_data
- Global data required by the BPF program.map_owner_id
- Optional owner ID of the map.
§Returns
Returns Result<Self, BpfmanError>
- An instance of ProgramData
or a BpfmanError
.
§Errors
This function will return an error if:
- The temporary database cannot be opened.
- The program database tree cannot be opened.
- Any of the subsequent setting operations fail (ID, location, name, metadata, global data, map owner ID).
§Example
use bpfman::types::{Location, ProgramData};
use bpfman::errors::BpfmanError;
use std::collections::HashMap;
fn main() -> Result<(), BpfmanError> {
let location = Location::File(String::from("kprobe.o"));
let metadata = HashMap::new();
let global_data = HashMap::new();
let map_owner_id = None;
let program_data = ProgramData::new(
location,
String::from("kprobe_do_sys_open"),
metadata,
global_data,
map_owner_id
)?;
println!("program_data: {:?}", program_data);
Ok(())
}
Sourcepub fn get_kind(&self) -> Result<Option<ProgramType>, BpfmanError>
pub fn get_kind(&self) -> Result<Option<ProgramType>, BpfmanError>
Retrieves the kind of program, which is represented by the
ProgramType
structure.
§Returns
Returns Result<Option<ProgramType>, BpfmanError>
.
§Errors
This function will return an error if:
- There is an issue fetching the kind from the database.
Sourcepub fn get_name(&self) -> Result<String, BpfmanError>
pub fn get_name(&self) -> Result<String, BpfmanError>
Sourcepub fn get_id(&self) -> Result<u32, BpfmanError>
pub fn get_id(&self) -> Result<u32, BpfmanError>
Sourcepub fn get_location(&self) -> Result<Location, BpfmanError>
pub fn get_location(&self) -> Result<Location, BpfmanError>
Sourcepub fn get_global_data(&self) -> Result<HashMap<String, Vec<u8>>, BpfmanError>
pub fn get_global_data(&self) -> Result<HashMap<String, Vec<u8>>, BpfmanError>
Sourcepub fn get_metadata(&self) -> Result<HashMap<String, String>, BpfmanError>
pub fn get_metadata(&self) -> Result<HashMap<String, String>, BpfmanError>
Sourcepub fn get_map_owner_id(&self) -> Result<Option<u32>, BpfmanError>
pub fn get_map_owner_id(&self) -> Result<Option<u32>, BpfmanError>
Sourcepub fn get_map_pin_path(&self) -> Result<Option<PathBuf>, BpfmanError>
pub fn get_map_pin_path(&self) -> Result<Option<PathBuf>, BpfmanError>
Sourcepub fn get_maps_used_by(&self) -> Result<Vec<u32>, BpfmanError>
pub fn get_maps_used_by(&self) -> Result<Vec<u32>, BpfmanError>
Sourcepub fn get_kernel_name(&self) -> Result<String, BpfmanError>
pub fn get_kernel_name(&self) -> Result<String, BpfmanError>
Sourcepub fn get_kernel_program_type(&self) -> Result<u32, BpfmanError>
pub fn get_kernel_program_type(&self) -> Result<u32, BpfmanError>
Sourcepub fn get_kernel_loaded_at(&self) -> Result<String, BpfmanError>
pub fn get_kernel_loaded_at(&self) -> Result<String, BpfmanError>
Sourcepub fn get_kernel_tag(&self) -> Result<String, BpfmanError>
pub fn get_kernel_tag(&self) -> Result<String, BpfmanError>
Sourcepub fn get_kernel_gpl_compatible(&self) -> Result<bool, BpfmanError>
pub fn get_kernel_gpl_compatible(&self) -> Result<bool, BpfmanError>
Sourcepub fn get_kernel_map_ids(&self) -> Result<Vec<u32>, BpfmanError>
pub fn get_kernel_map_ids(&self) -> Result<Vec<u32>, BpfmanError>
Sourcepub fn get_kernel_btf_id(&self) -> Result<u32, BpfmanError>
pub fn get_kernel_btf_id(&self) -> Result<u32, BpfmanError>
Sourcepub fn get_kernel_bytes_xlated(&self) -> Result<u32, BpfmanError>
pub fn get_kernel_bytes_xlated(&self) -> Result<u32, BpfmanError>
Sourcepub fn get_kernel_jited(&self) -> Result<bool, BpfmanError>
pub fn get_kernel_jited(&self) -> Result<bool, BpfmanError>
Sourcepub fn get_kernel_bytes_jited(&self) -> Result<u32, BpfmanError>
pub fn get_kernel_bytes_jited(&self) -> Result<u32, BpfmanError>
Sourcepub fn get_kernel_bytes_memlock(&self) -> Result<u32, BpfmanError>
pub fn get_kernel_bytes_memlock(&self) -> Result<u32, BpfmanError>
Sourcepub fn get_kernel_verified_insns(&self) -> Result<u32, BpfmanError>
pub fn get_kernel_verified_insns(&self) -> Result<u32, BpfmanError>
Trait Implementations§
Source§impl Clone for ProgramData
impl Clone for ProgramData
Source§fn clone(&self) -> ProgramData
fn clone(&self) -> ProgramData
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for ProgramData
impl !RefUnwindSafe for ProgramData
impl Send for ProgramData
impl Sync for ProgramData
impl Unpin for ProgramData
impl !UnwindSafe for ProgramData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more