e2b-dev / e2b-dev/runtime

RFC: optional eBPF (bpf_sk_assign) egress steering as an alternative to per-slot iptables REDIRECT

Open
#3,085 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
1.6k
Forks
438
PR merge metrics
No merged PRs in 30d

Description

Problem

Egress TCP is steered to the firewall proxy via per-slot nat PREROUTING ... -j REDIRECT --to-ports (3 rules/slot, in the shared nat table). Issues:

  • The nat table is shared host state. Co-tenant software (e.g. Docker) reconciling iptables can reorder or drop these rules, intermittently breaking egress.
  • Original-destination recovery depends on conntrack/DNAT via SO_ORIGINAL_DST.
  • Rule count scales 3×N with sandboxes.

Proposal

Optional, feature-flagged tc/eBPF steering. Default off; iptables REDIRECT stays the default.

  • tc (tcx) eBPF program on each sandbox veth classifies egress TCP by original dst port and bpf_sk_assigns it to the existing firewall listener; marks the skb so policy routing delivers it locally. No DNAT, no per-slot nat rules.
  • Listeners run IP_TRANSPARENT; original dst recovered from LocalAddr().
  • Wired through the existing network.EgressProxy seam (OnSlotCreate/OnSlotDelete).

Benefits

  • Per-interface, orchestrator-owned (tcx) — immune to co-tenant nat churn.
  • Zero per-slot nat rules (one-time host setup instead of 3×N).
  • Original dst from the kernel socket, not conntrack.
  • Clean teardown (detach a link vs. delete rules).

Requirements

  • Kernel: tcx (≥5.16) + bpf_sk_assign (≥5.7) + BTF/CO-RE. Flag gates on support; REDIRECT is the fallback.
  • One-time host setup: ip rule add fwmark 1 lookup 100, a local default route in table 100, and an INPUT allow for mark 1.

Status

Implemented and validated end-to-end: a real sandbox reaches the internet through eBPF steering → transparent proxy → upstream, original dst recovered, zero per-slot REDIRECT rules. PR-ready.

Questions

  1. Interest in an optional eBPF egress path, or is REDIRECT intentionally the only mechanism?
  2. Preferred gating (env flag vs. feature-flags client) and target kernel floor?
  3. Host local-delivery setup (ip rule + table): orchestrator-managed at startup, or a documented prerequisite?

Contributor guide

Open the contributing guide

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.

Research direction

Start by reading the existing network.EgressProxy seam, especially OnSlotCreate and OnSlotDelete, and review how the current per-slot iptables REDIRECT path is wired. Confirm the proposed tc/eBPF path can be feature-gated with REDIRECT as fallback, supports the stated kernel requirements, and performs clean setup and teardown; the remaining questions require maintainer decisions.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, linux
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.