Skip to content

feat(supervisor): replace ip/nsenter netns+veth+route setup with rtnetlink + setns #3281

Description

@akram

Problem Statement

NetworkNamespace::create() (and its teardown) in crates/openshell-supervisor-process/src/netns/mod.rs build the sandbox network namespace, veth pair, addresses, and routes by shelling out to ip — 32 call sites via run_ip / run_ip_netns / run_ip_netns_output — and to nsenter — 9 call sites, used to run ip inside the target namespace. Both binaries are resolved from the workload image (IP_SEARCH_PATHS, NSENTER_SEARCH_PATHS). A bare Alpine image ships only busybox ip (no netns subcommand) and no nsenter equivalent, so setup fails with Network namespace creation failed ... iproute2 is installed.

setns is already a direct syscall for the enter path (8 call sites), so the pattern is established; only namespace/veth/route creation still spawns external binaries.

Proposed Design

Create and configure the namespace entirely through kernel interfaces, with no external process:

  • Namespace: create via unshare(CLONE_NEWNET) in a forked helper (or open + setns), keeping an FD-owned namespace so the /run/netns bind mount is no longer required.
  • veth pair, address assignment, link up/down, routes: route netlink via the rtnetlink crate.
  • Operations "inside" the namespace: enter with setns on the owned FD instead of nsenter.

Acceptance Criteria

  • Network namespace + veth + addressing + routing created with no ip / nsenter process spawned.
  • The /run/netns bind mount is no longer required.
  • Teardown removes the veth/namespace via netlink/syscalls (no ip).
  • Verified on Docker, rootless Podman, and Kubernetes.
  • No behavior change for images that already ship iproute2.

Scope

In: the ip + nsenter network-namespace/veth/route path in netns/mod.rs.
Out: the nft firewall rules (sibling issue) and dmesg→NFLOG bypass monitoring (#2382).

Related

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    state:triage-neededOpened without agent diagnostics and needs triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions