@@ -1,9 +1,9 @@
|
||||
pub mod alloc;
|
||||
pub mod allocator_bump;
|
||||
pub mod bpf_verifier;
|
||||
pub mod helpers;
|
||||
pub mod syscalls;
|
||||
|
||||
use crate::{bpf_verifier::VerifierError, helpers::HelperError};
|
||||
use crate::{bpf_verifier::VerifierError, syscalls::SyscallError};
|
||||
use byteorder::{ByteOrder, LittleEndian, WriteBytesExt};
|
||||
use log::*;
|
||||
use num_derive::{FromPrimitive, ToPrimitive};
|
||||
@@ -50,7 +50,7 @@ pub enum BPFError {
|
||||
#[error("{0}")]
|
||||
VerifierError(#[from] VerifierError),
|
||||
#[error("{0}")]
|
||||
HelperError(#[from] HelperError),
|
||||
SyscallError(#[from] SyscallError),
|
||||
}
|
||||
impl UserDefinedError for BPFError {}
|
||||
|
||||
@@ -60,7 +60,7 @@ pub fn create_vm(prog: &[u8]) -> Result<(EbpfVm<BPFError>, MemoryRegion), EbpfEr
|
||||
vm.set_max_instruction_count(100_000)?;
|
||||
vm.set_elf(&prog)?;
|
||||
|
||||
let heap_region = helpers::register_helpers(&mut vm)?;
|
||||
let heap_region = syscalls::register_syscalls(&mut vm)?;
|
||||
|
||||
Ok((vm, heap_region))
|
||||
}
|
||||
@@ -197,8 +197,8 @@ pub fn process_instruction(
|
||||
Err(error) => {
|
||||
warn!("BPF program failed: {}", error);
|
||||
return match error {
|
||||
EbpfError::UserError(BPFError::HelperError(
|
||||
HelperError::InstructionError(error),
|
||||
EbpfError::UserError(BPFError::SyscallError(
|
||||
SyscallError::InstructionError(error),
|
||||
)) => Err(error),
|
||||
_ => Err(BPFLoaderError::VirtualMachineFailedToRunProgram.into()),
|
||||
};
|
||||
|
Reference in New Issue
Block a user