NameDateSize

..11-Jan-202444

.gitignoreH A D31-Aug-2023655

asm_goto_workaround.hH A D10-Feb-2024715

bpf_insn.hH A D17-Oct-20216.3 KiB

cookie_uid_helper_example.cH A D11-Jan-20229.4 KiB

cpustat_kern.cH A D27-Apr-20237 KiB

cpustat_user.cH A D13-Jan-20245.7 KiB

do_hbm_test.shH A D30-Apr-202112 KiB

fds_example.cH A D04-Aug-20224.3 KiB

gnu/H31-Aug-20233

hash_func01.hH A D30-Aug-20181.3 KiB

hbm.cH A D30-Jun-202313.6 KiB

hbm.hH A D12-Jul-20191.2 KiB

hbm_edt_kern.cH A D14-Dec-20225.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 D27-Apr-20232.9 KiB

ibumad_user.cH A D26-May-20223.4 KiB

lathist_kern.cH A D16-Oct-20202.1 KiB

lathist_user.cH A D16-Oct-20202.6 KiB

lwt_len_hist.bpf.cH A D22-Feb-20231.5 KiB

lwt_len_hist.shH A D27-Apr-20231 KiB

lwt_len_hist_user.cH A D16-May-20201.6 KiB

MakefileH A D01-Nov-202314.3 KiB

Makefile.targetH A D11-Jan-20222.5 KiB

map_perf_test.bpf.cH A D22-Feb-20236.4 KiB

map_perf_test_user.cH A D13-Mar-202411.6 KiB

net_shared.hH A D31-Aug-2023843

offwaketime.bpf.cH A D31-Aug-20233.3 KiB

offwaketime_user.cH A D31-Aug-20233.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 D31-Aug-20233.9 KiB

run_cookie_uid_helper_example.shH A D09-Dec-2017341

sampleip_kern.cH A D30-Apr-2021915

sampleip_user.cH A D27-Apr-20235 KiB

sock_example.cH A D04-Aug-20222.9 KiB

sock_example.hH A D30-Jun-2018814

sock_flags.bpf.cH A D22-Feb-20231.1 KiB

sockex1_kern.cH A D29-Jan-2020661

sockex1_user.cH A D11-Jan-20221.4 KiB

sockex2_kern.cH A D04-Jun-20204.8 KiB

sockex2_user.cH A D26-May-20221.3 KiB

sockex3_kern.cH A D14-Dec-20226.5 KiB

sockex3_user.cH A D14-Dec-20222.2 KiB

spintest.bpf.cH A D31-Aug-20231.7 KiB

spintest_user.cH A D31-Aug-20231.8 KiB

syscall_nrs.cH A D19-Sep-2019337

syscall_tp_kern.cH A D01-Nov-20231.9 KiB

syscall_tp_user.cH A D01-Nov-20233.4 KiB

task_fd_query_kern.cH A D06-Oct-2022412

task_fd_query_user.cH A D27-Apr-202311.3 KiB

tc_l2_redirect.shH A D22-Feb-20235.1 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 D30-Jun-20231.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 D11-Jan-20222.1 KiB

test_cgrp2_attach.cH A D04-Aug-20224.6 KiB

test_cgrp2_sock.cH A D11-Jan-20226.3 KiB

test_cgrp2_sock.shH A D22-Feb-20232.9 KiB

test_cgrp2_sock2.cH A D16-Dec-20202 KiB

test_cgrp2_sock2.shH A D22-Feb-20231.9 KiB

test_cgrp2_tc.bpf.cH A D22-Feb-20231.5 KiB

test_cgrp2_tc.shH A D22-Feb-20234.3 KiB

test_cls_bpf.shH A D09-Dec-2017915

test_current_task_under_cgroup.bpf.cH A D22-Feb-20231.1 KiB

test_current_task_under_cgroup_user.cH A D22-Feb-20232.4 KiB

test_lru_dist.cH A D22-Feb-202311.8 KiB

test_lwt_bpf.cH A D22-Feb-20235.8 KiB

test_lwt_bpf.shH A D31-Aug-20239.2 KiB

test_map_in_map.bpf.cH A D31-Aug-20233.8 KiB

test_map_in_map_user.cH A D22-Feb-20234.3 KiB

test_overhead_kprobe.bpf.cH A D31-Aug-20231 KiB

test_overhead_raw_tp.bpf.cH A D22-Feb-2023358

test_overhead_tp.bpf.cH A D31-Aug-2023658

test_overhead_user.cH A D22-Feb-20234.5 KiB

test_override_return.shH A D01-Sep-2021276

test_probe_write_user.bpf.cH A D22-Feb-20231.6 KiB

test_probe_write_user_user.cH A D22-Feb-20233.3 KiB

trace_event_kern.cH A D30-Apr-20212.3 KiB

trace_event_user.cH A D16-Dec-20207.8 KiB

trace_output.bpf.cH A D22-Feb-2023589

trace_output_user.cH A D22-Feb-20232.2 KiB

tracex1.bpf.cH A D31-Aug-20231.4 KiB

tracex1_user.cH A D31-Aug-20231.1 KiB

tracex2.bpf.cH A D22-Feb-20232.3 KiB

tracex2_user.cH A D22-Feb-20234 KiB

tracex3.bpf.cH A D31-Aug-20232.2 KiB

tracex3_user.cH A D31-Aug-20233.7 KiB

tracex4.bpf.cH A D31-Aug-20231.2 KiB

tracex4_user.cH A D31-Aug-20232 KiB

tracex5.bpf.cH A D31-Aug-20232.2 KiB

tracex5_user.cH A D31-Aug-20232.3 KiB

tracex6.bpf.cH A D31-Aug-20231.9 KiB

tracex6_user.cH A D31-Aug-20235.5 KiB

tracex7.bpf.cH A D31-Aug-2023301

tracex7_user.cH A D31-Aug-20231.2 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 D22-Feb-20234.6 KiB

xdp_fwd_kern.cH A D29-Jan-20204.5 KiB

xdp_fwd_user.cH A D22-Feb-20235.2 KiB

xdp_router_ipv4.bpf.cH A D04-Aug-20224 KiB

xdp_router_ipv4_user.cH A D13-Mar-202417 KiB

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

xdp_sample.bpf.hH A D22-Feb-20233.3 KiB

xdp_sample_shared.hH A D01-Sep-2021295

xdp_sample_user.cH A D26-May-202242.4 KiB

xdp_sample_user.hH A D25-Mar-20224.4 KiB

xdp_tx_iptunnel_common.hH A D01-Jun-2019485

xdp_tx_iptunnel_kern.cH A D04-Aug-20225.6 KiB

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