Skip to content

netfilter: share one hook among the instances of a percpu script - #777

Closed
lneto wants to merge 3 commits into
masterfrom
claude_netfilter_percpu
Closed

netfilter: share one hook among the instances of a percpu script#777
lneto wants to merge 3 commits into
masterfrom
claude_netfilter_percpu

Conversation

@lneto

@lneto lneto commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

On master, with the percpu object (#772), the runner (#762) and the lookup (#780) merged: a percpu script registers one netfilter hook, shared by its instances.

netfilter.register refused a percpu instance because each instance would have registered its own nf_hook_ops and every packet would have been handled once per instance. The hook now belongs to the object the instances share: the first registration of a pf, hooknum and priority installs it, with the percpu object as the runtime, so lunatik_run resolves the instance of the CPU the packet arrived on; the others attach their callbacks, each found through its own registry by the hook they share. The hook goes with the last registration. A plain runtime registers as before, one hook per call, and a second registration of the same hook in one instance is refused. Exactly-once is structural: there is one hook.

The first commit gives an instance the object that owns it, next to its CPU id in the state, which is what lets a binding register for the object rather than the instance.

Tests: tests/runtime/percpu_netfilter counts marked ping requests through the shared hook with the ping pinned to the last online CPU, where the loopback delivers it: exactly COUNT, on the instance of that CPU; the duplicate registration; the plain runtime. With one hook per instance, as before, every instance counts the requests and the case fails; a hook that fires for an instance that did not register it is a failure too. The netfilter cases leave percpu_refuse, which keeps device.new.

Tested on 6.8.0-136 and, after a host reboot, 6.8.0-138 (aarch64): runtime, skb, xdp and tc suites, clean dmesg. The fixup adds the mark to the identity of a shared hook, so instances registering different marks get different hooks.

🤖 Generated with Claude Code

@lneto
lneto force-pushed the claude_ebpf_lookup branch from 23546c4 to de7f47c Compare September 4, 2026 02:04
@lneto
lneto force-pushed the claude_netfilter_percpu branch from 2e21b8d to 4f69039 Compare September 4, 2026 02:04
@lneto
lneto force-pushed the claude_ebpf_lookup branch from de7f47c to 95b281f Compare September 4, 2026 11:59
@lneto
lneto force-pushed the claude_netfilter_percpu branch 2 times, most recently from 40d44ef to cc46494 Compare September 4, 2026 12:02
@lneto
lneto force-pushed the claude_ebpf_lookup branch 2 times, most recently from 68fe207 to 7eb2ac8 Compare September 4, 2026 12:04
@lneto
lneto force-pushed the claude_netfilter_percpu branch 2 times, most recently from ff55f15 to df79884 Compare September 4, 2026 12:07
@lneto
lneto force-pushed the claude_ebpf_lookup branch from 7eb2ac8 to 02daea2 Compare September 4, 2026 12:07
@lneto
lneto force-pushed the claude_netfilter_percpu branch from df79884 to 28afdbf Compare September 4, 2026 12:37
@lneto
lneto force-pushed the claude_ebpf_lookup branch from 02daea2 to efd5c5f Compare September 4, 2026 12:37
@lneto
lneto force-pushed the claude_netfilter_percpu branch from 28afdbf to 3f96fbd Compare September 4, 2026 12:45
@lneto
lneto force-pushed the claude_ebpf_lookup branch from efd5c5f to 55c0516 Compare September 4, 2026 12:45
@lneto
lneto force-pushed the claude_netfilter_percpu branch from 3f96fbd to ed2dcab Compare September 4, 2026 12:50
@lneto
lneto force-pushed the claude_ebpf_lookup branch from 55c0516 to 969ffff Compare September 4, 2026 12:50
@lneto
lneto force-pushed the claude_netfilter_percpu branch from ed2dcab to 075cacd Compare September 4, 2026 13:18
@lneto
lneto force-pushed the claude_ebpf_lookup branch 2 times, most recently from 1e79602 to 7a8d7a2 Compare September 4, 2026 13:19
@lneto
lneto force-pushed the claude_netfilter_percpu branch 2 times, most recently from 7dbded9 to e574a75 Compare September 4, 2026 13:20
@lneto
lneto force-pushed the claude_ebpf_lookup branch from 7a8d7a2 to b2cce07 Compare September 4, 2026 13:20
@lneto
lneto force-pushed the claude_netfilter_percpu branch from e574a75 to f3ac82a Compare September 4, 2026 14:32
@lneto
lneto force-pushed the claude_ebpf_lookup branch from b2cce07 to c0abebe Compare September 4, 2026 14:32
@lneto
lneto changed the base branch from claude_ebpf_lookup to claude_percpu_object September 4, 2026 14:42
@lneto
lneto force-pushed the claude_netfilter_percpu branch from f3ac82a to 915bcd0 Compare September 4, 2026 14:42
@lneto
lneto force-pushed the claude_percpu_object branch from 138bb43 to 5e477c2 Compare September 4, 2026 14:43
@lneto
lneto force-pushed the claude_netfilter_percpu branch from 915bcd0 to 5e38238 Compare September 4, 2026 14:43
@lneto
lneto changed the base branch from claude_percpu_object to claude_ebpf_lookup September 4, 2026 14:44
@lneto
lneto force-pushed the claude_netfilter_percpu branch from 5e38238 to 6203c0b Compare September 4, 2026 15:04
@lneto
lneto force-pushed the claude_ebpf_lookup branch from c0abebe to db41c49 Compare September 4, 2026 15:04
@lneto
lneto force-pushed the claude_netfilter_percpu branch from 6203c0b to 5dc7acc Compare September 4, 2026 22:38
@lneto
lneto force-pushed the claude_ebpf_lookup branch from db41c49 to 20f2c52 Compare September 4, 2026 22:38
@lneto
lneto force-pushed the claude_netfilter_percpu branch from 5dc7acc to e35b2dd Compare September 4, 2026 22:41
@lneto
lneto force-pushed the claude_ebpf_lookup branch from 20f2c52 to 8d16881 Compare September 4, 2026 22:41
@lneto
lneto force-pushed the claude_netfilter_percpu branch from e35b2dd to 933dc13 Compare September 4, 2026 22:42
@lneto
lneto force-pushed the claude_ebpf_lookup branch from 8d16881 to fba9af6 Compare September 4, 2026 22:42
@lneto
lneto force-pushed the claude_netfilter_percpu branch from 933dc13 to 0fba40f Compare September 4, 2026 22:48
@lneto
lneto force-pushed the claude_ebpf_lookup branch from fba9af6 to 0c4375a Compare September 4, 2026 22:48
lneto and others added 3 commits September 4, 2026 22:49
A binding registering from a percpu instance needs the object the
dispatch resolves, to register once for the object rather than once per
instance. The state carries it next to the CPU id; a plain runtime has
none.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
netfilter.register refused a percpu instance because each instance
would have registered its own nf_hook_ops and every packet would have
been handled once per instance. The hook now belongs to the object the
instances share: the first registration of a pf, hooknum and priority
installs it, with the percpu object as the runtime lunatik_run resolves
to the instance of the CPU the packet arrived on, and the others attach
their callbacks to it, each found through its own registry by the hook
they share. The hook goes with the last registration, and a plain
runtime registers as before, one hook per call.

The refusal in percpu_refuse moves to percpu_netfilter, which counts
marked ping requests through the shared hook: exactly once, by the
instance of the CPU the pinned ping runs on.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@lneto
lneto changed the base branch from claude_ebpf_lookup to master September 4, 2026 22:50
@lneto
lneto force-pushed the claude_netfilter_percpu branch from 0fba40f to 60a73f1 Compare September 4, 2026 22:50
@lneto lneto closed this Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant