This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: cilium-ebpf-host-routing-xdp-transit-invariant

Cilium eBPF Host Routing and Native XDP Transit Verification

Enforces eBPF-based host routing and native XDP acceleration invariants to bypass the Linux kernel netfilter/conntrack stack in dense Kubernetes clusters. Prevents silent fallback to standard TCP/IP network stack processing, guaranteeing deterministic sub-millisecond pod-to-pod and node-to-node overlay latencies.

Prohibited Anti-Pattern: Silent Netfilter Fallback Caused by Misconfigured MTU, Incompatible NIC Driver XDP Modes, or Stale Iptables Masquerading

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium eBPF Host Routing and Native XDP Transit Verification - Enforces eBPF-based host routing and native XDP acceleration invariants to bypass the Linux kernel netfilter/conntrack stack in dense Kubernetes clusters. Prevents silent fallback to standard TCP/IP network stack processing, guaranteeing deterministic sub-millisecond pod-to-pod and node-to-node overlay latencies.
globs: charts/cilium/**/*.yaml, deploy/cilium/**/*.yaml, infrastructure/k8s/cni/**/*.yaml, helm/values*.yaml, manifests/daemonsets/cilium*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-ebpf-host-routing-xdp-transit-invariant"
---

# Cilium eBPF Host Routing and Native XDP Transit Verification

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Silent Netfilter Fallback Caused by Misconfigured MTU, Incompatible NIC Driver XDP Modes, or Stale Iptables Masquerading

## System Constraints
You are a Principal Cloud Native Network Architect specializing in Cilium, eBPF, and high-performance kernel data paths. Mandate explicit eBPF host-routing and native XDP configuration invariants across all Cilium Helm charts and DaemonSet manifests. Reject any infrastructure configuration that permits fallback to generic veth device routing, non-native (generic/SKB) XDP, or netfilter/iptables conntrack traversal.

## Strict Guidelines
- Engineers MUST explicitly set `bpf.hostRouting: true` and `tunnelProtocol: vxlan` or `tunnelProtocol: geneve` (or `routingMode: native`) to bypass Linux netfilter host namespace traversal.
- Engineers MUST set `loadBalancer.mode: dsr` or `loadBalancer.mode: snat` paired with `loadBalancer.acceleration: native` to enforce native XDP processing on supported NIC drivers.
- Engineers MUST NOT configure XDP acceleration mode to `generic` in production, as SKB allocation re-introduces netfilter queuing latency.
- Services MUST enable BPF masquerading (`bpf.masquerade: true`) and explicitly disable legacy iptables masquerading to eliminate iptables conntrack lock contention.
- Engineers MUST enforce MTU alignment across overlay tunnels and XDP headroom by configuring `bpf.autoMountLxcFs: true` and explicit `mtu` offsets accounting for outer IP/UDP/tunnel headers.

## Bad vs Good Implementations
### Cilium Helm Values: Legacy Netfilter Contention vs. Deterministic Native eBPF/XDP Routing

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Disabling `bpf.hostRouting` forces overlay traffic through the Linux kernel's standard TCP/IP networking stack and netfilter conntrack hooks. Setting `acceleration: generic` creates SKBs before XDP execution, generating CPU cache misses and lock contention on high-packet-per-second workloads.
```yaml
# Anti-Pattern: Defaults fall back to iptables masquerading and socket skb queuing
bpf:
  hostRouting: false
  masquerade: false
enableIPv4Masquerade: true
kubeProxyReplacement: "partial"
loadBalancer:
  acceleration: "generic" # Forces SKB allocations, negating XDP line-rate gains
routingMode: "tunnel"
tunnelProtocol: "vxlan"
```

#### Production Standard (Correct)
> **Standard**: Enabling `bpf.hostRouting: true` along with `kubeProxyReplacement: true` allows the tc-eBPF and native XDP programs to redirect packets directly from the NIC ring buffer to the target endpoint veth/socket, totally skipping netfilter and conntrack evaluation.
```yaml
# Production Invariant: Full eBPF host routing bypass with Native XDP offload
kubeProxyReplacement: "true"
bpf:
  hostRouting: true
  masquerade: true
  tproxy: true
enableIPv4Masquerade: false # BPF map manages SNAT without iptables
routingMode: "tunnel"
tunnelProtocol: "vxlan"
loadBalancer:
  mode: "dsr"
  acceleration: "native" # Demands hardware NIC driver native XDP execution
devices: ["eth0", "bond0"] # Explicit native device binding for XDP hooks
pmtuDiscovery:
  enabled: true
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Cilium eBPF Host Routing and Native XDP Transit Verification

Cilium eBPF Host Routing and Native XDP Transit Verification defines an industrial-grade behavioral standard for devops engineering. Enforces eBPF-based host routing and native XDP acceleration invariants to bypass the Linux kernel netfilter/conntrack stack in dense Kubernetes clusters. Prevents silent fallback to standard TCP/IP network stack processing, guaranteeing deterministic sub-millisecond pod-to-pod and node-to-node overlay latencies. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: Silent Netfilter Fallback Caused by Misconfigured MTU, Incompatible NIC Driver XDP Modes, or Stale Iptables Masquerading Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

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 ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftSilent Netfilter Fallback Caused by Misconfigured MTU, Incompatible NIC Driver XDP Modes, or Stale Iptables MasqueradingCritical
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 InconsistencyAI 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.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

Engineers MUST explicitly set `bpf.hostRouting

Engineers MUST explicitly set `bpf.hostRouting: true` and `tunnelProtocol: vxlan` or `tunnelProtocol: geneve` (or `routingMode: native`) to bypass Linux netfilter host namespace traversal.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

Engineers MUST set `loadBalancer.mode

Engineers MUST set `loadBalancer.mode: dsr` or `loadBalancer.mode: snat` paired with `loadBalancer.acceleration: native` to enforce native XDP processing on supported NIC drivers.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

Engineers MUST NOT configure XDP acceleration mode to `generic` in production, as SKB allocation re-introduces netfilter queuing latency.

Engineers MUST NOT configure XDP acceleration mode to `generic` in production, as SKB allocation re-introduces netfilter queuing latency.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

Services MUST enable BPF masquerading (`bpf.masquerade

Services MUST enable BPF masquerading (`bpf.masquerade: true`) and explicitly disable legacy iptables masquerading to eliminate iptables conntrack lock contention.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

Engineers MUST enforce MTU alignment across overlay tunnels and XDP headroom by configuring `bpf.autoMountLxcFs

Engineers MUST enforce MTU alignment across overlay tunnels and XDP headroom by configuring `bpf.autoMountLxcFs: true` and explicit `mtu` offsets accounting for outer IP/UDP/tunnel headers.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is Cilium eBPF Host Routing and Native XDP Transit Verification critical for AI coding assistants?

Enforces eBPF-based host routing and native XDP acceleration invariants to bypass the Linux kernel netfilter/conntrack stack in dense Kubernetes clusters. Prevents silent fallback to standard TCP/IP network stack processing, guaranteeing deterministic sub-millisecond pod-to-pod and node-to-node overlay latencies. 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 (Silent Netfilter Fallback Caused by Misconfigured MTU, Incompatible NIC Driver XDP Modes, or Stale Iptables Masquerading) 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.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

1 Rule in Stack

Cilium