BpfMapInfo

Struct BpfMapInfo 

Source
pub struct BpfMapInfo {
Show 14 fields pub map_pa: u64, pub map_kva: u64, pub name_bytes: [u8; 16], pub name_len: u8, pub map_type: u32, pub map_flags: u32, pub key_size: u32, pub value_size: u32, pub max_entries: u32, pub value_kva: Option<u64>, pub btf_kva: u64, pub btf_value_type_id: u32, pub btf_vmlinux_value_type_id: u32, pub btf_key_type_id: u32,
}
Expand description

Discovered BPF map metadata and value location.

Fields§

§map_pa: u64

Guest physical address of the struct bpf_map.

§map_kva: u64

Guest KVA of the struct bpf_map (or containing struct like bpf_array/bpf_htab). Needed for hash map iteration to read bpf_htab fields relative to this base.

§name_bytes: [u8; 16]

Map name as raw bytes (kernel bpf_map.name), null-padded to BPF_OBJ_NAME_LEN. The active prefix length is in Self::name_len; use Self::name for a &str view. Holding the bytes inline avoids a per-map heap allocation on the freeze hot path.

§name_len: u8

Active byte length of Self::name_bytes. Offset of the first NUL byte; BPF_OBJ_NAME_LEN is the upper bound but every kernel-registered map name is NUL-terminated within the BPF_OBJ_NAME_LEN-byte field. The kernel’s bpf_obj_name_cpy (kernel/bpf/syscall.c) memsets the destination to zero before copying and rejects names whose source bytes fill the field without a NUL — see the if (src == end) return -EINVAL; guard. So name_len is strictly less than BPF_OBJ_NAME_LEN in practice; the unwrap_or(BPF_OBJ_NAME_LEN) fallback in find_all_bpf_maps is defense-in-depth against a corrupted guest read, not a shape the kernel itself produces.

§map_type: u32

map_type field value.

§map_flags: u32

map_flags field value.

§key_size: u32

key_size field value.

§value_size: u32

value_size field value — the size of ONE entry’s value. For BPF_MAP_TYPE_ARRAY the kernel’s per-entry stride is array->elem_size = round_up(value_size, 8) (kernel/bpf/arraymap.c:93) and the value region spans max_entries * elem_size; a multi-entry ARRAY is read one entry at a time via BpfMapAccessor::read_array, not as a single value_size-byte buffer.

§max_entries: u32

max_entries field value.

§value_kva: Option<u64>

Guest KVA of the map’s value region (entry 0). Some(kva) when the renderer can read an entry starting at this address; None when the map type requires a different walker (hash iteration, arena page snapshot, …) or the kva resolution failed.

Populated for:

  • BPF_MAP_TYPE_ARRAY — points at bpf_array.value (the inline flex array, entry 0). A single-entry ARRAY (max_entries <= 1, incl. .bss/.data/.rodata) reads value_size bytes via BpfMapAccessor::read_value; a multi-entry ARRAY reads entry k at value_kva + k * round_up(value_size, 8) via BpfMapAccessor::read_array.
  • BPF_MAP_TYPE_STRUCT_OPS — points at kvalue.data (the embedded registered struct’s bytes, after the bpf_struct_ops_common_value header). Renderer reads value_size - data_off bytes to match the size of the btf_value_type_id type, which describes the data payload only. None when struct_ops BTF offsets are unresolved.
§btf_kva: u64

Guest KVA of the map’s struct btf (guest-memory backend), or btf_id cast to u64 (live-host backend reading via the bpf(2) syscall: BPF_OBJ_GET_INFO_BY_FD returns btf_id, not a kernel pointer). The dump path treats the value as opaque — only btf_kva == 0 is meaningful (no BTF associated with this map). Backend-specific consumers cast to the shape they need. 0 if the map has no BTF.

§btf_value_type_id: u32

BTF type ID for the map’s value type. 0 if the map has no BTF.

§btf_vmlinux_value_type_id: u32

BTF type ID for the kernel-side bpf_struct_ops_<name> wrapper in vmlinux BTF, populated for BPF_MAP_TYPE_STRUCT_OPS maps. libbpf zeros btf_value_type_id for STRUCT_OPS and passes the wrapper id via the kernel-only btf_vmlinux_value_type_id field on struct bpf_map. The dump path uses it to BTF-render the data payload by walking the wrapper’s data member to the per-ops struct (e.g. sched_ext_ops). Zero on every other map type.

§btf_key_type_id: u32

BTF type ID for the map’s key type. 0 when the map’s BTF is missing or the map type does not record a key type id (most ARRAY-family maps store a synthetic __u32 key implicitly). HASH maps populate this so the dump path can render keys via BTF instead of falling back to hex.

Implementations§

Source§

impl BpfMapInfo

Source

pub fn name_bytes_active(&self) -> &[u8]

Active name bytes: &name_bytes[..name_len].

Source

pub fn name(&self) -> Cow<'_, str>

Map name as a &str view over Self::name_bytes. Lossily renders any non-UTF-8 bytes via String::from_utf8_lossy, allocating only when the active region contains invalid UTF-8. Most kernel-registered names are ASCII so the common path is alloc-free.

Trait Implementations§

Source§

impl Clone for BpfMapInfo

Source§

fn clone(&self) -> BpfMapInfo

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 BpfMapInfo

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for BpfMapInfo

Source§

fn default() -> BpfMapInfo

Returns the “default value” for a type. Read more
Source§

impl Display for BpfMapInfo

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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

§

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
§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSend for T
where T: Send,