Ebpf Versions Save

ebpf-go is a pure-Go library to read, modify and load eBPF programs and attach them to various hooks in the Linux kernel.

v0.15.0

3 weeks ago

btf: bpf_core_type_matches is now supported

Programs can now use bpf_core_type_matches() for a stricter compatibility check. See https://github.com/cilium/ebpf/pull/1366.

program, btf: improve debuggability when CO-RE or kfunc fixup fails

The library now tries to return a more informative error when loading a program fails due to a failed CO-RE relocation or a missing kfunc. See https://github.com/cilium/ebpf/pull/1402.

btf: synthesise instruction comments into line info

asm.Comment in an instruction's Source() are now passed to the kernel in the form of BTF line info. See https://github.com/cilium/ebpf/pull/1417.

perf: add WakeupEvents support to Reader

A perf Reader can now be configured to be woken up after a specific number of events / samples have been submitted. See https://github.com/cilium/ebpf/pull/1404.

Bugfixes

  • program: fix loading a program which targets a function in a kernel module when CONFIG_DEBUG_INFO_BTF_MODULES is disabled, see #1440.

Breaking changes

github.com/cilium/ebpf/btf

  • Copy: the transform argument was removed. Use the new btf.As function instead.
  • Transformer: removed. See above.

What's Changed

New Contributors

Full Changelog: https://github.com/cilium/ebpf/compare/v0.14.0...v0.15.0

v0.14.0

1 month ago

btf: support for CO-RE relocations against kernel modules

It's now possible to use CO-RE relocations against types defined in kernel modules. See https://github.com/cilium/ebpf/pull/1300 by @brycekahle.

The link package now allows attaching to netkit interfaces. See https://github.com/cilium/ebpf/pull/1257 by @hemanthmalla

The new link.Iterator type allows enumerating all BPF links active. See https://github.com/cilium/ebpf/pull/1392 by @mpastyl.

Bugfixes

Breaking changes

github.com/cilium/ebpf

  • ProgramOptions is not comparable anymore due to KernelModuleTypes.

github.com/cilium/ebpf/btf

  • CORERelocate had its singature change once again.

What's Changed

New Contributors

Full Changelog: https://github.com/cilium/ebpf/compare/v0.13.2...v0.14.0

v0.13.2

2 months ago

What's Changed

Full Changelog: https://github.com/cilium/ebpf/compare/v0.13.1...v0.13.2

v0.13.1

2 months ago

What's Changed

New Contributors

Full Changelog: https://github.com/cilium/ebpf/compare/v0.13.0...v0.13.1

v0.13.0

3 months ago

Faster btf.LoadKernelSpec()

Obtaining the kernel's BTF used to be very slow and is now very fast. See https://github.com/cilium/ebpf/pull/1235 by @lmb.

TCX

It's now possible to attach TC programs using the new bpf_link based TCX API. See https://github.com/cilium/ebpf/pull/1163 by @lmb.

UprobeMulti and UretprobeMulti

These are the user-space equivalents to KprobeMulti and Kretprobe multi and allow attaching to a large number of symbols quickly. See https://github.com/cilium/ebpf/pull/1269 by @olsajiri.

There is now support to attach Netfilter programs using bpf_links. See https://github.com/cilium/ebpf/pull/1313 by @mehrdadrad.

Better ELF section naming compatibility

The list of recognised ELF section names is now automatically generated from libbpf and should be more accurate and easier to keep up to date. See https://github.com/cilium/ebpf/pull/1209 by @lmb.

Pre-allocate per-CPU values

It's now possible to cut down on allocations by pre-allocating per-CPU values. See https://github.com/cilium/ebpf/pull/1220 by @alxn.

Batch operation support for per-CPU values

Batch operations like Map.BatchLookup now support per-CPU values. Note that this is not particularly optimised, please check whether it is faster based on your use case. See https://github.com/cilium/ebpf/pull/1192 by @alxn.

Breaking changes

This release requires at least Go 1.21.

github.com/cilium/ebpf

  • (*Map).BatchLookup, (*Map).BatchLookupAndDelete: now take a MapBatchCursor. The previous implementation did not properly account for differences between map types and was unsafe.

github.com/cilium/ebpf/btf

  • CORERelocate: now takes an additional argument, which is usually Spec.TypeID.
  • MarshalExtInfos: now takes an additional *Builder instead of allocating it. Simply pass NewBuilder().

Both of these are considered somewhat internal API of the library.

github.com/cilium/ebpf/features

  • HaveBoundedLoops: changed from var to func
  • HaveLargeInstructions: changed from var to func
  • HaveV2ISA: changed from var to func
  • HaveV3ISA: changed from var to func
  • QueryOptions.Path: removed. Instead, pass an fd to the directory via QueryOptions.Target.
  • QueryPrograms: now returns QueryResult to be able to extend the API.
  • RawAttachProgramOptions.Replace: removed. Instead, pass ReplaceProgram() to RawAttachProgramOptions.Anchor.

What's Changed

New Contributors

Full Changelog: https://github.com/cilium/ebpf/compare/v0.12.3...v0.13.0

v0.12.3

6 months ago

This is a small release to fix an incompatibility with golang.org/x/sys/[email protected]. There is a variety of performance improvements as well.

What's Changed

New Contributors

Full Changelog: https://github.com/cilium/ebpf/compare/v0.12.2...v0.12.3

v0.12.2

6 months ago

This release fixes unmarshaling from a map operation into a []byte, see #1180. This is a regression in v0.12.0.

We now also properly return an error when the value to unmarshal into is too small, see #1181. This behaviour has existed for a long time.

What's Changed

New Contributors

Full Changelog: https://github.com/cilium/ebpf/compare/v0.12.1...v0.12.2

v0.12.1

6 months ago

Fixes

Fix ProgramInfo.Instructions failing to decode ExtInfos

A recent change to ProgramInfo.Instructions failed to take a difference between kernel and ELF wire format into account. This meant that retrieving the instructions of a program from the kernel failed with a error.

See #1168, fixed by #1169.

Fix reading auxv on 32-bit platforms

The code to determine the kernel version from vdso has been broken on 32-bit platforms. Note that 32-bit arches are not officially supported to the fix is best effort.

See #1133, fixed by #1144.

What's Changed

Full Changelog: https://github.com/cilium/ebpf/compare/v0.12.0...v0.12.1

v0.12.0

7 months ago

This release requires at least Go 1.20. It is mainly a bugfix release without any expected breaking changes. Map operations have also been made faster on the Go side.

Fixes

Correctly freeze .rodata maps

.rodata maps were frozen after programs referring to them were loaded, preventing the verifier from eliminating dead code based on the contents of the .rodata maps. Upgrade if you're running into odd verifier errors that don't occur on libbpf.

See https://github.com/cilium/ebpf/pull/1159.

Fix fd leak in error path of kfunc support

The library leaked file descriptors when trying to use non-existent kfuncs.

See https://github.com/cilium/ebpf/pull/1145.

Fix incorrect formatting of signed BTF enums with negative values

Signed enums with negative values were incorrectly formatted, leading to invalid output from bpf2go.

See https://github.com/cilium/ebpf/pull/1155.

Additions

Map operations using common types are much faster

Keys and values used in map operations were indiscriminately passed through the encoding/binary package. There is now a fast path which skips this step when the in-memory layout of a type is equivalent to the output produced by binary.Write. The result is less allocations and CPU usage.

The optimization doesn't apply to per-CPU maps.

See https://github.com/cilium/ebpf/pull/1062.

What's Changed

New Contributors

Full Changelog: https://github.com/cilium/ebpf/compare/v0.11.0...v0.12.0

v0.11.0

10 months ago

Breaking changes

This release requires at least Go 1.19.

github.com/cilium/ebpf/btf:

  • Handle.Spec() now takes a base *Spec argument. nil is accepted if the Handle is for vmlinux. If Handle is for a (split BTF) kernel module, pass the result of LoadKernelSpec().
  • NewHandle() now takes a *Builder instead of a *Spec. Loading BTF into the kernel now goes via a new Builder type. See the 'Additions' section below.

github.com/cilium/ebpf/link:

  • KprobeMultiOptions.Addresses: changed from []uint64 to []uintptr The old API didn't take 32-bit architectures into account.

Fixes

Work around the kernel rejecting some Datasec

The kernel erroneously rejects Datasec where a Typedef, Volatile, Const, Restrict or typeTag follows a Pointer, Struct, Union or Array. There is now a workaround in place, see https://github.com/cilium/ebpf/pull/954.

Marshaling Map keys and values is more efficient

The marshaling code in the library now uses sync.Pool to re-use bytes.Buffer, which makes common map operations cheaper, see https://github.com/cilium/ebpf/pull/1053.

CO-RE relocations are a lot more efficient

The CO-RE code now does much less copying of BTF types, which makes CO-RE relocation a lot faster, especially against large types such as sk_buff. See https://github.com/cilium/ebpf/pull/1084.

Additions

__ksym (kfunc) support

It's now possible to use new-style BPF helpers aka kfunc with the library. Going forward, all new BPF 'helper' functionality in the kernel will be exposed as kfuncs, and new helpers won't be added. See https://github.com/cilium/ebpf/pull/966 and https://github.com/cilium/ebpf/pull/996.

__kconfig support

Tracing programs often need to vary their behaviour based on kernel configuration, such as CONFIG_HZ. Such references to __kconfig variables are now automatically populated from a variety of sources such as /proc/config.gz. Note that if you run your application implementing ebpf-go in a container, it will need access to the host's /boot on some distributions that don't ship /proc/config(.gz). (notably, Debian-based distros)

As a special mention, the LINUX_HAS_SYSCALL_WRAPPER kconfig is also supported. This allows writing portable kprobes using the BPF_KSYSCALL macro from bpf_tracing.h.

See https://github.com/cilium/ebpf/pull/951, https://github.com/cilium/ebpf/pull/960 and https://github.com/cilium/ebpf/pull/995.

Overwritable perf buffer support

The perf reader now allows creating "overwritable" perf buffers, which always contain the most recent events in case the buffer ever gets full. This is in contrast to regular perf buffers which drop recent events if there is no more space. This is useful to implement "flight recorder" type functionality for events sourced from BPF.

See https://github.com/cilium/ebpf/pull/953.

btf.Builder

Constructing custom BTF type blobs is now possible through the new btf.Builder type. Call btf.NewBuilder() to obtain one, Builder.Add(t btf.Type) to add any types you need, followed by btf.NewHandle(b btf.Builder) to load the types into the kernel. Builder also has a Marshal() method for serializing the type collection into the canonical BTF format so it can be stored for later use.

What's Changed

New Contributors

Full Changelog: https://github.com/cilium/ebpf/compare/v0.10.0...v0.11.0