remove_program

Function remove_program 

Source
pub async fn remove_program(id: u32) -> Result<(), BpfmanError>
Expand description

Removes an eBPF program specified by its ID.

This function attempts to remove an eBPF program that has been previously loaded by the bpfman tool. It performs the necessary cleanup and removal steps based on the type of program (e.g., XDP, Tc, Tracepoint, Kprobe, etc.).

§Arguments

  • id - A u32 kernel allocated value that uniquely identifies the eBPF program to be removed.

§Returns

  • Result<(), BpfmanError> - Returns Ok(()) if the program is successfully removed, or a BpfmanError if an error occurs during the removal process.

§Errors

This function will return a BpfmanError in the following cases:

  • The program with the given ID does not exist or was not created by bpfman.
  • The program with the given ID is currently in use and cannot be deleted.
  • The program with the given ID has dependent resources that must be deleted first.
  • The user does not have sufficient permissions to delete the program.
  • The program type specified is invalid or unsupported for deletion.
  • The deletion operation encountered a database error.
  • The deletion operation was aborted due to a system timeout or interruption.

§Example

use bpfman::remove_program;

#[tokio::main]
async fn main() {
    match remove_program(42).await {
        Ok(()) => println!("Program successfully removed."),
        Err(e) => eprintln!("Failed to remove program: {:?}", e),
    }
}

§Asynchronous Operation

This function is asynchronous and should be awaited in an asynchronous context.