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: u64Guest physical address of the struct bpf_map.
map_kva: u64Guest 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: u8Active 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: u32map_type field value.
map_flags: u32map_flags field value.
key_size: u32key_size field value.
value_size: u32value_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: u32max_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 atbpf_array.value(the inline flex array, entry 0). A single-entry ARRAY (max_entries <= 1, incl..bss/.data/.rodata) readsvalue_sizebytes viaBpfMapAccessor::read_value; a multi-entry ARRAY reads entrykatvalue_kva + k * round_up(value_size, 8)viaBpfMapAccessor::read_array.BPF_MAP_TYPE_STRUCT_OPS— points atkvalue.data(the embedded registered struct’s bytes, after thebpf_struct_ops_common_valueheader). Renderer readsvalue_size - data_offbytes to match the size of thebtf_value_type_idtype, which describes the data payload only.Nonewhen struct_ops BTF offsets are unresolved.
btf_kva: u64Guest 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: u32BTF type ID for the map’s value type. 0 if the map has no BTF.
btf_vmlinux_value_type_id: u32BTF 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: u32BTF 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
impl BpfMapInfo
Sourcepub fn name_bytes_active(&self) -> &[u8] ⓘ
pub fn name_bytes_active(&self) -> &[u8] ⓘ
Active name bytes: &name_bytes[..name_len].
Sourcepub fn name(&self) -> Cow<'_, str>
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
impl Clone for BpfMapInfo
Source§fn clone(&self) -> BpfMapInfo
fn clone(&self) -> BpfMapInfo
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BpfMapInfo
impl Debug for BpfMapInfo
Source§impl Default for BpfMapInfo
impl Default for BpfMapInfo
Source§fn default() -> BpfMapInfo
fn default() -> BpfMapInfo
Auto Trait Implementations§
impl Freeze for BpfMapInfo
impl RefUnwindSafe for BpfMapInfo
impl Send for BpfMapInfo
impl Sync for BpfMapInfo
impl Unpin for BpfMapInfo
impl UnwindSafe for BpfMapInfo
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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