Lawrence Brakmo 03e982eed4 bpf: Fix tcp_clamp_kern.c sample program 7 năm trước cách đây
..
Makefile eafb3401fa samples/bpf: add a test for bpf_override_return 7 năm trước cách đây
README.rst 8bf2ac25a9 samples/bpf: Add documentation on cross compilation 7 năm trước cách đây
bpf_load.c 2a171788ba Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 7 năm trước cách đây
bpf_load.h b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
cookie_uid_helper_example.c ad990dbe6d samples/bpf: run cleanup routines when receiving SIGTERM 8 năm trước cách đây
fds_example.c 9899694a7f samples/bpf: Move open_raw_sock to separate header 8 năm trước cách đây
lathist_kern.c 0fb1170ee6 bpf: BPF based latency tracing 10 năm trước cách đây
lathist_user.c d40fc181eb samples/bpf: Make samples more libbpf-centric 8 năm trước cách đây
libbpf.h b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
load_sock_ops.c ae16189efb bpf: program to load and attach sock_ops BPF progs 8 năm trước cách đây
lwt_len_hist.sh b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
lwt_len_hist_kern.c f74599f7c5 bpf: Add tests and samples for LWT-BPF 8 năm trước cách đây
lwt_len_hist_user.c b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
map_perf_test_kern.c 95ec669685 samples/bpf: Use getppid instead of getpgrp for array map stress 7 năm trước cách đây
map_perf_test_user.c 88cda1c9da bpf: libbpf: Provide basic API support to specify BPF obj name 7 năm trước cách đây
offwaketime_kern.c 02413cabd6 bpf, samples: don't zero data when not needed 9 năm trước cách đây
offwaketime_user.c ad990dbe6d samples/bpf: run cleanup routines when receiving SIGTERM 8 năm trước cách đây
parse_ldabs.c 96a8eb1eee bpf: fix samples to add fake KBUILD_MODNAME 8 năm trước cách đây
parse_simple.c 96a8eb1eee bpf: fix samples to add fake KBUILD_MODNAME 8 năm trước cách đây
parse_varlen.c 96a8eb1eee bpf: fix samples to add fake KBUILD_MODNAME 8 năm trước cách đây
run_cookie_uid_helper_example.sh b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
sampleip_kern.c 2dbb4c05d0 bpf/samples: Fix PT_REGS_IP on s390x and use it 8 năm trước cách đây
sampleip_user.c ad990dbe6d samples/bpf: run cleanup routines when receiving SIGTERM 8 năm trước cách đây
sock_example.c 9899694a7f samples/bpf: Move open_raw_sock to separate header 8 năm trước cách đây
sock_example.h b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
sock_flags_kern.c 0adc3dd900 samples/bpf: Update cgroup socket examples to use uid gid helper 8 năm trước cách đây
sockex1_kern.c 614cd3bd37 samples: bpf: add skb->field examples and tests 10 năm trước cách đây
sockex1_user.c b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
sockex2_kern.c d2b024d32d samples/bpf: fix sockex2 example 8 năm trước cách đây
sockex2_user.c b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
sockex3_kern.c 2b064fff85 bpf samples: fix compiler errors with sockex2 and sockex3 8 năm trước cách đây
sockex3_user.c b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
spintest_kern.c 138d6153a1 samples/bpf: Enable powerpc support 9 năm trước cách đây
spintest_user.c b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
syscall_nrs.c b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
syscall_tp_kern.c 1da236b6be bpf: add a test case for syscalls/sys_{enter|exit}_* tracepoints 8 năm trước cách đây
syscall_tp_user.c a678be5cc7 bpf: add a test case to test single tp multiple bpf attachment 7 năm trước cách đây
tc_l2_redirect.sh b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
tc_l2_redirect_kern.c cdb749cef1 bpf: fix samples xdp_tx_iptunnel and tc_l2_redirect with fake KBUILD_MODNAME 8 năm trước cách đây
tc_l2_redirect_user.c d40fc181eb samples/bpf: Make samples more libbpf-centric 8 năm trước cách đây
tcbpf1_kern.c 96a8eb1eee bpf: fix samples to add fake KBUILD_MODNAME 8 năm trước cách đây
tcbpf2_kern.c ef88f89c83 samples/bpf: extend test_tunnel_bpf.sh with ERSPAN 8 năm trước cách đây
tcp_basertt_kern.c c890063e44 bpf: sample BPF_SOCKET_OPS_BASE_RTT program 7 năm trước cách đây
tcp_bpf.readme aaf151b9e6 bpf: Rename tcp_bbf.readme to tcp_bpf.readme 7 năm trước cách đây
tcp_bufs_kern.c a4174f0560 bpf: Fix tcp_bufs_kern.c sample program 7 năm trước cách đây
tcp_clamp_kern.c 03e982eed4 bpf: Fix tcp_clamp_kern.c sample program 7 năm trước cách đây
tcp_cong_kern.c 2ff969fbe2 bpf: Fix tcp_cong_kern.c sample program 7 năm trước cách đây
tcp_iw_kern.c e1853319fc bpf: Fix tcp_iw_kern.c sample program 7 năm trước cách đây
tcp_rwnd_kern.c 016e661bb0 bpf: Fix tcp_rwnd_kern.c sample program 7 năm trước cách đây
tcp_synrto_kern.c 7863f46bac bpf: Fix tcp_synrto_kern.c sample program 7 năm trước cách đây
test_cgrp2_array_pin.c d40fc181eb samples/bpf: Make samples more libbpf-centric 8 năm trước cách đây
test_cgrp2_attach.c 7f67763337 bpf: introduce BPF_F_ALLOW_OVERRIDE flag 8 năm trước cách đây
test_cgrp2_attach2.c dfc069998e samples/bpf: use bpf_prog_query() interface 7 năm trước cách đây
test_cgrp2_sock.c 0adc3dd900 samples/bpf: Update cgroup socket examples to use uid gid helper 8 năm trước cách đây
test_cgrp2_sock.sh b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
test_cgrp2_sock2.c b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
test_cgrp2_sock2.sh b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
test_cgrp2_tc.sh b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
test_cgrp2_tc_kern.c 96a8eb1eee bpf: fix samples to add fake KBUILD_MODNAME 8 năm trước cách đây
test_cls_bpf.sh b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
test_current_task_under_cgroup_kern.c 9e6e60ecbd samples/bpf: Add test_current_task_under_cgroup test 9 năm trước cách đây
test_current_task_under_cgroup_user.c d40fc181eb samples/bpf: Make samples more libbpf-centric 8 năm trước cách đây
test_ipip.sh b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
test_lru_dist.c dfc5be0dc0 samples/bpf: check before defining offsetof 8 năm trước cách đây
test_lwt_bpf.c f74599f7c5 bpf: Add tests and samples for LWT-BPF 8 năm trước cách đây
test_lwt_bpf.sh b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
test_map_in_map_kern.c fb30d4b712 bpf: Add tests for map-in-map 8 năm trước cách đây
test_map_in_map_user.c a8744f2528 bpf: Add test for syscall on fd array/htab lookup 8 năm trước cách đây
test_overhead_kprobe_kern.c e3edfdec04 samples/bpf: add tracepoint vs kprobe performance tests 9 năm trước cách đây
test_overhead_tp_kern.c e3edfdec04 samples/bpf: add tracepoint vs kprobe performance tests 9 năm trước cách đây
test_overhead_user.c e3edfdec04 samples/bpf: add tracepoint vs kprobe performance tests 9 năm trước cách đây
test_override_return.sh eafb3401fa samples/bpf: add a test for bpf_override_return 7 năm trước cách đây
test_probe_write_user_kern.c cf9b1199de samples/bpf: Add test/example of using bpf_probe_write_user bpf helper 9 năm trước cách đây
test_probe_write_user_user.c b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
test_tunnel_bpf.sh b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
trace_event_kern.c 81b9cf8028 bpf: add a test case for helper bpf_perf_prog_read_value 7 năm trước cách đây
trace_event_user.c 81b9cf8028 bpf: add a test case for helper bpf_perf_prog_read_value 7 năm trước cách đây
trace_output_kern.c 569cc39d39 samples/bpf: fix trace_output example 9 năm trước cách đây
trace_output_user.c b6f4c66704 samples/bpf trace_output_user: Remove duplicate sys/ioctl.h include 8 năm trước cách đây
tracex1_kern.c 02413cabd6 bpf, samples: don't zero data when not needed 9 năm trước cách đây
tracex1_user.c b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
tracex2_kern.c 02413cabd6 bpf, samples: don't zero data when not needed 9 năm trước cách đây
tracex2_user.c b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
tracex3_kern.c 3059303f59 samples/bpf: update tracex[23] examples to use per-cpu maps 9 năm trước cách đây
tracex3_user.c 55de170382 samples/bpf: adjust rlimit RLIMIT_MEMLOCK for traceex2, tracex3 and tracex4 8 năm trước cách đây
tracex4_kern.c 138d6153a1 samples/bpf: Enable powerpc support 9 năm trước cách đây
tracex4_user.c 55de170382 samples/bpf: adjust rlimit RLIMIT_MEMLOCK for traceex2, tracex3 and tracex4 8 năm trước cách đây
tracex5_kern.c 4b7190e841 samples/bpf: Fix tracex5 to work with MIPS syscalls. 8 năm trước cách đây
tracex5_user.c b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license 7 năm trước cách đây
tracex6_kern.c 020a32d958 bpf: add a test case for helper bpf_perf_event_read_value 7 năm trước cách đây
tracex6_user.c 2a171788ba Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 7 năm trước cách đây
tracex7_kern.c eafb3401fa samples/bpf: add a test for bpf_override_return 7 năm trước cách đây
tracex7_user.c eafb3401fa samples/bpf: add a test for bpf_override_return 7 năm trước cách đây
xdp1_kern.c d9094bda5c bpf: make xdp sample variable names more meaningful 9 năm trước cách đây
xdp1_user.c 6dfca831c0 samples/bpf: adjust rlimit RLIMIT_MEMLOCK for xdp1 7 năm trước cách đây
xdp2_kern.c d9094bda5c bpf: make xdp sample variable names more meaningful 9 năm trước cách đây
xdp_monitor_kern.c 280b058d48 samples/bpf: xdp_monitor also record xdp_exception tracepoint 7 năm trước cách đây
xdp_monitor_user.c c4eb7f4643 samples/bpf: xdp_monitor increase memory rlimit 7 năm trước cách đây
xdp_redirect_cpu_kern.c fad3917e36 samples/bpf: add cpumap sample program xdp_redirect_cpu 7 năm trước cách đây
xdp_redirect_cpu_user.c fad3917e36 samples/bpf: add cpumap sample program xdp_redirect_cpu 7 năm trước cách đây
xdp_redirect_kern.c 3edcf18ec2 samples/bpf: Fix compilation issue in redirect dummy program 8 năm trước cách đây
xdp_redirect_map_kern.c 3edcf18ec2 samples/bpf: Fix compilation issue in redirect dummy program 8 năm trước cách đây
xdp_redirect_map_user.c 21d72af7dc samples/bpf: adjust rlimit RLIMIT_MEMLOCK for xdp_redirect_map 7 năm trước cách đây
xdp_redirect_user.c 306da4e685 samples/bpf: xdp_redirect load XDP dummy prog on TX device 8 năm trước cách đây
xdp_router_ipv4_kern.c 3e29cd0e65 xdp: Sample xdp program implementing ip forward 7 năm trước cách đây
xdp_router_ipv4_user.c 3e29cd0e65 xdp: Sample xdp program implementing ip forward 7 năm trước cách đây
xdp_tx_iptunnel_common.h 12d8bb64e3 bpf: xdp: Add XDP example for head adjustment 8 năm trước cách đây
xdp_tx_iptunnel_kern.c cdb749cef1 bpf: fix samples xdp_tx_iptunnel and tc_l2_redirect with fake KBUILD_MODNAME 8 năm trước cách đây
xdp_tx_iptunnel_user.c ad990dbe6d samples/bpf: run cleanup routines when receiving SIGTERM 8 năm trước cách đây

README.rst

eBPF sample programs
====================

This directory contains a test stubs, verifier test-suite and examples
for using eBPF. The examples use libbpf from tools/lib/bpf.

Build dependencies
==================

Compiling requires having installed:
* clang >= version 3.4.0
* llvm >= version 3.7.1

Note that LLVM's tool 'llc' must support target 'bpf', list version
and supported targets with command: ``llc --version``

Kernel headers
--------------

There are usually dependencies to header files of the current kernel.
To avoid installing devel kernel headers system wide, as a normal
user, simply call::

make headers_install

This will creates a local "usr/include" directory in the git/build top
level directory, that the make system automatically pickup first.

Compiling
=========

For building the BPF samples, issue the below command from the kernel
top level directory::

make samples/bpf/

Do notice the "/" slash after the directory name.

It is also possible to call make from this directory. This will just
hide the the invocation of make as above with the appended "/".

Manually compiling LLVM with 'bpf' support
------------------------------------------

Since version 3.7.0, LLVM adds a proper LLVM backend target for the
BPF bytecode architecture.

By default llvm will build all non-experimental backends including bpf.
To generate a smaller llc binary one can use::

-DLLVM_TARGETS_TO_BUILD="BPF"

Quick sniplet for manually compiling LLVM and clang
(build dependencies are cmake and gcc-c++)::

$ git clone http://llvm.org/git/llvm.git
$ cd llvm/tools
$ git clone --depth 1 http://llvm.org/git/clang.git
$ cd ..; mkdir build; cd build
$ cmake .. -DLLVM_TARGETS_TO_BUILD="BPF;X86"
$ make -j $(getconf _NPROCESSORS_ONLN)

It is also possible to point make to the newly compiled 'llc' or
'clang' command via redefining LLC or CLANG on the make command line::

make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang

Cross compiling samples
-----------------------
In order to cross-compile, say for arm64 targets, export CROSS_COMPILE and ARCH
environment variables before calling make. This will direct make to build
samples for the cross target.

export ARCH=arm64
export CROSS_COMPILE="aarch64-linux-gnu-"
make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang