Struct ProgramData

Source
pub struct ProgramData { /* private fields */ }
Expand description

ProgramData stores information about bpf programs that are loaded and managed by bpfman.

Implementations§

Source§

impl ProgramData

Source

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(())
}
Source

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.
Source

pub fn get_name(&self) -> Result<String, BpfmanError>

Retrieves the name of the program.

§Returns

Returns Result<String, BpfmanError>.

§Errors

This function will return an error if:

  • There is an issue fetching the name from the database.
Source

pub fn get_id(&self) -> Result<u32, BpfmanError>

Retrieves the kernel ID of the program.

§Returns

Returns Result<u32, BpfmanError>.

§Errors

This function will return an error if:

  • There is an issue fetching the ID from the database.
Source

pub fn get_location(&self) -> Result<Location, BpfmanError>

Retrieves the location of the program.

§Returns

Returns Result<Location, BpfmanError>.

§Errors

This function will return an error if:

  • There is an issue fetching the location from the database.
Source

pub fn get_global_data(&self) -> Result<HashMap<String, Vec<u8>>, BpfmanError>

Retrieves the global data of the program.

§Returns

Returns Result<HashMap<String, Vec<u8>>, BpfmanError>.

§Errors

This function will return an error if:

  • There is an issue fetching the global data from the database.
Source

pub fn get_metadata(&self) -> Result<HashMap<String, String>, BpfmanError>

Retrieves the metadata of the program.

§Returns

Returns Result<HashMap<String, String>, BpfmanError>.

§Errors

This function will return an error if:

  • There is an issue fetching the metadata from the database.
Source

pub fn get_map_owner_id(&self) -> Result<Option<u32>, BpfmanError>

Retrieves the owner ID of the map.

§Returns

Returns Result<Option<u32>, BpfmanError>.

§Errors

This function will return an error if:

  • There is an issue fetching the map owner ID from the database.
Source

pub fn get_map_pin_path(&self) -> Result<Option<PathBuf>, BpfmanError>

Retrieves the map pin path.

§Returns

Returns Result<Option<PathBuf>, BpfmanError>.

§Errors

This function will return an error if:

  • There is an issue fetching the map pin path from the database.
Source

pub fn get_maps_used_by(&self) -> Result<Vec<u32>, BpfmanError>

Retrieves the IDs of maps used by the program.

§Returns

Returns Result<Vec<u32>, BpfmanError>.

§Errors

This function will return an error if:

  • There is an issue fetching the maps used by from the database.
Source

pub fn get_kernel_name(&self) -> Result<String, BpfmanError>

Retrieves the name of the program.

§Returns

Returns Result<String, BpfmanError>.

§Errors

This function will return an error if:

  • There is an issue fetching the kernel name from the database.
Source

pub fn get_kernel_program_type(&self) -> Result<u32, BpfmanError>

Retrieves the kernel program type.

§Returns

Returns Result<u32, BpfmanError>.

§Errors

This function will return an error if:

  • There is an issue fetching the kernel program type from the database.
Source

pub fn get_kernel_loaded_at(&self) -> Result<String, BpfmanError>

Retrieves the kernel loaded timestamp.

§Returns

Returns Result<String, BpfmanError>.

§Errors

This function will return an error if:

  • There is an issue fetching the kernel loaded timestamp from the database.
Source

pub fn get_kernel_tag(&self) -> Result<String, BpfmanError>

Retrieves the kernel tag.

§Returns

Returns Result<String, BpfmanError>.

§Errors

This function will return an error if:

  • There is an issue fetching the kernel tag from the database.
Source

pub fn get_kernel_gpl_compatible(&self) -> Result<bool, BpfmanError>

Retrieves whether the kernel is GPL compatible.

§Returns

Returns Result<bool, BpfmanError>.

§Errors

This function will return an error if:

  • There is an issue fetching the kernel GPL compatibility status from the database.
Source

pub fn get_kernel_map_ids(&self) -> Result<Vec<u32>, BpfmanError>

Retrieves the IDs of kernel maps.

§Returns

Returns Result<Vec<u32>, BpfmanError>.

§Errors

This function will return an error if:

  • There is an issue fetching the kernel map IDs from the database.
Source

pub fn get_kernel_btf_id(&self) -> Result<u32, BpfmanError>

Retrieves the BTF ID of the kernel.

§Returns

Returns Result<u32, BpfmanError>.

§Errors

This function will return an error if:

  • There is an issue fetching the kernel BTF ID from the database.
Source

pub fn get_kernel_bytes_xlated(&self) -> Result<u32, BpfmanError>

Retrieves the translated bytes of the kernel program.

§Returns

Returns Result<u32, BpfmanError>.

§Errors

This function will return an error if:

  • There is an issue fetching the kernel translated bytes from the database.
Source

pub fn get_kernel_jited(&self) -> Result<bool, BpfmanError>

Retrieves whether the kernel program is JIT compiled.

§Returns

Returns Result<bool, BpfmanError>.

§Errors

This function will return an error if:

  • There is an issue fetching the kernel JIT status from the database.
Source

pub fn get_kernel_bytes_jited(&self) -> Result<u32, BpfmanError>

Retrieves the JIT compiled bytes of the kernel program.

§Returns

Returns Result<u32, BpfmanError>.

§Errors

This function will return an error if:

  • There is an issue fetching the kernel JIT compiled bytes from the database.
Source

pub fn get_kernel_bytes_memlock(&self) -> Result<u32, BpfmanError>

Retrieves the memory lock bytes of the kernel program.

§Returns

Returns Result<u32, BpfmanError>.

§Errors

This function will return an error if:

  • There is an issue fetching the kernel memory lock bytes from the database.
Source

pub fn get_kernel_verified_insns(&self) -> Result<u32, BpfmanError>

Retrieves the number of verified instructions of the kernel program.

§Returns

Returns Result<u32, BpfmanError>.

§Errors

This function will return an error if:

  • There is an issue fetching the kernel verified instructions count from the database.

Trait Implementations§

Source§

impl Clone for ProgramData

Source§

fn clone(&self) -> ProgramData

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProgramData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,