feat(sysctl): typed @sysctl global variables#20
Open
congwang-mk wants to merge 14 commits intomainfrom
Open
Conversation
Signed-off-by: Cong Wang <cwang@multikernel.io>
Signed-off-by: Cong Wang <cwang@multikernel.io>
Signed-off-by: Cong Wang <cwang@multikernel.io>
Signed-off-by: Cong Wang <cwang@multikernel.io>
Signed-off-by: Cong Wang <cwang@multikernel.io>
Signed-off-by: Cong Wang <cwang@multikernel.io>
Signed-off-by: Cong Wang <cwang@multikernel.io>
Signed-off-by: Cong Wang <cwang@multikernel.io>
Signed-off-by: Cong Wang <cwang@multikernel.io>
Signed-off-by: Cong Wang <cwang@multikernel.io>
Signed-off-by: Cong Wang <cwang@multikernel.io>
igned-off-by: Cong Wang <cwang@multikernel.io>
Signed-off-by: Cong Wang <cwang@multikernel.io>
Signed-off-by: Cong Wang <cwang@multikernel.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
@sysctl("dotted.path") var name: Tattribute that turns userspace global variable reads/writes into/proc/sys/...file I/O. The handle is fully imperative — the user controls when each access happens, no auto-apply, no auto-restore — and is rejected at compile time from@xdp / @tc / @probe / @tracepoint / @helper / @kfunccontexts (no filesystem there). Supports integer types,bool, andstr(N); the eBPF and kernel-module outputs do not contain sysctl globals.Spec:
SPEC.md§3.3.7. Example:examples/sysctl_demo.ks(verified end-to-end on Linux — readkernel.hostname, format prints, write back). Forward-compatible with a future@sysctl(create=true)for kernel-module-declared sysctls; eBPF cgroup-sysctl interception (BPF_PROG_TYPE_CGROUP_SYSCTL) is intentionally out of scope.The PR also lands one ancillary fix in the userspace string-assignment template: the
strcpy/strncpytemplate referenced its source three times, which is harmless for plain locals but caused side-effecting sysctl reads to be invoked three times pervar s: str(N) = strSysctl. Source is now bound to a__srclocal first.Test plan
dune runtestis green (20 sysctl tests + the rest of the suite, no regressions).examples/sysctl_demo.kson a Linux host (requires root for the eBPF stub program; readingkernel.hostnameworked on a Pop_OS box during development — setshostnametoedge-01, so revert withsudo hostname <original>afterwards).@sysctlaccess from@xdp / @tc / @probe / @tracepoint / @helper / @kfuncproduces the userspace-only compile error.*.ebpf.cfor any sample with sysctl globals — they must not appear there.🤖 Generated with Claude Code