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

Cilium BPF Host-Routing & Path MTU Discovery Invariant Enforcement

Eliminates silent IP packet blackholing, frame truncation, and sporadic TCP reset (RST) storms caused by eBPF FIB host routing bypassing standard kernel IP stack PMTUD handling. Dynamically synchronizes overlay encapsulation overheads, host network device MTUs, and TCP MSS clamping across Kubernetes cloud provider envelopes.

Prohibited Anti-Pattern: Unclamped eBPF Host Routing Over Overlays Causing Silent MTU Blackholing and TCP Resets

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium BPF Host-Routing & Path MTU Discovery Invariant Enforcement - Eliminates silent IP packet blackholing, frame truncation, and sporadic TCP reset (RST) storms caused by eBPF FIB host routing bypassing standard kernel IP stack PMTUD handling. Dynamically synchronizes overlay encapsulation overheads, host network device MTUs, and TCP MSS clamping across Kubernetes cloud provider envelopes.
globs: infra/**/*.ts, cdk/**/*.ts, deploy/**/*.ts, **/cilium*.ts
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-bpf-host-routing-pmtu-guardrail"
---

# Cilium BPF Host-Routing & Path MTU Discovery Invariant Enforcement

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Unclamped eBPF Host Routing Over Overlays Causing Silent MTU Blackholing and TCP Resets

## System Constraints
You are a Principal Systems & DevOps Architect enforcing the Cilium BPF Host-Routing Path MTU Discovery Invariant. You must ensure that whenever eBPF host routing is enabled (`bpf.hostRouting=true`), all cloud fabric MTU constraints, overlay encapsulation overheads (Geneve/VXLAN/WireGuard), and TCP MSS clamping are explicitly reconciled and enforced to avoid packet fragmentation drops.

## Strict Guidelines
- Engineers MUST ALWAYS deduct overlay encapsulation overhead (Geneve/VXLAN: 50 bytes, WireGuard: 60 bytes, IPsec: 62-80 bytes) from host interface MTU when configuring Cilium.
- Engineers MUST NOT enable `bpf.hostRouting=true` without explicitly configuring either host interface auto-detection patterns (`devices`) or explicit MTU overrides matching the cloud provider topology.
- Services MUST enable TCP MSS clamping (`bpf.masquerade=true` and `bpf.hostRouting=true` paired with Cilium MTU configuration) when routing across mixed-MTU fabrics (e.g., AWS 9001 jumbo frames to 1500 cross-VPC or Internet gateways).
- Components NEVER assume default 1500 MTU without querying or asserting the underlying host network provider interface envelope (e.g., GCP 1460 standard MTU, Azure 1500, AWS Jumbo 9001).
- Code SHOULD validate that `autoDirectNodeRoutes=true` or equivalent FIB routing flags do not bypass MTU checks on interfaces where Path MTU Discovery (ICMP Type 3, Code 4 'Fragmentation Needed') is dropped by upstream security groups.

## Bad vs Good Implementations
### Cilium Helm Values Generation via TypeScript (CDK8s/Pulumi)

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Defaulting to 1500 MTU while using Geneve tunneling and BPF host routing creates 1550-byte packets. Because BPF host routing bypasses the standard Linux IP stack slow path, ICMP 'Fragmentation Needed' (Packet Too Big) generation is bypassed or blackholed, causing immediate connection stalls during TLS handshakes or large HTTP transfers.
```typescript
// Flawed: Enables BPF host routing with zero MTU coordination.
// Fails on GCP (1460 MTU) or mixed AWS VPC peering when packets drop silently
// because eBPF bpf_redirect skips netfilter PTB/ICMP NeedFrag handling.
export function getCiliumHelmConfig() {
  return {
    routingMode: 'tunnel',
    tunnelProtocol: 'geneve',
    bpf: {
      hostRouting: true,
      masquerade: true,
    },
    // MTU is left undefined (defaults to 1500), causing 1500 + 50 (Geneve) = 1550 bytes
    // which exceeds physical 1500 MTU, blackholing all large payloads and TLS handshakes
  };
}
```

#### Production Standard (Correct)
> **Standard**: Explicitly calculates pod MTU by subtracting tunneling (50B) and encryption (60B) overheads from the physical interface MTU (e.g., 1460 on GCP -> 1410 MTU; 1500 on AWS standard -> 1450 MTU). Explicitly enables PMTU discovery, defines device binding patterns, and enforces the minimum MTU floor (1280) required for IP transport without fragmentation.
```typescript
// Invariant Compliant: Derives MTU dynamically from cloud network interface constraints,
// subtracts encapsulation overhead, and configures explicit MTU and devices for BPF host routing.
export interface CloudFabricNetworkConfig {
  provider: 'aws' | 'gcp' | 'azure';
  hostInterfaceMtu: number;
  tunnelProtocol: 'geneve' | 'vxlan' | 'native';
  enableEncryption: boolean;
}

export function getCiliumHelmConfig(config: CloudFabricNetworkConfig) {
  const ENCAPSULATION_OVERHEAD_MAP = {
    geneve: 50,
    vxlan: 50,
    native: 0,
  } as const;

  const ENCRYPTION_OVERHEAD = config.enableEncryption ? 60 : 0; // WireGuard overhead
  const totalOverhead = ENCAPSULATION_OVERHEAD_MAP[config.tunnelProtocol] + ENCRYPTION_OVERHEAD;
  const calculatedPodMtu = config.hostInterfaceMtu - totalOverhead;

  if (calculatedPodMtu < 1280) {
    throw new Error(`Calculated Pod MTU (${calculatedPodMtu}) violates IPv6 minimum MTU (1280).`);
  }

  return {
    routingMode: config.tunnelProtocol === 'native' ? 'native' : 'tunnel',
    tunnelProtocol: config.tunnelProtocol === 'native' ? undefined : config.tunnelProtocol,
    autoDirectNodeRoutes: config.tunnelProtocol === 'native',
    mtu: calculatedPodMtu,
    devices: 'eth+ ens+ eno+ enX+',
    bpf: {
      hostRouting: true,
      masquerade: true,
      tproxy: true,
    },
    ipv4: {
      enabled: true,
    },
    enablePMTUDiscovery: true,
  };
}
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Recommended Agent Skills (askills.dev)

Ready-to-use executable skill functions tailored to this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Cilium BPF Host-Routing & Path MTU Discovery Invariant Enforcement

Cilium BPF Host-Routing & Path MTU Discovery Invariant Enforcement defines an industrial-grade behavioral standard for devops engineering. Eliminates silent IP packet blackholing, frame truncation, and sporadic TCP reset (RST) storms caused by eBPF FIB host routing bypassing standard kernel IP stack PMTUD handling. Dynamically synchronizes overlay encapsulation overheads, host network device MTUs, and TCP MSS clamping across Kubernetes cloud provider envelopes. 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: Unclamped eBPF Host Routing Over Overlays Causing Silent MTU Blackholing and TCP Resets 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 DriftUnclamped eBPF Host Routing Over Overlays Causing Silent MTU Blackholing and TCP ResetsCritical
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 ALWAYS deduct overlay encapsulation overhead (Geneve/VXLAN

Engineers MUST ALWAYS deduct overlay encapsulation overhead (Geneve/VXLAN: 50 bytes, WireGuard: 60 bytes, IPsec: 62-80 bytes) from host interface MTU when configuring Cilium.

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 NOT enable `bpf.hostRouting=true` without explicitly configuring either host interface auto-detection patterns (`devices`) or explicit MTU overrides matching the cloud provider topology.

Engineers MUST NOT enable `bpf.hostRouting=true` without explicitly configuring either host interface auto-detection patterns (`devices`) or explicit MTU overrides matching the cloud provider topology.

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

Services MUST enable TCP MSS clamping (`bpf.masquerade=true` and `bpf.hostRouting=true` paired with Cilium MTU configuration) when routing across mixed-MTU fabrics (e.g., AWS 9001 jumbo frames to 1500 cross-VPC or Internet gateways).

Services MUST enable TCP MSS clamping (`bpf.masquerade=true` and `bpf.hostRouting=true` paired with Cilium MTU configuration) when routing across mixed-MTU fabrics (e.g., AWS 9001 jumbo frames to 1500 cross-VPC or Internet gateways).

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

Components NEVER assume default 1500 MTU without querying or asserting the underlying host network provider interface envelope (e.g., GCP 1460 standard MTU, Azure 1500, AWS Jumbo 9001).

Components NEVER assume default 1500 MTU without querying or asserting the underlying host network provider interface envelope (e.g., GCP 1460 standard MTU, Azure 1500, AWS Jumbo 9001).

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

Code SHOULD validate that `autoDirectNodeRoutes=true` or equivalent FIB routing flags do not bypass MTU checks on interfaces where Path MTU Discovery (ICMP Type 3, Code 4 'Fragmentation Needed') is dropped by upstream security groups.

Code SHOULD validate that `autoDirectNodeRoutes=true` or equivalent FIB routing flags do not bypass MTU checks on interfaces where Path MTU Discovery (ICMP Type 3, Code 4 'Fragmentation Needed') is dropped by upstream security groups.

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 BPF Host-Routing & Path MTU Discovery Invariant Enforcement critical for AI coding assistants?

Eliminates silent IP packet blackholing, frame truncation, and sporadic TCP reset (RST) storms caused by eBPF FIB host routing bypassing standard kernel IP stack PMTUD handling. Dynamically synchronizes overlay encapsulation overheads, host network device MTUs, and TCP MSS clamping across Kubernetes cloud provider envelopes. 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 (Unclamped eBPF Host Routing Over Overlays Causing Silent MTU Blackholing and TCP Resets) 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