RFC: optional eBPF (bpf_sk_assign) egress steering as an alternative to per-slot iptables REDIRECT
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
nattable 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-slotnatrules. - Listeners run
IP_TRANSPARENT; original dst recovered fromLocalAddr(). - Wired through the existing
network.EgressProxyseam (OnSlotCreate/OnSlotDelete).
Benefits
- Per-interface, orchestrator-owned (tcx) — immune to co-tenant
natchurn. - Zero per-slot
natrules (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
- Interest in an optional eBPF egress path, or is REDIRECT intentionally the only mechanism?
- Preferred gating (env flag vs. feature-flags client) and target kernel floor?
- Host local-delivery setup (
ip rule+ table): orchestrator-managed at startup, or a documented prerequisite?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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