examples/

directory
v0.0.0-...-e5e17f5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2024 License: GPL-2.0

README

Examples

Please note that eBPF is supported only by Linux, it will not work on MacOS!

List of examples

How to run

All examples actually contain 2 parts:

  • The eBPF program written in C
  • go application which acts as a control plane

You need to build both to make example work.

Install prerequisites
# Install clang/llvm to be able to compile C files into bpf arch
$ apt-get install clang llvm make

# Install goebpf package
$ go get github.com/dropbox/goebpf

Run

Compile both parts

$ make
clang -I../../.. -O2 -target bpf -c ebpf_prog/xdp.c  -o ebpf_prog/xdp.elf
go build -v -o main

Run it!

$ sudo ./main [optional args]

You must use sudo or CAP_SYS_ADMIN / CAP_NET_ADMIN capabilities because of it creates kernel objects.

How to compile only eBPF program
$ cd [path_to_example]
$ make build_bpf

Compiled binary will be under ebpf_prog folder, e.g.:

$ ls -l ebpf_prog
total 8
-rw-r--r-- 1 root root 1524 May 15 21:20 xdp.c
-rw-r--r-- 1 root root 1104 May 15 21:20 xdp.elf

Directories

Path Synopsis
kprobe
socket_filter
tc
xdp

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL