# pinoogni/ebpf-samples architecture

> Architecture diagram of the GitHub repository pinoogni/ebpf-samples, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pinoogni/ebpf-samples
- Repository: https://github.com/pinoogni/ebpf-samples

## Overview

ebpf-samples is an educational collection of standalone eBPF examples, not a single application. The learner’s workflow is to choose a domain example, run its Go control plane to load and attach a kernel program, then observe counters or other results. XDP, tracepoint, kprobe, TC, program-test, and inspection examples are distinct branches. Sampled code supports specific attach and map-observation relationships; other example internals are represented by their directories because they were not sampled.

Main entry points: [`headers`](https://github.com/pinoogni/ebpf-samples/tree/main/headers) (eBPF headers), [`xdp/example7/main.go`](https://github.com/pinoogni/ebpf-samples/blob/main/xdp/example7/main.go) (XDP controller), [`tracepoint/example7/main.go`](https://github.com/pinoogni/ebpf-samples/blob/main/tracepoint/example7/main.go) (Packet trace controller), [`xdp/example7/xdp.c`](https://github.com/pinoogni/ebpf-samples/blob/main/xdp/example7/xdp.c) (IPv4 counter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_network["Network dataplane"]
  node_xdp_examples["XDP examples"]
  node_xdp_ctl7["XDP controller<br/>[main.go]"]
  node_xdp_prog7["IPv4 counter<br/>[xdp.c]"]
  node_xdp_metrics["XDP metrics<br/>[main.go]"]
  node_tc_examples["TC examples"]
  node_tc_drop["TC dropper<br/>[main.go]"]
  node_tc_classic["Classic BPF filter<br/>[main.go]"]
  node_tc_experiments["TC experiments"]
end

subgraph group_observe["Kernel observation"]
  node_trace_examples["Tracepoint examples"]
  node_trace_ctl7["Packet trace controller<br/>[main.go]"]
  node_trace_prog7["Packet trace programs<br/>[tracepoint.c]"]
  node_kprobe_examples["Kprobe examples"]
end

subgraph group_experiments["Program experiments"]
  node_test_run["BPF test-run"]
  node_program_inspection["Program inspection"]
end

subgraph group_support["Shared definitions"]
  node_headers["eBPF headers"]
  node_common_header["Common definitions<br/>[common.h]"]
  node_endian_header["Endian helpers<br/>[bpf_endian.h]"]
  node_tracing_header["Tracing helpers<br/>[bpf_tracing.h]"]
  node_helper_defs["Helper definitions<br/>[bpf_helper_defs.h]"]
  node_kernel_btf["Kernel BTF types<br/>[vmlinux.h]"]
end

node_learner(("Learner"))
node_kernel(("Linux kernel"))
node_prometheus(("Prometheus endpoint"))

node_learner -->|"explores"| node_xdp_examples
node_learner -->|"explores"| node_tc_examples
node_learner -->|"explores"| node_tc_experiments
node_learner -->|"explores"| node_trace_examples
node_learner -->|"explores"| node_kprobe_examples
node_learner -->|"explores"| node_test_run
node_learner -->|"explores"| node_program_inspection
node_xdp_ctl7 -->|"loads and attaches"| node_xdp_prog7
node_xdp_ctl7 -->|"attaches XDP"| node_kernel
node_xdp_prog7 -->|"counts packets"| node_kernel
node_xdp_ctl7 -->|"reads maps"| node_xdp_prog7
node_xdp_metrics -->|"attaches XDP"| node_kernel
node_xdp_metrics -->|"serves metrics"| node_prometheus
node_tc_drop -->|"attaches TC filter"| node_kernel
node_tc_classic -->|"installs filter"| node_kernel
node_trace_ctl7 -->|"loads and attaches"| node_trace_prog7
node_trace_ctl7 -->|"attaches tracepoints"| node_kernel
node_trace_prog7 -->|"counts packets"| node_kernel
node_trace_ctl7 -->|"reads counter maps"| node_trace_prog7
node_headers -.->|"provides"| node_common_header
node_headers -.->|"provides"| node_endian_header
node_headers -.->|"provides"| node_tracing_header
node_headers -.->|"provides"| node_helper_defs
node_kernel_btf -.->|"describes types"| node_kernel

click node_xdp_examples "https://github.com/pinoogni/ebpf-samples/tree/main/xdp"
click node_xdp_ctl7 "https://github.com/pinoogni/ebpf-samples/blob/main/xdp/example7/main.go"
click node_xdp_prog7 "https://github.com/pinoogni/ebpf-samples/blob/main/xdp/example7/xdp.c"
click node_xdp_metrics "https://github.com/pinoogni/ebpf-samples/blob/main/xdp/example8/main.go"
click node_tc_examples "https://github.com/pinoogni/ebpf-samples/tree/main/tc"
click node_tc_drop "https://github.com/pinoogni/ebpf-samples/blob/main/tc/example3/main.go"
click node_tc_classic "https://github.com/pinoogni/ebpf-samples/blob/main/tc/example3_cBPF/main.go"
click node_tc_experiments "https://github.com/pinoogni/ebpf-samples/tree/main/tc-experiments"
click node_trace_examples "https://github.com/pinoogni/ebpf-samples/tree/main/tracepoint"
click node_trace_ctl7 "https://github.com/pinoogni/ebpf-samples/blob/main/tracepoint/example7/main.go"
click node_trace_prog7 "https://github.com/pinoogni/ebpf-samples/blob/main/tracepoint/example7/tracepoint.c"
click node_kprobe_examples "https://github.com/pinoogni/ebpf-samples/tree/main/kprobe"
click node_test_run "https://github.com/pinoogni/ebpf-samples/tree/main/program_test"
click node_program_inspection "https://github.com/pinoogni/ebpf-samples/tree/main/program_insights"
click node_headers "https://github.com/pinoogni/ebpf-samples/tree/main/headers"
click node_common_header "https://github.com/pinoogni/ebpf-samples/blob/main/headers/common.h"
click node_endian_header "https://github.com/pinoogni/ebpf-samples/blob/main/headers/bpf_endian.h"
click node_tracing_header "https://github.com/pinoogni/ebpf-samples/blob/main/headers/bpf_tracing.h"
click node_helper_defs "https://github.com/pinoogni/ebpf-samples/blob/main/headers/bpf_helper_defs.h"
click node_kernel_btf "https://github.com/pinoogni/ebpf-samples/blob/main/vmlinux/vmlinux.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_xdp_examples,node_xdp_ctl7,node_xdp_prog7,node_xdp_metrics,node_tc_examples,node_tc_drop,node_tc_classic,node_tc_experiments toneBlue
class node_trace_examples,node_trace_ctl7,node_trace_prog7,node_kprobe_examples toneAmber
class node_test_run,node_program_inspection toneMint
class node_headers,node_common_header,node_endian_header,node_tracing_header,node_helper_defs,node_kernel_btf toneRose
class node_learner,node_kernel,node_prometheus toneIndigo
```

## Components

### Network dataplane

- [XDP examples](https://github.com/pinoogni/ebpf-samples/tree/main/xdp): `xdp`
- [XDP controller](https://github.com/pinoogni/ebpf-samples/blob/main/xdp/example7/main.go): `xdp/example7/main.go`
- [IPv4 counter](https://github.com/pinoogni/ebpf-samples/blob/main/xdp/example7/xdp.c): `xdp/example7/xdp.c`
- [XDP metrics](https://github.com/pinoogni/ebpf-samples/blob/main/xdp/example8/main.go): `xdp/example8/main.go`
- [TC examples](https://github.com/pinoogni/ebpf-samples/tree/main/tc): `tc`
- [TC dropper](https://github.com/pinoogni/ebpf-samples/blob/main/tc/example3/main.go): `tc/example3/main.go`
- [Classic BPF filter](https://github.com/pinoogni/ebpf-samples/blob/main/tc/example3_cBPF/main.go): `tc/example3_cBPF/main.go`
- [TC experiments](https://github.com/pinoogni/ebpf-samples/tree/main/tc-experiments): `tc-experiments`

### Kernel observation

- [Tracepoint examples](https://github.com/pinoogni/ebpf-samples/tree/main/tracepoint): `tracepoint`
- [Packet trace controller](https://github.com/pinoogni/ebpf-samples/blob/main/tracepoint/example7/main.go): `tracepoint/example7/main.go`
- [Packet trace programs](https://github.com/pinoogni/ebpf-samples/blob/main/tracepoint/example7/tracepoint.c): `tracepoint/example7/tracepoint.c`
- [Kprobe examples](https://github.com/pinoogni/ebpf-samples/tree/main/kprobe): `kprobe`

### Program experiments

- [BPF test-run](https://github.com/pinoogni/ebpf-samples/tree/main/program_test): `program_test`
- [Program inspection](https://github.com/pinoogni/ebpf-samples/tree/main/program_insights): `program_insights`

### Shared definitions

- [eBPF headers](https://github.com/pinoogni/ebpf-samples/tree/main/headers): `headers`
- [Common definitions](https://github.com/pinoogni/ebpf-samples/blob/main/headers/common.h): `headers/common.h`
- [Endian helpers](https://github.com/pinoogni/ebpf-samples/blob/main/headers/bpf_endian.h): `headers/bpf_endian.h`
- [Tracing helpers](https://github.com/pinoogni/ebpf-samples/blob/main/headers/bpf_tracing.h): `headers/bpf_tracing.h`
- [Helper definitions](https://github.com/pinoogni/ebpf-samples/blob/main/headers/bpf_helper_defs.h): `headers/bpf_helper_defs.h`
- [Kernel BTF types](https://github.com/pinoogni/ebpf-samples/blob/main/vmlinux/vmlinux.h): `vmlinux/vmlinux.h`

### Other components

- **Learner**
- **Linux kernel**
- **Prometheus endpoint**

## Connections

- Learner → XDP examples: explores
- Learner → TC examples: explores
- Learner → TC experiments: explores
- Learner → Tracepoint examples: explores
- Learner → Kprobe examples: explores
- Learner → BPF test-run: explores
- Learner → Program inspection: explores
- XDP controller → IPv4 counter: loads and attaches (evidence: `xdp/example7/main.go`)
- XDP controller → Linux kernel: attaches XDP (evidence: `xdp/example7/main.go`)
- IPv4 counter → Linux kernel: counts packets (evidence: `xdp/example7/xdp.c`)
- XDP controller → IPv4 counter: reads maps (evidence: `xdp/example7/main.go`)
- XDP metrics → Linux kernel: attaches XDP (evidence: `xdp/example8/main.go`)
- XDP metrics → Prometheus endpoint: serves metrics (evidence: `xdp/example8/main.go`)
- TC dropper → Linux kernel: attaches TC filter (evidence: `tc/example3/main.go`)
- Classic BPF filter → Linux kernel: installs filter (evidence: `tc/example3_cBPF/main.go`)
- Packet trace controller → Packet trace programs: loads and attaches (evidence: `tracepoint/example7/main.go`)
- Packet trace controller → Linux kernel: attaches tracepoints (evidence: `tracepoint/example7/main.go`)
- Packet trace programs → Linux kernel: counts packets (evidence: `tracepoint/example7/tracepoint.c`)
- Packet trace controller → Packet trace programs: reads counter maps (evidence: `tracepoint/example7/main.go`)
- eBPF headers → Common definitions: provides
- eBPF headers → Endian helpers: provides
- eBPF headers → Tracing helpers: provides
- eBPF headers → Helper definitions: provides
- Kernel BTF types → Linux kernel: describes types
