Architectural Invariant Design: Hardware-Offloaded eBPF XDP Invariant for L4 Reflection and Amplification Defense
Hardware-Offloaded eBPF XDP Invariant for L4 Reflection and Amplification Defense defines an industrial-grade behavioral standard for devops engineering. Enforces strict offload-compatible eBPF XDP invariants to intercept and drop UDP-based amplification vectors (e.g., DNS, NTP, Memcached, CLDAP) directly within the NIC RX descriptor ring buffer. Prohibits helper functions, packet mutations, and map architectures that breach hardware offload boundaries or cause fallback to native/generic driver processing. Ensures deterministic wire-rate drop throughput without triggering host network stack overhead or kernel socket allocations. 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 | Executing Non-Offloadable eBPF Operations or Deferring Volumetric L4 Drop Logic to sk_buff Stack Ingress | 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 bounds for every packet header dereference (Ethernet, IPv4/IPv6, UDP) using explicit pointer comparisons against `ctx->data_end` before accessing any payload or header fields.
Engineers MUST ALWAYS verify bounds for every packet header dereference (Ethernet, IPv4/IPv6, UDP) using explicit pointer comparisons against `ctx->data_end` before accessing any payload or header fields.
Engineers MUST NOT utilize BPF helper functions unsupported by SmartNIC hardware offload engines (e.g., `bpf_ktime_get_ns`, dynamic map insertions, `bpf_trace_printk`) inside the critical offload packet path.
Engineers MUST NOT utilize BPF helper functions unsupported by SmartNIC hardware offload engines (e.g., `bpf_ktime_get_ns`, dynamic map insertions, `bpf_trace_printk`) inside the critical offload packet path.
Code MUST restrict map access to offload-supported primitive map types such as `BPF_MAP_TYPE_ARRAY` with `BPF_F_NUMA_NODE` and strictly pre-allocated slots or compile-time constant lookup tables.
Code MUST restrict map access to offload-supported primitive map types such as `BPF_MAP_TYPE_ARRAY` with `BPF_F_NUMA_NODE` and strictly pre-allocated slots or compile-time constant lookup tables.
Services MUST return `XDP_DROP` deterministically for matching reflection signatures (e.g., source port 53/123/11211/389 paired with specific amplification payload thresholds) without modifying packet buffers.
Services MUST return `XDP_DROP` deterministically for matching reflection signatures (e.g., source port 53/123/11211/389 paired with specific amplification payload thresholds) without modifying packet buffers.
Components NEVER fall back silently to `XDP_PASS` or driver-generic mode (`XDP_FLAGS_SKB_MODE`) when handling volumetric amplification floods under offload degradation.
Components NEVER fall back silently to `XDP_PASS` or driver-generic mode (`XDP_FLAGS_SKB_MODE`) when handling volumetric amplification floods under offload degradation.
Frequently Asked Technical Questions
Common questions developers face when configuring AI coding assistants for this stack:
Q:Why is Hardware-Offloaded eBPF XDP Invariant for L4 Reflection and Amplification Defense critical for AI coding assistants?
Enforces strict offload-compatible eBPF XDP invariants to intercept and drop UDP-based amplification vectors (e.g., DNS, NTP, Memcached, CLDAP) directly within the NIC RX descriptor ring buffer. Prohibits helper functions, packet mutations, and map architectures that breach hardware offload boundaries or cause fallback to native/generic driver processing. Ensures deterministic wire-rate drop throughput without triggering host network stack overhead or kernel socket allocations. 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 (Executing Non-Offloadable eBPF Operations or Deferring Volumetric L4 Drop Logic to sk_buff Stack Ingress) 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.