pub struct EbpfFlowMonitor { /* private fields */ }Expand description
Host-side eBPF flow monitor.
Owns the loaded aya BPF object (so it stays alive for the duration of
the cell run — dropping aya::Ebpf detaches all programs) plus the
receiver end of an mpsc channel into which the ring-buffer drainer
task pushes FlowEvents.
Lifecycle:
EbpfFlowMonitor::startenters the cell’s netns, loads + attaches the BPF program, spawns the drainer task, and returns to the original netns.- The supervisor periodically calls
EbpfFlowMonitor::drain(or consumes events directly via the channel) on its hot path. EbpfFlowMonitor::stopaborts the drainer task and drops the aya object, which detaches the BPF program and releases the ring-buffer map.
The struct is constructed only via start; Default is intentionally
not provided to prevent callers from skipping the netns + load
sequence.
Implementations§
Source§impl EbpfFlowMonitor
impl EbpfFlowMonitor
Sourcepub async fn start(
netns_fd: RawFd,
tap_iface: &str,
) -> Result<Self, EbpfMonitorError>
pub async fn start( netns_fd: RawFd, tap_iface: &str, ) -> Result<Self, EbpfMonitorError>
Load and attach the BPF program inside the cell’s netns. Falls
back to nflog (via the caller in per_flow.rs) if any step
fails by returning an EbpfMonitorError.
netns_fd MUST be an open file descriptor for the cell’s
/proc/<child_pid>/ns/net. The caller retains ownership.
tap_iface is the supervisor-provisioned tap interface name
(e.g. "vethC0").
Sourcepub fn drain(&mut self) -> Vec<FlowEvent>
pub fn drain(&mut self) -> Vec<FlowEvent>
Drain pending flow events into a Vec without blocking.
Used by callers that want a synchronous batch pull instead of
.recv().await per event. Returns an empty Vec when no events
are buffered.
Auto Trait Implementations§
impl Freeze for EbpfFlowMonitor
impl RefUnwindSafe for EbpfFlowMonitor
impl Send for EbpfFlowMonitor
impl Sync for EbpfFlowMonitor
impl Unpin for EbpfFlowMonitor
impl UnsafeUnpin for EbpfFlowMonitor
impl UnwindSafe for EbpfFlowMonitor
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more