Skip to content

Add get key_size and value_size for OpenMapImpl #1382

@fkcrazy001

Description

@fkcrazy001

Currently there is no way to get a map's key_size and value_size from OpenMapImpl. This makes it difficult to use libbpf-rs as a “parser-only” library.

There is a valid use case where people only want to use libbpf-rs to open eBPF object files and extract metadata (programs, maps, etc.), without actually loading/attaching them to the kernel. For example, a custom eBPF map implementation + uBPF could be used to run eBPF programs entirely in userspace. In that scenario, we need access to map metadata such as key_size and value_size in order to recreate the maps on the userspace side.

Right now, some of the APIs needed for this are not exposed. I have a local vendored version where I implemented this functionality myself, but I would like to propose adding an official API for it.

My suggestion is:

  • Expose map metadata (at least key_size and value_size, and possibly other fields like flags) from OpenMapImpl or from a related public type.
  • Ensure that these fields can be queried before any actual kernel loading/attachment happens, so libbpf-rs can be used purely as a parser/inspector for eBPF object files.

Would this be something you’d consider supporting? I think this just requires adding some wrapper of libbpf c apis in Rust

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions