bypass4netns-style socket switching (opt-in host network mode)

Open
#16 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
c, linux

Research direction

Start by reading forward_pipe() and the syscall dispatch layer in seccomp-dispatch.c, then trace how socket-related calls and file descriptors are handled. A first version is done when the explicitly opt-in host-bypass mode supports the narrow AF_INET/AF_INET6 SOCK_STREAM outbound-connect scope, applies destination policy controls, and documents the host-network isolation tradeoff and remaining multiplexing limits.

Written by the indexing model from the issue text.

Description

Problem

All network I/O goes through the SLIRP/passt userspace stack. For bulk
transfers, data-path overhead dominates.

Proposed Changes

Add an opt-in --net=host-bypass fast path using SECCOMP_IOCTL_NOTIF_ADDFD
(the same mechanism already used for pipe injection in forward_pipe()):

  1. Intercept socket() + connect() via seccomp for eligible sockets.
  2. Create the socket in the host network namespace, inject via ADDFD.
  3. Subsequent read/write/send/recv go directly to the host kernel
    without supervisor involvement on the data path.

Scope of first version:

  • AF_INET/AF_INET6, SOCK_STREAM, outbound connect() only.
  • Explicitly exclude AF_UNIX, AF_PACKET, raw sockets.
  • Policy controls to restrict which destination addresses/ports are eligible
    for bypass.

Additional syscall interception beyond socket() is required:
connect, bind, listen, accept, setsockopt, getsockopt, and
fcntl on bypassed FDs all need consideration in the dispatch layer
(seccomp-dispatch.c).

Considerations

  • epoll/poll multiplexing: LKL epoll cannot monitor host socket FDs and
    vice versa. Bridging both worlds may require intercepting epoll_ctl and
    epoll_wait to implement a unified event loop. This is the hardest
    architectural challenge and may limit applicability to simple
    connect-send-recv workloads initially.
  • Network isolation tradeoff: the guest operates directly in the host
    network namespace for bypassed sockets. bind() binds to host interfaces,
    getsockname() returns host IPs. This must be explicitly opt-in with
    clear documentation of the security implications.
  • Relationship to passt backend and SLIRP Phase 2 (#12): this is a
    complementary approach. passt improves the stack-mediated path; socket
    switching bypasses the stack entirely for eligible connections.
  • Address-family scope: start narrow (AF_INET/AF_INET6,
    SOCK_STREAM) and expand based on demand.
Dominant language
C
Stars
95
Forks
27
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sysprog21/kbox

All issues in sysprog21/kbox

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.