Direct Linux BPF_PROG_TEST_RUN execution for loaded eBPF programs.
Executes a loaded program directly inside the kernel with synthetic input packet bytes and returns the raw return code, decoded XDP action, average execution duration in nanoseconds, and modified output packet bytes.
Summary
Functions
Computes the clamped output buffer size matching the NIF allocation rules:
min(1 MiB, max(data_in_size + 256, requested)).
Decodes an integer cgroup_skb return value (1 = :pass, 0 = :drop)
into its symbolic action atom or {:raw, retval}.
Decodes an integer XDP return value into its symbolic action atom or
{:raw, retval} for non-XDP return codes.
Validates and normalizes run/4 options into a map passed to the NIF.
Runs prog_name on loaded object via bpf_prog_test_run_opts.
Types
@type result() :: %{ retval: non_neg_integer(), action: xdp_action(), duration_ns: non_neg_integer(), data_out: binary() }
@type xdp_action() :: :aborted | :drop | :pass | :tx | :redirect | {:raw, non_neg_integer()}
Functions
@spec clamp_data_out_size(non_neg_integer(), non_neg_integer()) :: non_neg_integer()
Computes the clamped output buffer size matching the NIF allocation rules:
min(1 MiB, max(data_in_size + 256, requested)).
@spec decode_cgroup_skb_action(non_neg_integer()) :: :pass | :drop | {:raw, non_neg_integer()}
Decodes an integer cgroup_skb return value (1 = :pass, 0 = :drop)
into its symbolic action atom or {:raw, retval}.
@spec decode_xdp_action(non_neg_integer()) :: xdp_action()
Decodes an integer XDP return value into its symbolic action atom or
{:raw, retval} for non-XDP return codes.
Validates and normalizes run/4 options into a map passed to the NIF.
Runs prog_name on loaded object via bpf_prog_test_run_opts.
Options (keyword list or map):
:repeat- positive integer repetition count (default1):data_out_size- requested output buffer size in bytes (clamped tomax(byte_size(data_in) + 256, requested), capped at 1 MiB):cpu- optional non-negative target CPU index (BPF_F_TEST_RUN_ON_CPU)