Repository navigation
Conversation
skb:mark() reads the packet's mark and skb:mark(v) sets it to a value from 0 up to U32_MAX and answers it, as skb:priority does and as the kernel's skb object spells the method (lib/luaskb.c). The context table lowers it to a four-byte load and store of __sk_buff's mark, the field tc_cls_act_is_valid_access lets a TC program write beside priority (net/core/filter.c, read at 6.6 and 6.8): mark is a context field the kernel already offers, so no helper or mechanism of the compiler's own is written for it. A value outside the range is refused where the compiler holds it and stops the program where the program computes it, through the store priority already takes. A program that picks a flow's path hands that choice to policy routing, an ip rule fwmark, and one at tcx ingress leaves its verdict for the netfilter rules that run after it. The guide's example of a refused method becomes skb:connmark(), which the context still does not offer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Note This comment was written by an LLM, not a human. What #29 requires, as the review read the change meeting it:
The matrix the change is held to: This branch holds no test: luaebpf's AGENTS.md puts the compiler's tests in Lunatik's tests/luaebpf. I measured each case by hand, with the branch's tc.lua laid over the installed luaebpf and bpftool on aarch64 6.8. The test that would cover each case is a cell owed by the Lunatik PR. skb:mark() read:
skb:mark(v), v a constant in range:
skb:mark(v), v computed in range:
skb:mark(v), v computed out of range:
skb:mark(-1), skb:mark(1<<32), skb:mark(true):
skb:connmark():
skb.mark = 1:
Second use (tcx ingress on a bridge port, a netfilter rule after it):
What this kernel cannot see: big-endian and x86 JIT lowering of the store. It is a BPF_W context access the verifier rewrites per architecture. Examples: none uses bpf.tc (examples/filter and sniclassify are C), so none was run. |
A compiled TC program cannot set its packet's mark:
bpf.tcrefusesskb:mark()with "the context has no method 'mark'", though the kernel lets a TC program write the mark as it lets it write the priority.A TC program now reads the mark with
skb:mark()and sets it withskb:mark(v), which answers the value it stored, asskb:prioritydoes and as the kernel'sskbobject spells the method. A program that picks a flow's path hands the choice to policy routing, anip rule add fwmark 2 table 2, and one at tcx ingress leaves its verdict in the mark for the netfilter rules that run after it:The value is held to 0 up to 4294967295, as the kernel object holds it: one outside that range is refused at its line when the compiler knows it,
'mark' takes 0 to 4294967295, not -1, and stops the program when the program computes it, which returnsTC_ACT_SHOTand logs "out of bounds". The guide lists the method besideskb:priority, and its example of a refused method becomesskb:connmark(), which the context still does not offer.It needs no kernel past the 6.6 floor: the mark is a field of
__sk_buffthat 6.6 and 6.8 already let a TC program write. No example usesbpf.tc, so none is run for this change. The tests are in Lunatik'stests/luaebpf/and come with the Lunatik pull request that moves itsluaebpf/submodule to this change and closes luaebpf#29.#29, which it does not close