gobpf

Go bindings for creating BPF programs.

  • 所有者: iovisor/gobpf
  • 平台:
  • 许可证: Apache License 2.0
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

gobpf

Build Status GoDoc

This repository provides go bindings for the bcc framework
as well as low-level routines to load and use eBPF programs from .elf
files.

gobpf is at an early stage but is usable nonetheless. Input and contributions
are very welcome.

We recommend vendoring gobpf and pinning its version as the API is likely to
change during development.

Requirements

eBPF requires a recent Linux kernel. A good feature list can be found here:
https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md

github.com/iovisor/gobpf/bcc

Install the latest released version of libbcc
(either using a package manager or by building from source).

github.com/iovisor/gobpf/elf

Building ELF Object Files

To build ELF object files for use with the elf package, you must use specific
sections (SEC("...")). The following are currently supported:

  • kprobe/...
  • cgroup/skb
  • cgroup/sock
  • maps/...
  • socket...
  • tracepoint...
  • uprobe/...
  • uretprobe/...
  • xdp/...

Map definitions must correspond to bpf_map_def from the elf package.
Otherwise, you will encounter an error like only one map with size 280 bytes allowed per section (check bpf_map_def).

The Cilium BPF docs contain helpful info
for using clang/LLVM to compile programs into elf object files:
https://cilium.readthedocs.io/en/latest/bpf/#llvm

See tests/dummy.c for a minimal dummy and https://github.com/weaveworks/tcptracer-bpf
for a real world example.

Examples

Sample code can be found in the examples/ directory. Examples can be run as
follows:

sudo -E go run examples/bcc/perf/perf.go

Tests

The semaphore.sh script can be used to run the tests in rkt stage1-kvm
containers on different kernel versions. To run all tests on the host system,
use go test as follows:

go test -tags integration -v ./...

主要指标

概览
名称与所有者iovisor/gobpf
主编程语言C
编程语言Go (语言数: 3)
平台
许可证Apache License 2.0
所有者活动
创建于2016-11-18 18:27:13
推送于2023-08-31 05:47:21
最后一次提交2022-10-05 08:38:22
发布数3
最新版本名称v0.2.0 (发布于 2021-05-06 09:38:03)
第一版名称v0.1.0 (发布于 2021-03-05 10:56:08)
用户参与
星数2.2k
关注者数55
派生数312
提交数408
已启用问题?
问题数113
打开的问题数56
拉请求数154
打开的拉请求数29
关闭的拉请求数37
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?