MaeBPF.Probe (maebpf v0.1.0)

Copy Markdown View Source

Host kernel capability probing, privilege inspection, and human-readable feature diagnostics for Linux eBPF environments.

On non-Linux hosts (such as macOS), capabilities/0 returns a clean supported: false capability map without invoking the Linux NIF.

Summary

Functions

Probes the current host's Linux kernel, BPF feature support, process capabilities, and RLIMIT_MEMLOCK.

Checks whether a probed capability map satisfies the kernel version, feature, privilege, and memory-lock requirements for feature.

Formats a human-readable diagnostic summary for feature against caps.

Parses a Linux CapEff hex bitmask string or full /proc/self/status text and decodes the BPF-relevant capability flags

Parses a Linux uname -r kernel release string into {major, minor, patch}.

Compares two {major, minor, patch} kernel version tuples.

Types

kernel_version()

@type kernel_version() :: {non_neg_integer(), non_neg_integer(), non_neg_integer()}

Functions

capabilities()

@spec capabilities() :: {:ok, map()} | {:error, term()}

Probes the current host's Linux kernel, BPF feature support, process capabilities, and RLIMIT_MEMLOCK.

On non-Linux platforms (such as :darwin), returns {:ok, %{platform: ..., supported: false, ...}}.

check_requirement(caps, feature)

@spec check_requirement(map(), atom()) :: :ok | {:error, String.t()}

Checks whether a probed capability map satisfies the kernel version, feature, privilege, and memory-lock requirements for feature.

Returns :ok if supported or {:error, message} with an actionable remediation string.

format_diagnostic(caps, feature)

@spec format_diagnostic(map(), atom()) :: String.t()

Formats a human-readable diagnostic summary for feature against caps.

Returns "<feature>: supported" when all requirements pass, or a detailed remediation string when one or more checks fail.

parse_cap_eff(input)

@spec parse_cap_eff(binary()) :: {:ok, map()} | {:error, :invalid_cap_eff}

Parses a Linux CapEff hex bitmask string or full /proc/self/status text and decodes the BPF-relevant capability flags:

  • cap_net_admin (CAP_NET_ADMIN, bit 12)
  • cap_sys_admin (CAP_SYS_ADMIN, bit 21)
  • cap_perfmon (CAP_PERFMON, bit 38)
  • cap_bpf (CAP_BPF, bit 39)

parse_kernel_release(release)

@spec parse_kernel_release(binary()) ::
  {:ok, kernel_version()} | {:error, :invalid_kernel_release}

Parses a Linux uname -r kernel release string into {major, minor, patch}.

Examples:

  • "6.18.57-current-rockchip64" -> {:ok, {6, 18, 57}}
  • "5.15.0" -> {:ok, {5, 15, 0}}
  • "6.6" -> {:ok, {6, 6, 0}}

version_at_least?(arg1, arg2)

@spec version_at_least?(kernel_version(), kernel_version()) :: boolean()

Compares two {major, minor, patch} kernel version tuples.