Repository navigation
Releases
Releases · luainkernel/luaebpf
luaebpf v0.1
The first release of luaebpf, the Lua to eBPF compiler of Lunatik, as it leaves Lunatik's tree for a repository of its own (luainkernel/lunatik#2598). It is experimental: the compiler, the modules a program file's body requires and the part of Lua it compiles may change in a minor release.
Highlights
- A program file is Lua whose functions become XDP and TC programs:
lunatik bpfcompiles it on the host into a BPF object with its BTF, andlunatik run --devattaches it to a device and pins it (luainkernel/lunatik#944, luainkernel/lunatik#2042, luainkernel/lunatik#946). - A compiled function computes what the kernel's Lua computes: integer arithmetic with Lua's semantics, comparisons and branches, the numeric
for, agotoforwards and calls to the functions the file declares; what has no sound lowering is refused at its line (luainkernel/lunatik#2031, luainkernel/lunatik#2033). - A program reads the packet and the kernel's structs by name:
bpf.vmlinuxlays a struct out from the kernel's BTF, and astructcodec's view reads a header's fields, bitfields and big-endian members included, from the packet; a TC program reads a non-linear packet whole (luainkernel/lunatik#2039, luainkernel/lunatik#2663, luainkernel/lunatik#2235). - A program keeps state in the maps its file declares with
bpf.map, shared with Lunatik's kernel scripts, and hands a packet to a kernel script withlunatik.runtime(script):run(...)(luainkernel/lunatik#2043, luainkernel/lunatik#2202). - A check that fails where Lua would raise stops the program: it returns
XDP_ABORTEDorTC_ACT_SHOT, logs<file>:<line>: <reason>to the trace ring, ten lines every five seconds at most, and counts the error at its line, whichlunatik bpf --errors <script>prints (luainkernel/lunatik#2545, luainkernel/lunatik#2692, luainkernel/lunatik#2702).
Requirements
- Lunatik at the commit that mounts this release at
luaebpf/, luainkernel/lunatik@18388fb67 or later, whosemakebuilds the compiler and its loader and whosemake installinstalls them. - libbpf 1.0 or later, which the loader is built against, and the kernel's BTF,
/sys/kernel/btf/vmlinux.
Known issues
- Kernel scripts installed by a Lunatik older than the compiler stop
lunatik bpfat an index error inside the compiler (#9). - A method call in a function of more than 256 constants is refused as a table read (#10).
- A function that compiles past 32767 instructions fails in
string.pack, with a message that names the compiler's file and not the program file's line (#4). - On a big-endian kernel, a struct member typed
__le16,__le32or__le64reads in the kernel's order (#8). - Indexing a value that is not a table is refused naming it "a table" (#6).
Contributors
- Lourival Vieira Neto (@lneto)