MCPcopy
hub / github.com/cilium/ebpf

github.com/cilium/ebpf @v0.22.0 sqlite

repository ↗ · DeepWiki ↗ · release v0.22.0 ↗
3,274 symbols 13,379 edges 405 files 1,358 documented · 41%
README

eBPF

PkgGoDev

HoneyGopher

ebpf-go is a pure Go library that provides utilities for loading, compiling, and debugging eBPF programs. It has minimal external dependencies and is intended to be used in long running processes.

See ebpf.io for complementary projects from the wider eBPF ecosystem.

Getting Started

Please take a look at our Getting Started guide.

Contributions are highly encouraged, as they highlight certain use cases of eBPF and the library, and help shape the future of the project.

Getting Help

The community actively monitors our GitHub Discussions page. Please search for existing threads before starting a new one. Refrain from opening issues on the bug tracker if you're just starting out or if you're not sure if something is a bug in the library code.

Alternatively, join the #ebpf-go channel on Slack if you have other questions regarding the project. Note that this channel is ephemeral and has its history erased past a certain point, which is less helpful for others running into the same problem later.

Packages

This library includes the following packages:

  • asm contains a basic assembler, allowing you to write eBPF assembly instructions directly within your Go code. (You don't need to use this if you prefer to write your eBPF program in C.)
  • cmd/bpf2go allows compiling and embedding eBPF programs written in C within Go code. As well as compiling the C code, it auto-generates Go code for loading and manipulating the eBPF program and map objects.
  • link allows attaching eBPF to various hooks
  • perf allows reading from a PERF_EVENT_ARRAY
  • ringbuf allows reading from a BPF_MAP_TYPE_RINGBUF map
  • features implements the equivalent of bpftool feature probe for discovering BPF-related kernel features using native Go.
  • rlimit provides a convenient API to lift the RLIMIT_MEMLOCK constraint on kernels before 5.11.
  • btf allows reading the BPF Type Format.
  • pin provides APIs for working with pinned objects on bpffs.

Requirements

  • A version of Go that is supported by upstream
  • Linux (amd64, arm64): CI is run against kernel.org LTS releases. >= 4.4 should work but EOL'ed versions are not supported.
  • Windows (amd64): CI is run against Windows Server 2022. Only the latest eBPF for Windows release is supported.
  • Other architectures are best effort. 32bit arches are not supported.

License

MIT

eBPF Gopher

The eBPF honeygopher is based on the Go gopher designed by Renee French.

Extension points exported contracts — how you extend this code

Type (Interface)
Type represents a type described by BTF. A Type has three properties where compared to other Types. Identity: follows [20 …
btf/types.go
Pinner (Interface)
Pinner is an interface implemented by all eBPF objects that support pinning to a bpf virtual filesystem. [6 implementers]
pin/load.go
Info (Interface)
Info is implemented by all structs that can be passed to the ObjInfo syscall. MapInfo ProgInfo LinkInfo BtfInfo To [21 …
internal/sys/syscall.go
FDer (Interface)
FDer represents a resource tied to an underlying file descriptor. Used as a stand-in for e.g. ebpf.Map since that type c [5 …
asm/instruction.go
PerfEvent (Interface)
PerfEvent is implemented by some Link types which use a perf event under the hood. [3 implementers]
link/perf_event.go
Link (Interface)
Link represents a Program attached to a BPF hook. [3 implementers]
link/link.go
Anchor (Interface)
Anchor is a reference to a link or program. It is used to describe where an attachment or detachment should take place [3 …
link/anchor.go
FDer (Interface)
(no doc) [5 implementers]
link/link_test.go

Core symbols most depended-on inside this repo

IsNil
called by 569
internal/sys/ptr.go
Close
called by 390
link/link.go
Is
called by 312
internal/unix/errno_windows.go
Run
called by 209
internal/testutils/testmain/main.go
Error
called by 147
internal/efw/result.go
Pointer
called by 146
internal/sysenc/buffer.go
SkipIfNotSupported
called by 129
internal/testutils/feature.go
Sizeof
called by 109
asm/load_store.go

Shape

Function 1,596
Method 913
Struct 653
TypeAlias 90
Interface 20
FuncType 2

Languages

Go100%
Python1%

Modules by API surface

btf/types.go134 symbols
internal/sys/types.go131 symbols
map.go85 symbols
map_test.go74 symbols
asm/instruction.go60 symbols
btf/btf_types.go57 symbols
btf/ext_info.go48 symbols
internal/unix/types_linux.go47 symbols
elf_reader.go45 symbols
internal/unix/types_other.go43 symbols
prog.go41 symbols
prog_test.go39 symbols

Dependencies from manifests, versioned

github.com/BurntSushi/tomlv1.6.0 · 1×
github.com/containerd/stargz-snapshotter/estargzv0.16.3 · 1×
github.com/davecgh/go-spewv1.1.2-0.20180830191 · 1×
github.com/docker/cliv29.2.0+incompatible · 1×
github.com/docker/distributionv2.8.3+incompatible · 1×
github.com/docker/docker-credential-helpersv0.9.3 · 1×
github.com/go-quicktest/qtv1.101.1-0.202403011 · 1×
github.com/inconshreveable/mousetrapv1.1.0 · 1×
github.com/josharian/nativev1.1.0 · 1×
github.com/jsimonetti/rtnetlink/v2v2.0.1 · 1×

For agents

$ claude mcp add ebpf \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact