Architectural Invariant Design: eBPF TC Direct Host Routing & Conntrack Bypass Guardrail
eBPF TC Direct Host Routing & Conntrack Bypass Guardrail defines an industrial-grade behavioral standard for devops engineering. Enforces eBPF direct host routing at the Traffic Control (tc) clsact hook to bypass the netfilter conntrack engine for east-west container traffic. Ensures encapsulation headers, socket translation metadata, and fib_lookup flags are strictly verified to maintain deterministic sub-millisecond p99 latency without dropping stateful packet context. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.
Hazard Analysis: What Breaks Without This Rule
The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:
| Failure Mode | AI Symptom (The Anti-Pattern) | Severity | Production Impact & Remedy |
|---|---|---|---|
| AI Hallucination & Deprecation Drift | Routing Container East-West Traffic Through Netfilter Conntrack Stack and Default Veth Pair Queues | Critical | Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production. Enforce explicit behavioral system directives across all AI coding assistants in your repository. |
| Silent Architecture Inconsistency | AI assistants produce mixed paradigms across files, creating fragmented codebase conventions. | Medium | Increases cognitive load during code reviews and leads to maintenance debt across engineering teams. Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails. |
Step-by-Step Production Directives
Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:
Engineers MUST ALWAYS attach eBPF programs to the `clsact` qdisc egress and ingress hooks on both container veth interfaces and physical host netdevices.
Engineers MUST ALWAYS attach eBPF programs to the `clsact` qdisc egress and ingress hooks on both container veth interfaces and physical host netdevices.
Engineers MUST ALWAYS execute `bpf_fib_lookup()` with `BPF_FIB_LOOKUP_DIRECTNET` to perform direct routing decisions within the eBPF datapath prior to passing skb up the stack.
Engineers MUST ALWAYS execute `bpf_fib_lookup()` with `BPF_FIB_LOOKUP_DIRECTNET` to perform direct routing decisions within the eBPF datapath prior to passing skb up the stack.
Engineers MUST ALWAYS use `bpf_redirect_peer()` for container-to-host veth redirection to avoid queuing packets into the host kernel's per-CPU backlog queue via `netif_rx`.
Engineers MUST ALWAYS use `bpf_redirect_peer()` for container-to-host veth redirection to avoid queuing packets into the host kernel's per-CPU backlog queue via `netif_rx`.
Engineers MUST NOT allow unencapsulated overlay or pod IP packets to enter standard netfilter chains (`PREROUTING`, `FORWARD`) unless explicit legacy L4/L7 inspection is declared.
Engineers MUST NOT allow unencapsulated overlay or pod IP packets to enter standard netfilter chains (`PREROUTING`, `FORWARD`) unless explicit legacy L4/L7 inspection is declared.
Programs MUST validate skb headroom via `bpf_skb_change_head()` and adjust network headers safely before initiating layer 2/3 redirects.
Programs MUST validate skb headroom via `bpf_skb_change_head()` and adjust network headers safely before initiating layer 2/3 redirects.
Kernel configurations MUST verify that `net.ipv4.conf.all.forwarding=1` and `net.core.bpf_jit_enable=1` are asserted by CNI daemonset init containers.
Kernel configurations MUST verify that `net.ipv4.conf.all.forwarding=1` and `net.core.bpf_jit_enable=1` are asserted by CNI daemonset init containers.
Frequently Asked Technical Questions
Common questions developers face when configuring AI coding assistants for this stack:
Q:Why is eBPF TC Direct Host Routing & Conntrack Bypass Guardrail critical for AI coding assistants?
Enforces eBPF direct host routing at the Traffic Control (tc) clsact hook to bypass the netfilter conntrack engine for east-west container traffic. Ensures encapsulation headers, socket translation metadata, and fib_lookup flags are strictly verified to maintain deterministic sub-millisecond p99 latency without dropping stateful packet context. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.
Q:How does adopting this rule prevent AI hallucinations?
This rule explicitly declares what the AI must avoid (Routing Container East-West Traffic Through Netfilter Conntrack Stack and Default Veth Pair Queues) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.
Q:Which AI coding environments are supported?
This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).
Q:Can I combine this rule with other technology stacks?
Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.