This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: ebpf-tc-ringbuf-drain-drop-telemetry-standard

eBPF TC Ingress RingBuffer Memory Drain & Drop Telemetry Standard

Enforces deterministic memory allocation, power-of-two page-aligned ring buffer sizing, and non-blocking backpressure metrics for eBPF Traffic Control (TC) ingress filters. Guarantees zero silent drop under high-volume L7 DDoS amplification through explicit user-space draining SLAs and per-CPU drop telemetry export.

Prohibited Anti-Pattern: Unbounded or Undersized BPF Ring Buffers with Silent Drops and Missing Drop Counters Under Ingress Spikes

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: eBPF TC Ingress RingBuffer Memory Drain & Drop Telemetry Standard - Enforces deterministic memory allocation, power-of-two page-aligned ring buffer sizing, and non-blocking backpressure metrics for eBPF Traffic Control (TC) ingress filters. Guarantees zero silent drop under high-volume L7 DDoS amplification through explicit user-space draining SLAs and per-CPU drop telemetry export.
globs: **/*.bpf.c, **/*.bpf.h, src/network/**/*.ts, src/telemetry/**/*.ts
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/ebpf-tc-ringbuf-drain-drop-telemetry-standard"
---

# eBPF TC Ingress RingBuffer Memory Drain & Drop Telemetry Standard

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Unbounded or Undersized BPF Ring Buffers with Silent Drops and Missing Drop Counters Under Ingress Spikes

## System Constraints
You are a Principal Systems & SRE Engineer enforcing the eBPF TC Ingress RingBuffer Memory Drain & Drop Telemetry Standard. You mandate power-of-two page-aligned BPF_MAP_TYPE_RINGBUF allocations, non-blocking bpf_ringbuf_reserve() verification, per-CPU drop counter maps, and prioritized user-space polling routines to prevent blind packet loss under burst conditions.

## Strict Guidelines
- Engineers MUST ALWAYS dimension BPF_MAP_TYPE_RINGBUF allocations to a power of two that accommodates maximum ingress burst capacity (e.g., minimum 16MB or 4096 pages) to prevent kernel allocation failures.
- Engineers MUST ALWAYS check the return value of bpf_ringbuf_reserve() and immediately increment a dedicated BPF_MAP_TYPE_PERCPU_ARRAY drop counter when reservation fails due to queue saturation.
- Engineers MUST NOT use legacy BPF_MAP_TYPE_PERF_EVENT_ARRAY for high-throughput packet metadata paths where zero packet loss invariants are required.
- Code SHOULD leverage epoll or dedicated worker threads using ring_buffer__poll() with non-zero timeout and aggressive batch sizes during surge conditions.
- Services MUST export ring buffer utilization metrics (head/tail consumer lag) and drop rates to Prometheus/OTel collectors at sub-second intervals under high traffic.
- Components NEVER drop ingress context or packets silently without emitting monotonically increasing 64-bit kernel telemetry counters.

## Bad vs Good Implementations
### Kernel-side RingBuffer Output with Explicit Drop Accounting

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Allocates inadequate memory (64KB) for burst traffic, fails to check null pointer from bpf_ringbuf_reserve(), and silently discards ring buffer exhaustion events without telemetry.
```c
// ANTI-PATTERN: Undersized ring buffer without drop counters or null-check handling
struct {
    __uint(type, BPF_MAP_TYPE_RINGBUF);
    __uint(max_entries, 64 * 1024); // 64KB: saturated instantaneously during DDoS
} packet_ringbuf SEC(".maps");

SEC("tc")
int handle_tc_ingress(struct __sk_buff *skb) {
    struct event *ev = bpf_ringbuf_reserve(&packet_ringbuf, sizeof(*ev), 0);
    // Missing reservation check causes verifier failure or silent drop
    ev->packet_len = skb->len;
    bpf_ringbuf_submit(ev, 0);
    return 0;
}
```

#### Production Standard (Correct)
> **Standard**: Sizes the ring buffer to 16MB (power of two), safely checks the reservation result, and increments an atomic per-CPU drop counter to ensure absolute drop visibility under DDoS surge conditions.
```c
// PRODUCTION STANDARD: Properly sized ring buffer with Per-CPU drop telemetry
struct {
    __uint(type, BPF_MAP_TYPE_RINGBUF);
    __uint(max_entries, 16 * 1024 * 1024); // 16MB (page-aligned power of two)
} packet_ringbuf SEC(".maps");

struct {
    __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
    __type(key, __u32);
    __type(value, __u64);
    __uint(max_entries, 1);
} ringbuf_drops SEC(".maps");

SEC("tc")
int handle_tc_ingress(struct __sk_buff *skb) {
    __u32 key = 0;
    struct event *ev = bpf_ringbuf_reserve(&packet_ringbuf, sizeof(*ev), 0);
    if (!ev) {
        __u64 *drops = bpf_map_lookup_elem(&ringbuf_drops, &key);
        if (drops) {
            __sync_fetch_and_add(drops, 1);
        }
        return 0; // Return gracefully after recording the drop
    }
    ev->packet_len = skb->len;
    bpf_ringbuf_submit(ev, 0);
    return 0;
}
```

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: eBPF TC Ingress RingBuffer Memory Drain & Drop Telemetry Standard

eBPF TC Ingress RingBuffer Memory Drain & Drop Telemetry Standard defines an industrial-grade behavioral standard for devops engineering. Enforces deterministic memory allocation, power-of-two page-aligned ring buffer sizing, and non-blocking backpressure metrics for eBPF Traffic Control (TC) ingress filters. Guarantees zero silent drop under high-volume L7 DDoS amplification through explicit user-space draining SLAs and per-CPU drop telemetry export. 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: Unbounded or Undersized BPF Ring Buffers with Silent Drops and Missing Drop Counters Under Ingress Spikes 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 DriftUnbounded or Undersized BPF Ring Buffers with Silent Drops and Missing Drop Counters Under Ingress SpikesCritical
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 dimension BPF_MAP_TYPE_RINGBUF allocations to a power of two that accommodates maximum ingress burst capacity (e.g., minimum 16MB or 4096 pages) to prevent kernel allocation failures.

Engineers MUST ALWAYS dimension BPF_MAP_TYPE_RINGBUF allocations to a power of two that accommodates maximum ingress burst capacity (e.g., minimum 16MB or 4096 pages) to prevent kernel allocation failures.

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 ALWAYS check the return value of bpf_ringbuf_reserve() and immediately increment a dedicated BPF_MAP_TYPE_PERCPU_ARRAY drop counter when reservation fails due to queue saturation.

Engineers MUST ALWAYS check the return value of bpf_ringbuf_reserve() and immediately increment a dedicated BPF_MAP_TYPE_PERCPU_ARRAY drop counter when reservation fails due to queue saturation.

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 use legacy BPF_MAP_TYPE_PERF_EVENT_ARRAY for high-throughput packet metadata paths where zero packet loss invariants are required.

Engineers MUST NOT use legacy BPF_MAP_TYPE_PERF_EVENT_ARRAY for high-throughput packet metadata paths where zero packet loss invariants are required.

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

Code SHOULD leverage epoll or dedicated worker threads using ring_buffer__poll() with non-zero timeout and aggressive batch sizes during surge conditions.

Code SHOULD leverage epoll or dedicated worker threads using ring_buffer__poll() with non-zero timeout and aggressive batch sizes during surge conditions.

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

Services MUST export ring buffer utilization metrics (head/tail consumer lag) and drop rates to Prometheus/OTel collectors at sub-second intervals under high traffic.

Services MUST export ring buffer utilization metrics (head/tail consumer lag) and drop rates to Prometheus/OTel collectors at sub-second intervals under high traffic.

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.
6

Components NEVER drop ingress context or packets silently without emitting monotonically increasing 64-bit kernel telemetry counters.

Components NEVER drop ingress context or packets silently without emitting monotonically increasing 64-bit kernel telemetry counters.

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 eBPF TC Ingress RingBuffer Memory Drain & Drop Telemetry Standard critical for AI coding assistants?

Enforces deterministic memory allocation, power-of-two page-aligned ring buffer sizing, and non-blocking backpressure metrics for eBPF Traffic Control (TC) ingress filters. Guarantees zero silent drop under high-volume L7 DDoS amplification through explicit user-space draining SLAs and per-CPU drop telemetry export. 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 (Unbounded or Undersized BPF Ring Buffers with Silent Drops and Missing Drop Counters Under Ingress Spikes) 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

eBPF