Giter Club home page Giter Club logo

ebpf-apps's Introduction

ebpf-apps

eBPF sample apps based on BCC, libbpf and various language bindings.

Contents

  • bcc-apps: eBPF samples with BCC.
  • bpf-apps: eBPF samples with libbpf and CO-RE.
  • bpftrace: eBPF samples with bpftrace.
  • go: eBPF samples with Go bindings.
  • kernel: eBPF samples built with kernel source.
  • rust: eBPF samples with Rust bindings.
  • tools: Tools for eBPF (e.g. bpftool and faddr2line).
  • chatgpt: generating eBPF programs with ChatGPT.

Pre-requisites

BCC

BCC and its development libraries should be installed.

Install from packages

Please follow INSTALL.md to see the detailed guides. For example, on Ubuntu or RHEL:

# Ubuntu
sudo apt-get install bpfcc-tools libbpfcc-dev linux-headers-$(uname -r)

# RHEL
sudo yum install bcc-tools bcc-devel

Install from source

Please follow INSTALL.md to see the detailed guides. For example, on Ubuntu 20.04+:

sudo apt install -y bison build-essential cmake flex git libedit-dev llvm-dev libclang-dev python zlib1g-dev libelf-dev libfl-dev python3-distutils

git clone https://github.com/iovisor/bcc.git
mkdir bcc/build; cd bcc/build
cmake ..
make
sudo make install
cmake -DPYTHON_CMD=python3 .. # build python3 binding
pushd src/python/
make
sudo make install
popd

libbpf with CO-RE

To use BTF and CO-RE, CONFIG_DEBUG_INFO_BTF=y and CONFIG_DEBUG_INFO_BTF_MODULES=y need to be enabled. If you don't want to rebuild the kernel, the following distos have enabled those options by default:

  • Ubuntu 20.10+
  • Fedora 31+
  • RHEL 8.2+
  • Debian 11+

And to build bpf applications, the following development tools should also be installed:

# Ubuntu
sudo apt-get install -y make clang llvm libelf-dev linux-tools-$(uname -r)

# RHEL
sudo yum install -y make clang llvm elfutils-libelf-devel bpftool

Useful Links

ebpf-apps's People

Contributors

feiskyer avatar huweicai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ebpf-apps's Issues

Ubuntu20.10 are not available

clang -g -O2 -Wall -I. -c xdp-proxy.c -o xdp-proxy.o
clang -Wall -O2 -g xdp-proxy.o -static -lbpf -lelf -lz -o xdp-proxy

These two instructions cannot run

xdp-proxy.c:54:2: warning: implicit declaration of function 'LIBBPF_OPTS' is invalid in C99 [-Wimplicit-function-declaration]
LIBBPF_OPTS(bpf_xdp_attach_opts, attach_opts);
^
xdp-proxy.c:54:14: error: use of undeclared identifier 'bpf_xdp_attach_opts'
LIBBPF_OPTS(bpf_xdp_attach_opts, attach_opts);
^
xdp-proxy.c:54:35: error: use of undeclared identifier 'attach_opts'
LIBBPF_OPTS(bpf_xdp_attach_opts, attach_opts);
^
xdp-proxy.c:55:8: warning: implicit declaration of function 'bpf_xdp_attach' is invalid in C99 [-Wimplicit-function-declaration]
err = bpf_xdp_attach(ifindex, prog_id, xdp_flags, &attach_opts);
^
xdp-proxy.c:55:53: error: use of undeclared identifier 'attach_opts'
err = bpf_xdp_attach(ifindex, prog_id, xdp_flags, &attach_opts);
^
xdp-proxy.c:67:2: warning: implicit declaration of function 'bpf_xdp_detach' is invalid in C99 [-Wimplicit-function-declaration]
bpf_xdp_detach(ifindex, xdp_flags, &attach_opts);
^
xdp-proxy.c:67:38: error: use of undeclared identifier 'attach_opts'
bpf_xdp_detach(ifindex, xdp_flags, &attach_opts);
^
3 warnings and 4 errors generated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.