Skip to content

Releasing the BTF package!

Compare
Choose a tag to compare
@lmb lmb released this 25 May 16:02

This release makes package btf public, allowing type information embedded in eBPF ELF objects and vmlinux to be read programmatically from Go. This enables use cases like searching and inspecting the kernel's types and function signatures at runtime, or ensuring alignment between structures defined in Go and C. Package btf stands on its own and does not require adopting other subpackages, potentially making it useful beyond the domain of eBPF. Additionally, parsing BTF was made significantly faster and now consumes less memory.

Note: Modifications to btf.Types are not (yet) reflected in the BTF info loaded into the kernel. This will be implemented in the near future, and will provide the flexibility of, for example, creating maps with arbitrarily crafted key/value type information for pretty-printing map dumps, among many other exciting use cases.

Users of the ringbuf and perf packages can now avoid allocations when reading samples with the addition of ReadInto().

Feature probes for program helpers (features.HaveProgramHelper()) were added, as well as a few miscellaneous probes for large instruction limit, bounded loops and the supported eBPF ISA. This now brings the library mostly on par with bpftool's probing capabilities, except for a few program types that require BTF.

There was also one important bugfix where CO-RE relocations in bpf2bpf subprograms were not applied. Users are strongly encouraged to upgrade.

Enjoy!

Breaking changes

  • Deprecations:
    • CollectionSpec.RewriteMaps is deprecated in favour of CollectionOptions.MapReplacements
    • features.HaveProgType is deprecated in favour of features.HaveProgramType
  • CollectionSpec.BTF is now called CollectionSpec.Types
  • link.K(ret)probe and link.Tracepoint signatures have changed, they now take an additional options parameter. Pass nil to retain the old behaviour.

Features

  • features: add misc probes by @florianl in #541
  • bpf2go: generate Go types from BTF by @lmb in #552
  • features: add LinuxVersionCode function to obtain LINUX_VERSION_CODE by @ti-mo in #585
  • link: support bpf perf event link, add bpf_cookies by @mmat11 in #565
  • link/kprobe: Allow . in symbol name by @chenhengqi in #600
  • btf: Implement support for bitfield relocations by @joamaki in #573
  • kprobe: fall back to tracefs if kernel doesn't support dots in PMU symbol by @chenhengqi in #605
  • link/kprobe: specify symbol offset by @xpu22 in #618
  • collection: Add ReplaceMaps to CollectionOptions by @mauriciovasquezbernal in #646
  • fix: support bpf_core_type_exists() by @holyspectral in #655
  • perf, ringbuf: add ReadBuffer mehods by @lmb in #663
  • Make BTF for data sections optional by @ti-mo in #675
  • btf: Add spec types iterator by @brb in #678
  • features: add HaveProgramHelper API by @rgo3 in #375
  • Probe kernel bpf2bpf support by @ti-mo in #657

Bug fixes

  • elf_reader: Fix cgroup/sock_{create,release} program type by @joamaki in #580
  • Execute and test CO-RE relocations of bpf2bpf subprogs by @ti-mo in #590
  • syscalls: omit AttachType field in haveProgAttach by @ti-mo in #652
  • prog: recognize ENOTSUPP in testRun() by @ti-mo in #653
  • Assorted fixes for kernel 4.14 by @ti-mo in #658

Miscellaneous

  • collection: Rename CollectionSpec.BTF to .Types, copy in Copy() by @ti-mo in #581
  • collection: document garbage collection behaviour of *Map and *Program by @ti-mo in #579
  • prog_test: compare BTF program tags instead of raw insns by @ti-mo in #583
  • collection: don't copy btf.Spec in CollectionSpec.Copy() by @ti-mo in #584
  • Moved Instruction.Symbol and Instruction.Reference into per-instruction metadata by @dylandreimerink in #582
  • examples: generate types via bpf2go by @lmb in #575
  • Add Maps to Instruction metadata by @dylandreimerink in #567
  • CI: use Go 1.18 by @lmb in #599
  • examples: include bpf_helpers.h from common.h by @ti-mo in #614
  • examples: add example for CO-RE kernel struct (tcp_sock) by @BigMikes in #602
  • examples: fentry - add comments to illustrate difference with tcprtt by @ti-mo in #615
  • btf: reduce unnecessary copies when parsing BTF by @lmb in #623
  • asm: add Instruction Source metadata by @lmb in #609
  • Memory improvements to loadRawSpec by @paulcacheux in #634
  • btf: split string table ahead of time by @lmb in #637
  • sys: update types by @florianl in #630
  • btf: fix up inflated types immediately if possible by @lmb in #638
  • Go 1.17 by @lmb in #640
  • btf: stop relying on TypeID when printing Types by @lmb in #633
  • link: do not use regexp pkg by @kolyshkin in #642
  • btf: make copying types infallible by @lmb in #631
  • Deprecate CollectionSpec.RewriteMaps() by @ti-mo in #651
  • CI: retry two times on error 42 by @lmb in #654
  • Use instruction metadata to simplify linking and CO-RE relocation by @lmb in #606
  • btf: allow users to obtain COREFixups by @lmb in #661
  • CI: run test suite against LTS kernel 4.14 by @ti-mo in #670
  • btf: introduce Bits type and remove Int.Bits and Int.Offset by @lmb in #660
  • ringbuf: reduce allocations and syscalls by @lmb in #667
  • Export package btf by @lmb in #665
  • btf: don't cache kernel BTF in LoadKernelSpec by @lmb in #676

New Contributors

Full Changelog: v0.8.1...v0.9.0