pub struct SockMap<T: Deref<Target = Map>> { /* private fields */ }
Expand description

An array of TCP or UDP sockets.

A SockMap is used to store TCP or UDP sockets. eBPF programs can then be attached to the map to inspect, filter or redirect network buffers on those sockets.

A SockMap can also be used to redirect packets to sockets contained by the map using bpf_redirect_map(), bpf_sk_redirect_map() etc.

Minimum kernel version

The minimum kernel version required to use this feature is 4.14.

Examples

use std::convert::{TryFrom, TryInto};
use aya::maps::SockMap;
use aya::programs::SkSkb;

let intercept_ingress = SockMap::try_from(bpf.map_mut("INTERCEPT_INGRESS")?)?;
let prog: &mut SkSkb = bpf.program_mut("intercept_ingress_packet").unwrap().try_into()?;
prog.load()?;
prog.attach(&intercept_ingress)?;

Implementations

An iterator over the indices of the array that point to a program. The iterator item type is Result<u32, MapError>.

Stores a socket into the map.

Removes the socket stored at index from the map.

Trait Implementations

Returns a Result containg the map fd or an error if there is none

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.