Architectural Invariant Design: eBPF XDP Dynamic TCP-MSS Clamping Invariant
eBPF XDP Dynamic TCP-MSS Clamping Invariant defines an industrial-grade behavioral standard for devops engineering. Enforces deterministic, in-kernel TCP Maximum Segment Size (MSS) clamping at the eBPF XDP layer across overlay and WireGuard network interfaces. Guarantees zero PMTU discovery black-holing and eliminates tunnel-induced packet fragmentation by rewriting SYN/SYN-ACK packet options and incrementally updating the TCP checksum before socket allocation. 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 | Relying on ICMP Type 3 Code 4 PMTUD or iptables TCPMSS target across high-throughput overlay topologies | 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 verify packet bounds (`data + offset > data_end`) before dereferencing any byte in IP headers, TCP headers, or TCP options to satisfy the eBPF verifier.
Engineers MUST ALWAYS verify packet bounds (`data + offset > data_end`) before dereferencing any byte in IP headers, TCP headers, or TCP options to satisfy the eBPF verifier.
Engineers MUST rewrite MSS values ONLY when the incoming MSS exceeds the target interface MTU minus fixed IP/TCP encapsulation overheads (e.g., MTU 1420 for WireGuard results in a maximum MSS of 1380 for IPv4 or 1360 for IPv6).
Engineers MUST rewrite MSS values ONLY when the incoming MSS exceeds the target interface MTU minus fixed IP/TCP encapsulation overheads (e.g., MTU 1420 for WireGuard results in a maximum MSS of 1380 for IPv4 or 1360 for IPv6).
Code MUST update the TCP header checksum incrementally using RFC 1624 one's complement arithmetic or `bpf_csum_diff` to maintain wire-speed line rate without traversing the full packet payload.
Code MUST update the TCP header checksum incrementally using RFC 1624 one's complement arithmetic or `bpf_csum_diff` to maintain wire-speed line rate without traversing the full packet payload.
Programs MUST parse TCP options strictly by honoring Option Kind 2 (MSS) with Length 4, safely advancing option pointers through variable-length options and End of Option List (EOL) / No Operation (NOP) delimiters.
Programs MUST parse TCP options strictly by honoring Option Kind 2 (MSS) with Length 4, safely advancing option pointers through variable-length options and End of Option List (EOL) / No Operation (NOP) delimiters.
Components NEVER drop non-SYN packets or packets without an MSS option in the clamping filter
Components NEVER drop non-SYN packets or packets without an MSS option in the clamping filter; all non-matching traffic MUST return `XDP_PASS` immediately.
Services MUST dynamically synchronize overlay MTU constraints to eBPF BPF_MAP_TYPE_ARRAY or BPF_MAP_TYPE_HASH maps without requiring kernel module reloading or program re-attachment.
Services MUST dynamically synchronize overlay MTU constraints to eBPF BPF_MAP_TYPE_ARRAY or BPF_MAP_TYPE_HASH maps without requiring kernel module reloading or program re-attachment.
Frequently Asked Technical Questions
Common questions developers face when configuring AI coding assistants for this stack:
Q:Why is eBPF XDP Dynamic TCP-MSS Clamping Invariant critical for AI coding assistants?
Enforces deterministic, in-kernel TCP Maximum Segment Size (MSS) clamping at the eBPF XDP layer across overlay and WireGuard network interfaces. Guarantees zero PMTU discovery black-holing and eliminates tunnel-induced packet fragmentation by rewriting SYN/SYN-ACK packet options and incrementally updating the TCP checksum before socket allocation. 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 (Relying on ICMP Type 3 Code 4 PMTUD or iptables TCPMSS target across high-throughput overlay topologies) 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.