Skip to content

luaebpf: name kernel scripts older than the compiler - #41

Open
lneto wants to merge 1 commit into
masterfrom
claude_stale_scripts
Open

lneto wants to merge 1 commit into
masterfrom
claude_stale_scripts

Conversation

@lneto

@lneto lneto commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

A compile against kernel scripts an older Lunatik installed stops at a line of the compiler, as emit/init.lua:280: attempt to index a nil value (field 'max'), which names neither the script nor the directory at fault.

Such a compile now stops at the first table or entry it reads that the scripts lack, and names the script and the directory:

$ lunatik bpf --scripts=staging/lib/modules/lua filter.bpf.lua
lunatik: staging/lib/modules/lua/linux/bpf.lua carries no 'max': the kernel scripts under staging/lib/modules/lua predate the compiler

The way out is the kernel scripts of a Lunatik as new as the compiler, installed or staged under --scripts. A directory that lacks a script altogether keeps today's error, the module not found with the paths searched.

Its tests live in Lunatik's tests/luaebpf/scripts.sh, so they come in a Lunatik pull request opened after this one merges, which moves Lunatik's luaebpf submodule here and is the one that closes the issue this answers.
#9, which it does not close

The compiler reads constants from the kernel scripts, and a tree an
older Lunatik installed, or one --scripts names, that lacks a table or
an entry it reads stopped a compile at a line of the compiler: an index
error at emit/init.lua:280 for a linux/bpf.lua without max, and a
string.pack error at insn.lua:315 for one without func.map_lookup_elem,
or at btf.lua:136 for one without map_type.PERCPU_ARRAY.

luaebpf.proto.script now hands back the script's table with each table
it holds raising at a read of a name it does not carry:

    <script> carries no '<name>': the kernel scripts under <dir> predate the compiler

so the reads a compile takes through it, max, func and map_type of
linux.bpf, default of linux.ratelimit and int of linux.limits, refuse
by name, and so does a read a later compiler adds. The kernel's loader
answers a module that lacks what it was built against the same way, per
symbol and naming it (simplify_symbols, kernel/module/main.c; and
check_version, kernel/module/version.c), and libbpf probes each feature
it uses rather than compare a version; a version stamp compared here
would need Lunatik's install to write one, and a number this tree keeps
by hand.

A script the directory lacks stays not found, with the paths searched,
and the modules of lib/bpf keep reading the kernel scripts through the
body's require.

Part of #9.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lneto lneto added complexity: small One line or one file, with a trivial or existing test workflow-reviewed reviewed end to end by a review workflow labels Nov 26, 2026
@lneto

lneto commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Note

This comment was written by an LLM, not a human.

What the workflow that wrote this pull request held it to, at efe3690.

Build, on Linux 6.8.0-138-generic aarch64: Grand Totals: pass:1344 fail:0 skip:35

  • Examples run: none, since the change touches no example.

Requirements (7 met)

Each requirement, how the diff meets it and the case that shows it
  • met: Update, Contract: "Where a compile reads from a kernel script a table or an entry the script lacks, it raises, with no position of the compiler: <script> carries no '<name>': the kernel scripts under <dir> predate the compiler. <script> is the path the script was found at, <dir> the directory as --scripts or luaebpf.compile was given it, /lib/modules/lua otherwise, and <name> what the compiler read down to the first name the script lacks, max or func.map_lookup_elem. lunatik bpf prints it after lunatik: , exits 1 and writes no object."

    proto.lua:25 holds the message; strict (proto.lua:95-104) gives each table of the script an __index that raises it at level 0 with the path package.searchpath found (proto.lua:116), the name dotted from the script's top and root (proto.lua:46, set at proto.lua:82 from luaebpf.compile's argument, init.lua:113); proto.script returns that table (proto.lua:117). bin/lunatik's pcall prints it after lunatik: and exits 1 before it opens the object.

    Case: None in this repository can: luaebpf has no suite, its cases are Lunatik's tests/luaebpf (AGENTS.md), and the rows come with Lunatik's pull request. Run by hand: lunatik: trees/nomax/linux/bpf.lua carries no 'max': the kernel scripts under trees/nomax predate the compiler and lunatik: trees/nolookup/linux/bpf.lua carries no 'func.map_lookup_elem': ..., exit 1, no object; the base prints emit/init.lua:280: attempt to index a nil value (field 'max') and insn.lua:315: bad argument #5 to 'pack' (number expected, got nil).

  • met: Update, Contract: "The reads are the compile's own, four today, all through luaebpf.proto.script: max.STACK of linux.bpf (emit/init.lua:280), func of linux.bpf and default of linux.ratelimit (emit/frame.lua:540), map_type.PERCPU_ARRAY (emit/frame.lua:558) and int.MAX of linux.limits (emit/forloop.lua:114). Where the check lives, and whether those reads share it, is the implementer's."

    The check lives on the reader, proto.script (proto.lua:117), so the four share it with no call site changed, and errors.lua:25 with them.

    Case: None in this repository can, for the reason above. Run by hand, one tree per name: max, max.STACK, func, func.jiffies64, func.map_lookup_elem, func.trace_printk, default, default.INTERVAL, default.BURST, map_type, map_type.PERCPU_ARRAY, int, int.MAX, each printed in the message with its script. Of these the second pull request's rows cover max and func.map_lookup_elem; the others are the implementer's finding left on luaebpf: kernel scripts older than the compiler stop lunatik bpf at an index error inside the compiler #9.

  • met: Update, Contract: "A script the directory lacks stays not found, with the paths searched, as the guide says of a module the directory lacks. The modules under lib/bpf/ keep reading through the body's require: no tree Lunatik wrote reaches an unnamed error through them."

    proto.script's assert(package.searchpath(...)) is untouched (proto.lua:116), strict is applied to what proto.script loads and not to what the searcher loads for the body's require (proto.lua:85-91), and the diff touches no file under lib/.

    Case: For the body's require, Lunatik's existing row "a module the --scripts directory lacks is not found, and /lib/modules/lua is not read", whose scenario still prints module 'class' not found with the directory's paths under the folded compiler. For the compiler's own read no row exists; by hand a tree without linux/ratelimit.lua prints no file 'trees/noratelimit/linux/ratelimit.lua' and no file 'trees/noratelimit/linux/ratelimit/init.lua', as the base does.

  • met: Update, Contract: ""Predate" holds of what a compile reads today: each constant is in the kernel at v6.6, v7.0, v7.2 and torvalds/linux master (include/linux/filter.h, include/vdso/limits.h, include/linux/ratelimit_types.h, include/uapi/linux/bpf.h), so only the tree's age leaves one out."

    The message says "predate the compiler" (proto.lua:25) and the guide says what the directory takes, "the kernel scripts of the Lunatik the compiler's release names, or of a later one" (doc/guide/08-luaebpf.md:664-665).

    Case: None can: it is a statement about kernel headers, not behaviour of the diff. Read here in the 6.8 tree only (MAX_BPF_STACK, INT_MAX, DEFAULT_RATELIMIT_INTERVAL and _BURST, the four BPF_FUNC ids and BPF_MAP_TYPE_PERCPU_ARRAY are all there); the other releases are the groomer's reading.

  • met: Issue, as the Update restates it: ""where the table is absent, emit.program raises a message that names the kernel scripts directory and says its linux/bpf.lua predates the compiler": emit.program's read of max raises <dir>/linux/bpf.lua carries no 'max': the kernel scripts under <dir> predate the compiler. The script it opens with is that linux/bpf.lua, one of the kernel scripts it says predate the compiler."

    emit.program's read proto.script("linux.bpf").max (emit/init.lua:280) reaches the __index strict set on the script's table (proto.lua:101-103), and the error leaves emit.program as raised.

    Case: None in this repository can; the row is Lunatik's, in the second pull request. Run by hand on a linux/bpf.lua as v5.1 wrote it (map_type and update, no max): lunatik: trees/v51/linux/bpf.lua carries no 'max': the kernel scripts under trees/v51 predate the compiler, exit 1, no object.

  • met: Issue, as the Update restates it: ""with a row in tests/luaebpf/scripts.sh that stages such a file": a row of Lunatik's tests/luaebpf/scripts.sh, where the case lives until tests: the compiler's cases move to a suite of luaebpf's own #33 moves it, stages a linux/bpf.lua with map_type and update and no max; a second stages one without func.map_lookup_elem under a program file that has a stop. Each reads the message, the exit status and that no object was written."

    Not in this diff, as the Update assigns it: the rows are Lunatik's pull request's, the second ("then Lunatik's, which moves the mount to that commit as merged and adds the rows"). This diff adds no row and closes nothing: the commit says Part of #9. and the body ends #9, which it does not close, so the requirement stays owed by that pull request and luaebpf: kernel scripts older than the compiler stop lunatik bpf at an index error inside the compiler #9 stays open until it merges. Marked met for what the Update asks of this pull request, not for the rows themselves.

    Case: None here: scripts.sh is Lunatik's file. Both scenarios the rows will stage were run by hand under the folded compiler and print the message, exit 1 and write no object (the two lines quoted under the first requirement).

  • met: Update: "Two pull requests, since the compiler and its cases are in two repositories: this repository's, the compiler with luaebpf.compile's @raise and the guide page, under #9, which it does not close; then Lunatik's, which moves the mount to that commit as merged and adds the rows, their entry in tests/README.md and a sentence in doc/guide/02-running-scripts.md beside "a module that directory lacks is not found", and closes this issue."

    This pull request is the first: the compiler (proto.lua:25, :94-104, :117), luaebpf.compile's @raise (init.lua:104-106), the guide's paragraph under Messages (doc/guide/08-luaebpf.md:661-665), Part of #9. in the commit and #9, which it does not close as the body's last line. No file of Lunatik's is in it.

    Case: None can: it is a property of the pull request's files and text. ldoc ., run as the docs workflow runs it, exits 0 and renders the @raise and the paragraph.

Matrix, the reviewer's

Each cell with its case, and what no case covers

The matrix, each cell run by hand in this review with the folded compiler staged ahead of the installed one (which is the base, fcd4422, file for file) and lunatik bpf --scripts=<copy of /lib/modules/lua with one name removed>, which opens no device. No cell has a test in this repository: luaebpf has no suite, and the rows are Lunatik's.

Read by what the script lacks, outcome lunatik: <dir>/linux/<script>.lua carries no '<name>': the kernel scripts under <dir> predate the compiler, exit 1, no object, no line of the compiler:

  • emit.program, linux.bpf (emit/init.lua:280): max, max.STACK. Base: emit/init.lua:280 index error.
  • frame.stops, linux.bpf (emit/frame.lua:540, read at :491, :527, :549): func, func.jiffies64, func.map_lookup_elem, func.trace_printk. Base: insn.lua:315 pack error.
  • frame.stops, linux.ratelimit (emit/frame.lua:540, read at :495, :500): default, default.INTERVAL, default.BURST. Base: emit/frame.lua:495 index error or insn.lua:315.
  • frame.counts, linux.bpf (emit/frame.lua:558): map_type, map_type.PERCPU_ARRAY. Base: btf.lua:136 pack error.
  • forloop.iterated, linux.limits (emit/forloop.lua:114): int, int.MAX, under an XDP-only program with a computed for. Base: emit/forloop.lua:114 index error or insn.lua:315.
  • errors.read, linux.errno (errors.lua:25): shares the check; read through proto.script on the installed tree with a name it lacks, which also shows the default directory's message (/lib/modules/lua/linux/errno.lua carries no ...: the kernel scripts under /lib/modules/lua predate the compiler). Not run over pinned maps.

Successes and what stays:

  • current scripts: 30 program files of tests/luaebpf and 4 of tests/xdp and tests/tc write the objects the base writes, with the same output.
  • a name the program does not read: a tree without func.map_lookup_elem compiles a program with no stop.
  • a script the directory lacks (linux/ratelimit.lua): the paths searched, as on the base.
  • the stack-limit row of Lunatik's scripts.sh ({max = {STACK = 8}}): still refused at the limit; its first row's tree writes the base's object; a module the directory lacks is still not found with the directory's paths.
  • the directory relative, absolute and with a trailing slash: printed as given.
  • a compile in one process after the raise writes the object the first compile wrote.

Out of contract, seen: a script that returns no table stops at a line of proto.lua, as it stopped at emit/init.lua:280 on the base; the twins under lib/bpf on trees Lunatik never wrote.

What this host cannot show: nothing here depends on the running kernel, the change runs in the CLI's Lua. A stale /lib/modules/lua itself was not staged, since the installed tree is shared; that path is root = dir or SCRIPTS (proto.lua:82) and was read through linux.errno only. That each constant is in the kernel at v6.6, v7.0, v7.2 and master is the groomer's reading; here it was read in the 6.8 tree alone (include/linux/filter.h:90, include/vdso/limits.h:8, include/linux/ratelimit_types.h:9-10, include/uapi/linux/bpf.h:930, :5702, :5707, :5819). Lunatik's make, install and suite with the mount at the tip are the Build phase's.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

complexity: small One line or one file, with a trivial or existing test workflow-reviewed reviewed end to end by a review workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant