Behaviour for eBPF compiler backends invoked by use MaeBPF, compiler: Module.
defmodule MyCustomCompiler do
@behaviour MaeBPF.Compiler
@impl true
def compile_ir(ir_module, opts) do
MaeBPF.Compiler.Pure.compile_ir(ir_module, opts)
end
end
defmodule MyPolicy do
use MaeBPF, compiler: MyCustomCompiler
xdp :ingress do
default :pass
end
endDefaults to MaeBPF.Compiler.Pure when :compiler is omitted.
Summary
Callbacks
Compiles a %MaeBPF.IR.Module{} into an ELF64 bpfel binary and metadata map.
Types
@type compile_result() :: %{ :elf => binary(), :ir => MaeBPF.IR.Module.t(), optional(:c_source) => String.t(), optional(:source_map) => map(), optional(:insn_counts) => map(), optional(:stack_bytes) => map(), optional(:elapsed_us) => non_neg_integer() }
Callbacks
@callback compile_ir(MaeBPF.IR.Module.t(), keyword()) :: {:ok, compile_result()} | {:error, term()}
Compiles a %MaeBPF.IR.Module{} into an ELF64 bpfel binary and metadata map.