NameDateSize

..21-Nov-202137

.gitignoreH A D03-Nov-2021810

asm_goto_workaround.hH A D20-Oct-2019725

bpf_insn.hH A D17-Oct-20216.3 KiB

cookie_uid_helper_example.cH A D01-Sep-20219.3 KiB

cpustat_kern.cH A D16-Oct-20207 KiB

cpustat_user.cH A D16-Oct-20205.7 KiB

do_hbm_test.shH A D30-Apr-202112 KiB

fds_example.cH A D06-Aug-20204.2 KiB

hash_func01.hH A D30-Aug-20181.3 KiB

hbm.cH A D16-Dec-202013.4 KiB

hbm.hH A D12-Jul-20191.2 KiB

hbm_edt_kern.cH A D12-Jul-20195.3 KiB

hbm_kern.hH A D19-Nov-20215.7 KiB

hbm_out_kern.cH A D12-Jul-20195.5 KiB

ibumad_kern.cH A D01-Jul-20212.9 KiB

ibumad_user.cH A D01-Jul-20213.4 KiB

lathist_kern.cH A D16-Oct-20202.1 KiB

lathist_user.cH A D16-Oct-20202.6 KiB

lwt_len_hist.shH A D16-Dec-20201 KiB

lwt_len_hist_kern.cH A D29-Jan-20201.9 KiB

lwt_len_hist_user.cH A D16-May-20201.6 KiB

MakefileH A D03-Nov-202115.3 KiB

Makefile.targetH A D01-Sep-20212.9 KiB

map_perf_test_kern.cH A D06-Aug-20206.5 KiB

map_perf_test_user.cH A D16-Dec-202011.5 KiB

offwaketime_kern.cH A D01-Sep-20213.8 KiB

offwaketime_user.cH A D16-Dec-20203.2 KiB

parse_ldabs.cH A D29-Jan-20201.2 KiB

parse_simple.cH A D29-Jan-20201.3 KiB

parse_varlen.cH A D29-Jan-20203.4 KiB

README.rstH A D21-Feb-20213.4 KiB

run_cookie_uid_helper_example.shH A D09-Dec-2017341

sampleip_kern.cH A D30-Apr-2021915

sampleip_user.cH A D04-Jun-20204.8 KiB

sock_example.cH A D21-Feb-20212.9 KiB

sock_example.hH A D30-Jun-2018814

sock_flags_kern.cH A D29-Jan-20201.2 KiB

sockex1_kern.cH A D29-Jan-2020661

sockex1_user.cH A D29-Jan-20201.1 KiB

sockex2_kern.cH A D04-Jun-20204.8 KiB

sockex2_user.cH A D16-Dec-20201.2 KiB

sockex3_kern.cH A D24-Oct-20206.2 KiB

sockex3_user.cH A D16-Dec-20202.4 KiB

spintest_kern.cH A D16-Oct-20202.1 KiB

spintest_user.cH A D16-Dec-20202.1 KiB

syscall_nrs.cH A D19-Sep-2019337

syscall_tp_kern.cH A D16-Oct-20201.4 KiB

syscall_tp_user.cH A D16-Dec-20203.2 KiB

task_fd_query_kern.cH A D16-Oct-2020410

task_fd_query_user.cH A D01-Jul-202111.4 KiB

tc_l2_redirect.shH A D09-Dec-20174.9 KiB

tc_l2_redirect_kern.cH A D29-Jan-20206 KiB

tc_l2_redirect_user.cH A D01-Jun-20191.3 KiB

tcbpf1_kern.cH A D29-Jan-20202.6 KiB

tcp_basertt_kern.cH A D29-Jan-20201.7 KiB

tcp_bpf.readmeH A D12-Jul-20191.1 KiB

tcp_bufs_kern.cH A D29-Jan-20202.1 KiB

tcp_clamp_kern.cH A D29-Jan-20202.7 KiB

tcp_cong_kern.cH A D29-Jan-20201.9 KiB

tcp_dumpstats_kern.cH A D29-Jan-20201.3 KiB

tcp_iw_kern.cH A D29-Jan-20202.2 KiB

tcp_rwnd_kern.cH A D29-Jan-20201.7 KiB

tcp_synrto_kern.cH A D29-Jan-20201.7 KiB

tcp_tos_reflect_kern.cH A D29-Jan-20201.8 KiB

test_cgrp2_array_pin.cH A D01-Jun-20192.1 KiB

test_cgrp2_attach.cH A D21-Feb-20214.5 KiB

test_cgrp2_sock.cH A D30-Jun-20186.2 KiB

test_cgrp2_sock.shH A D05-Apr-20182.9 KiB

test_cgrp2_sock2.cH A D16-Dec-20202 KiB

test_cgrp2_sock2.shH A D16-Dec-20201.8 KiB

test_cgrp2_tc.shH A D09-Dec-20174.2 KiB

test_cgrp2_tc_kern.cH A D29-Jan-20201.8 KiB

test_cls_bpf.shH A D09-Dec-2017915

test_current_task_under_cgroup_kern.cH A D16-Oct-20201.1 KiB

test_current_task_under_cgroup_user.cH A D16-Oct-20202.4 KiB

test_lru_dist.cH A D16-Dec-202011.9 KiB

test_lwt_bpf.cH A D29-Jan-20206 KiB

test_lwt_bpf.shH A D16-Dec-20209 KiB

test_map_in_map_kern.cH A D16-Oct-20203.9 KiB

test_map_in_map_user.cH A D16-Dec-20204.3 KiB

test_overhead_kprobe_kern.cH A D06-Aug-20201.3 KiB

test_overhead_raw_tp_kern.cH A D29-Jan-2020361

test_overhead_tp_kern.cH A D29-Jan-2020832

test_overhead_user.cH A D16-Dec-20204.2 KiB

test_override_return.shH A D01-Sep-2021276

test_probe_write_user_kern.cH A D16-Oct-20201.8 KiB

test_probe_write_user_user.cH A D16-Oct-20203.3 KiB

trace_common.hH A D04-Jun-2020286

trace_event_kern.cH A D30-Apr-20212.3 KiB

trace_event_user.cH A D16-Dec-20207.8 KiB

trace_output_kern.cH A D16-Oct-2020660

trace_output_user.cH A D16-Oct-20202.3 KiB

tracex1_kern.cH A D30-Apr-20211.8 KiB

tracex1_user.cH A D04-Jun-20201.1 KiB

tracex2_kern.cH A D04-Jun-20202.3 KiB

tracex2_user.cH A D16-Dec-20204 KiB

tracex3_kern.cH A D16-Oct-20202.1 KiB

tracex3_user.cH A D16-Dec-20203.7 KiB

tracex4_kern.cH A D04-Jun-20201.2 KiB

tracex4_user.cH A D01-Sep-20212 KiB

tracex5_kern.cH A D06-Aug-20202.2 KiB

tracex5_user.cH A D16-Dec-20202.3 KiB

tracex6_kern.cH A D04-Jun-20201.4 KiB

tracex6_user.cH A D16-Dec-20205.5 KiB

tracex7_kern.cH A D29-Jan-2020339

tracex7_user.cH A D01-Sep-20211.2 KiB

xdp1_kern.cH A D01-Sep-20212.1 KiB

xdp1_user.cH A D03-Nov-20213.3 KiB

xdp2_kern.cH A D01-Sep-20212.4 KiB

xdp2skb_meta.shH A D30-Aug-20184.5 KiB

xdp2skb_meta_kern.cH A D16-Dec-20203 KiB

xdp_adjust_tail_kern.cH A D29-Jan-20203.8 KiB

xdp_adjust_tail_user.cH A D16-Dec-20204.5 KiB

xdp_fwd_kern.cH A D29-Jan-20204.5 KiB

xdp_fwd_user.cH A D01-Jul-20213.9 KiB

xdp_monitor.bpf.cH A D01-Sep-2021218

xdp_monitor_user.cH A D01-Sep-20212.8 KiB

xdp_redirect.bpf.cH A D01-Sep-20211.3 KiB

xdp_redirect_cpu.bpf.cH A D01-Sep-202112 KiB

xdp_redirect_cpu_user.cH A D19-Nov-202114.9 KiB

xdp_redirect_map.bpf.cH A D01-Sep-20212.4 KiB

xdp_redirect_map_multi.bpf.cH A D17-Oct-20211.7 KiB

xdp_redirect_map_multi_user.cH A D01-Sep-20215.8 KiB

xdp_redirect_map_user.cH A D01-Sep-20215.7 KiB

xdp_redirect_user.cH A D01-Sep-20214.3 KiB

xdp_router_ipv4_kern.cH A D29-Jan-20204.4 KiB

xdp_router_ipv4_user.cH A D03-Nov-202118.6 KiB

xdp_rxq_info_kern.cH A D29-Jan-20203.2 KiB

xdp_rxq_info_user.cH A D16-Dec-202013.8 KiB

xdp_sample.bpf.cH A D01-Sep-20217.1 KiB

xdp_sample.bpf.hH A D01-Sep-20213.9 KiB

xdp_sample_pkts_kern.cH A D16-Oct-20201.5 KiB

xdp_sample_pkts_user.cH A D03-Nov-20214 KiB

xdp_sample_shared.hH A D01-Sep-2021295

xdp_sample_user.cH A D19-Nov-202142.4 KiB

xdp_sample_user.hH A D01-Sep-20214.4 KiB

xdp_tx_iptunnel_common.hH A D01-Jun-2019485

xdp_tx_iptunnel_kern.cH A D29-Jan-20205.6 KiB

xdp_tx_iptunnel_user.cH A D16-Dec-20207.3 KiB

xdpsock.hH A D16-Dec-2020298

xdpsock_ctrl_proc.cH A D16-Dec-20203.7 KiB

xdpsock_kern.cH A D29-Jan-2020593

xdpsock_user.cH A D01-Sep-202142.1 KiB

xsk_fwd.cH A D16-Oct-202025.1 KiB

README.rst

1eBPF sample programs
2====================
3
4This directory contains a test stubs, verifier test-suite and examples
5for using eBPF. The examples use libbpf from tools/lib/bpf.
6
7Build dependencies
8==================
9
10Compiling requires having installed:
11 * clang >= version 3.4.0
12 * llvm >= version 3.7.1
13
14Note that LLVM's tool 'llc' must support target 'bpf', list version
15and supported targets with command: ``llc --version``
16
17Clean and configuration
18-----------------------
19
20It can be needed to clean tools, samples or kernel before trying new arch or
21after some changes (on demand)::
22
23 make -C tools clean
24 make -C samples/bpf clean
25 make clean
26
27Configure kernel, defconfig for instance::
28
29 make defconfig
30
31Kernel headers
32--------------
33
34There are usually dependencies to header files of the current kernel.
35To avoid installing devel kernel headers system wide, as a normal
36user, simply call::
37
38 make headers_install
39
40This will creates a local "usr/include" directory in the git/build top
41level directory, that the make system automatically pickup first.
42
43Compiling
44=========
45
46For building the BPF samples, issue the below command from the kernel
47top level directory::
48
49 make M=samples/bpf
50
51It is also possible to call make from this directory.  This will just
52hide the invocation of make as above.
53
54Manually compiling LLVM with 'bpf' support
55------------------------------------------
56
57Since version 3.7.0, LLVM adds a proper LLVM backend target for the
58BPF bytecode architecture.
59
60By default llvm will build all non-experimental backends including bpf.
61To generate a smaller llc binary one can use::
62
63 -DLLVM_TARGETS_TO_BUILD="BPF"
64
65We recommend that developers who want the fastest incremental builds
66use the Ninja build system, you can find it in your system's package
67manager, usually the package is ninja or ninja-build.
68
69Quick sniplet for manually compiling LLVM and clang
70(build dependencies are ninja, cmake and gcc-c++)::
71
72 $ git clone https://github.com/llvm/llvm-project.git
73 $ mkdir -p llvm-project/llvm/build
74 $ cd llvm-project/llvm/build
75 $ cmake .. -G "Ninja" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \
76            -DLLVM_ENABLE_PROJECTS="clang"    \
77            -DCMAKE_BUILD_TYPE=Release        \
78            -DLLVM_BUILD_RUNTIME=OFF
79 $ ninja
80
81It is also possible to point make to the newly compiled 'llc' or
82'clang' command via redefining LLC or CLANG on the make command line::
83
84 make M=samples/bpf LLC=~/git/llvm-project/llvm/build/bin/llc CLANG=~/git/llvm-project/llvm/build/bin/clang
85
86Cross compiling samples
87-----------------------
88In order to cross-compile, say for arm64 targets, export CROSS_COMPILE and ARCH
89environment variables before calling make. But do this before clean,
90cofiguration and header install steps described above. This will direct make to
91build samples for the cross target::
92
93 export ARCH=arm64
94 export CROSS_COMPILE="aarch64-linux-gnu-"
95
96Headers can be also installed on RFS of target board if need to keep them in
97sync (not necessarily and it creates a local "usr/include" directory also)::
98
99 make INSTALL_HDR_PATH=~/some_sysroot/usr headers_install
100
101Pointing LLC and CLANG is not necessarily if it's installed on HOST and have
102in its targets appropriate arm64 arch (usually it has several arches).
103Build samples::
104
105 make M=samples/bpf
106
107Or build samples with SYSROOT if some header or library is absent in toolchain,
108say libelf, providing address to file system containing headers and libs,
109can be RFS of target board::
110
111 make M=samples/bpf SYSROOT=~/some_sysroot
112