Options
All
  • Public
  • Public/Protected
  • All
Menu

bpf

Index

Variables

OBJ_NAME_LEN: 16 = 16

Maximum length of object names, in bytes, including NUL terminator. Longer names will be truncated.

libbpfErrnoMessages: {} = ...

mapping of libbpf-specific errno codes to messages

Keep synchronized with deps/libbpf/src/libbpf.h.

Type declaration

  • [errno: number]: string
u32type: TypeConversion<number> = ...

TypeConversion for a single uint32, for convenience

version: string = versions.libbpf

alias of versions.libbpf

versions: { btf: number; kernel: string; libbpf: string; libelf: string } = native.versions

Type declaration

  • btf: number

    supported BTF version

  • kernel: string

    running kernel release

  • libbpf: string

    libbpf version used

  • libelf: string

    libelf version used

Functions

  • Convenience function to create an ARRAY map using createMap and construct a ConvArrayMap instance.

    Type parameters

    • V

    Parameters

    • length: number

      Array size, in items

    • valueSize: number

      Size of each value, in bytes (will be rounded up to a multiple of 8)

    • valueConv: TypeConversion<V>

      Type conversion for values

    • Optional options: MapDefOptional

      Other map options

    Returns ConvArrayMap<V>

    Map instance

  • Create a new eBPF map. It is recommended to use close if you're no longer going to need it at some point.

    Parameters

    Returns MapRef

    MapRef instance, holding a reference to the newly created map, and its actual parameters

  • createMapRef(fd: number, options?: { parameters?: MapDef; transfer?: boolean }): MapRef
  • Given an existing file descriptor pointing to an eBPF map, obtain its information and return a MapRef instance pointing to that map (but creating a duplicate descriptor).

    Note: If parameters is passed, it will be used as a fallback to build the MapRef for kernels older than 4.13. Make sure it's correct. If not passed, the call will fail for older kernels.

    If transfer is true, the passed FD itself is used (taking ownership of it) instead of creating a new FD first. Do this only if the FD isn't being used anywhere else.

    If the file descriptor is invalid, the function throws without taking ownership. Note that there is no way to check whether the FD actually points to an eBPF map, the caller is responsible to check first.

    Parameters

    • fd: number

      file descriptor

    • Optional options: { parameters?: MapDef; transfer?: boolean }

      options

      • Optional parameters?: MapDef
      • Optional transfer?: boolean

    Returns MapRef

    MapRef instance

  • objGet(path: string): number
  • Get a file descriptor (fd) of a pinned eBPF object.

    Since Linux 4.4.

    Parameters

    • path: string

      pinned eBPF object path

    Returns number

    fd file descriptor

Generated using TypeDoc