Repository navigation
Conversation
Detect Linux network namespaces at configure time and add the C helpers used by open/fork/spawn and package net, including unprivileged userns bootstrap, host-uid pin dirs, safe /run/netns mount probing, and an atexit/signal reaper that only runs in the creating process. Signed-off-by: Jafar Al-Gharaibeh <[email protected]>
…spaces
Expose native netns handles through open("j"), close, fork, spawn, and
system, with ns["name"] / key(ns) for status and OptNetns available
outside Graphics builds.
Signed-off-by: Jafar Al-Gharaibeh <[email protected]>
Provide Netns/Link/Veth/Bridge/Vrf/Tun helpers that honor initns via run(), prefer native ns File over ip netns exec, and fall back to ephemeral open when persist fails. Signed-off-by: Jafar Al-Gharaibeh <[email protected]>
Cover native open/peek/fork/spawn/system with forced userns=yes (drop to nobody when root), name-collision behavior, and package-net veth topology; soft-skip when unprivileged. Signed-off-by: Jafar Al-Gharaibeh <[email protected]>
Describe mode "j", join via fork/spawn/system, status peek, unprivileged bootstrap, and package net helpers. Signed-off-by: Jafar Al-Gharaibeh <[email protected]>
Greptile SummaryAdds Linux network-namespace support across the runtime and standard library.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| src/common/rnetns.c | Implements Linux namespace creation, user-namespace bootstrap, secure private pin selection, joining, reference management, and cleanup. |
| src/runtime/fmisc.r | Extends spawn argument handling and synchronizes namespace ownership with co-expression thread creation. |
| src/runtime/rcoexpr.r | Joins a pending namespace before executing co-expression code and routes join failures through thread cleanup. |
| src/runtime/fstruct.r | Adds key iteration for namespace status while using the file mutex shared with close. |
| src/runtime/fsys.r | Integrates namespace handles with open, close, and child-process execution paths. |
| uni/lib/netns.icn | Adds namespace and virtual-link abstractions whose scoped operations use native handles or iproute2. |
| configure.ac | Detects the Linux unshare, setns, and CLONE_NEWNET interfaces needed to enable the feature. |
| tests/posix/netns.icn | Covers namespace creation, status, fork, system, spawn, persistence, bridge setup, and duplicate names. |
| tests/unicon/nettopo.icn | Exercises the higher-level namespace and virtual-network topology helpers. |
Sequence Diagram
sequenceDiagram
participant Program
participant Runtime
participant Namespace
participant Child
Program->>Runtime: open(name, "j")
Runtime->>Namespace: unshare and pin network namespace
Namespace-->>Runtime: namespace handle
Runtime-->>Program: file value
Program->>Runtime: spawn/system/fork(handle, work)
Runtime->>Child: create child process or thread
Child->>Namespace: setns()
Child->>Child: execute requested work
Program->>Runtime: close(handle)
Runtime->>Namespace: release reference and remove pins
Reviews (11): Last reviewed commit: "runtime: Clean up spawn netns join failu..." | Re-trigger Greptile
2cc4bbd to
6b7ec9e
Compare
Add a short Chapter 5 / langref note for open(...,"j") and status peek, and a two-node veth+ping sample under uni/progs. Signed-off-by: Jafar Al-Gharaibeh <[email protected]>
open() already unregisters the thread around sock_listen(); a second decrement around accept() let NARthreads go negative when another thread was in delay(), so GC could collect live TLS open() strings (error 302). Signed-off-by: Jafar Al-Gharaibeh <[email protected]>
903172d to
44527ad
Compare
| * Activate thread x for the first time. | ||
| */ | ||
| /* cp->tstate->K_level = k_level+1;*/ | ||
| CREATE_CE_THREAD(cp, _stks_, "spawn()"); |
There was a problem hiding this comment.
Failed spawn leaks namespace hold
When pthread_create fails during spawn(ns, ce), the namespace reference stored in cp->pending_ns remains held while CREATE_CE_THREAD still marks the co-expression as having a thread. Reclamation then skips the reference, leaving the namespace object and its bind-mount pins allocated and the co-expression associated with a thread that does not exist.
Knowledge Base Used: Interpreter, values, and memory runtime
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/runtime/fmisc.r
Line: 3042
Comment:
**Failed spawn leaks namespace hold**
When `pthread_create` fails during `spawn(ns, ce)`, the namespace reference stored in `cp->pending_ns` remains held while `CREATE_CE_THREAD` still marks the co-expression as having a thread. Reclamation then skips the reference, leaving the namespace object and its bind-mount pins allocated and the co-expression associated with a thread that does not exist.
**Knowledge Base Used:** [Interpreter, values, and memory runtime](https://app.greptile.com/unicon-project/-/custom-context/knowledge-base/uniconproject/unicon/-/docs/runtime-core.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
Yes, this is still an issue. spawn acquires netns_hold() into cp->pending_ns before calling CREATE_CE_THREAD (src/runtime/fmisc.r:3030-3049). If pthread_create() fails, CREATE_CE_THREAD reports the fatal error without returning to spawn, so the new cleanup in src/runtime/rcoexpr.r is never reached. The pending hold is therefore not released via netns_release() on that path. The failure handling needs to unwind cp->pending_ns at the thread-creation site (or inside CREATE_CE_THREAD) before reporting the error; the nctramp cleanup only covers threads that were successfully created.
300f69b to
54086b3
Compare
Join the namespace after SEM_WAIT so NARthreads is already counted and a failed setns() can go through coclean. Undo pushact when a concurrent spawn wins first-create or the ns handle is already closed. Signed-off-by: Jafar Al-Gharaibeh <[email protected]>
No description provided.