Name Date Size

..25-Oct-20244 KiB

.gitignoreH A D25-Oct-2024704

asm_goto_workaround.hH A D25-Oct-2024725

bpf_insn.hH A D25-Oct-20245.4 KiB

bpf_load.cH A D25-Oct-202416 KiB

bpf_load.hH A D25-Oct-20241.5 KiB

cookie_uid_helper_example.cH A D25-Oct-20249.2 KiB

cpustat_kern.cH A D25-Oct-20247 KiB

cpustat_user.cH A D25-Oct-20245.7 KiB

do_hbm_test.shH A D25-Oct-202412.1 KiB

fds_example.cH A D25-Oct-20244.2 KiB

hash_func01.hH A D25-Oct-20241.3 KiB

hbm.cH A D25-Oct-202413.2 KiB

hbm.hH A D25-Oct-20241.2 KiB

hbm_edt_kern.cH A D25-Oct-20245.3 KiB

hbm_kern.hH A D25-Oct-20245.7 KiB

hbm_out_kern.cH A D25-Oct-20245.5 KiB

ibumad_kern.cH A D25-Oct-20243 KiB

ibumad_user.cH A D25-Oct-20242.5 KiB

lathist_kern.cH A D25-Oct-20242.1 KiB

lathist_user.cH A D25-Oct-20242.6 KiB

lwt_len_hist.shH A D25-Oct-20241 KiB

lwt_len_hist_kern.cH A D25-Oct-20241.9 KiB

lwt_len_hist_user.cH A D25-Oct-20241.6 KiB

MakefileH A D25-Oct-202410.8 KiB

Makefile.targetH A D25-Oct-20242.5 KiB

map_perf_test_kern.cH A D25-Oct-20246.5 KiB

map_perf_test_user.cH A D25-Oct-202411.6 KiB

offwaketime_kern.cH A D25-Oct-20243.8 KiB

offwaketime_user.cH A D25-Oct-20243.3 KiB

parse_ldabs.cH A D25-Oct-20241.2 KiB

parse_simple.cH A D25-Oct-20241.3 KiB

parse_varlen.cH A D25-Oct-20243.4 KiB

README.rstH A D25-Oct-20243.1 KiB

run_cookie_uid_helper_example.shH A D25-Oct-2024341

sampleip_kern.cH A D25-Oct-2024942

sampleip_user.cH A D25-Oct-20244.8 KiB

sock_example.cH A D25-Oct-20242.9 KiB

sock_example.hH A D25-Oct-2024814

sock_flags_kern.cH A D25-Oct-20241.2 KiB

sockex1_kern.cH A D25-Oct-2024661

sockex1_user.cH A D25-Oct-20241.1 KiB

sockex2_kern.cH A D25-Oct-20244.8 KiB

sockex2_user.cH A D25-Oct-20241.2 KiB

sockex3_kern.cH A D25-Oct-20246.2 KiB

sockex3_user.cH A D25-Oct-20242.5 KiB

spintest_kern.cH A D25-Oct-20242.1 KiB

spintest_user.cH A D25-Oct-20242.2 KiB

syscall_nrs.cH A D25-Oct-2024337

syscall_tp_kern.cH A D25-Oct-20241.4 KiB

syscall_tp_user.cH A D25-Oct-20243.2 KiB

task_fd_query_kern.cH A D25-Oct-2024410

task_fd_query_user.cH A D25-Oct-202410.5 KiB

tc_l2_redirect.shH A D25-Oct-20244.9 KiB

tc_l2_redirect_kern.cH A D25-Oct-20246 KiB

tc_l2_redirect_user.cH A D25-Oct-20241.3 KiB

tcbpf1_kern.cH A D25-Oct-20242.6 KiB

tcp_basertt_kern.cH A D25-Oct-20241.7 KiB

tcp_bpf.readmeH A D25-Oct-20241.1 KiB

tcp_bufs_kern.cH A D25-Oct-20242.1 KiB

tcp_clamp_kern.cH A D25-Oct-20242.7 KiB

tcp_cong_kern.cH A D25-Oct-20241.9 KiB

tcp_dumpstats_kern.cH A D25-Oct-20241.3 KiB

tcp_iw_kern.cH A D25-Oct-20242.2 KiB

tcp_rwnd_kern.cH A D25-Oct-20241.7 KiB

tcp_synrto_kern.cH A D25-Oct-20241.7 KiB

tcp_tos_reflect_kern.cH A D25-Oct-20241.8 KiB

test_cgrp2_array_pin.cH A D25-Oct-20242.1 KiB

test_cgrp2_attach.cH A D25-Oct-20244.6 KiB

test_cgrp2_sock.cH A D25-Oct-20246.2 KiB

test_cgrp2_sock.shH A D25-Oct-20242.9 KiB

test_cgrp2_sock2.cH A D25-Oct-20241.4 KiB

test_cgrp2_sock2.shH A D25-Oct-20241.5 KiB

test_cgrp2_tc.shH A D25-Oct-20244.2 KiB

test_cgrp2_tc_kern.cH A D25-Oct-20241.8 KiB

test_cls_bpf.shH A D25-Oct-2024915

test_current_task_under_cgroup_kern.cH A D25-Oct-20241.1 KiB

test_current_task_under_cgroup_user.cH A D25-Oct-20242.4 KiB

test_ipip.shH A D25-Oct-20245.6 KiB

test_lru_dist.cH A D25-Oct-202412 KiB

test_lwt_bpf.cH A D25-Oct-20246 KiB

test_lwt_bpf.shH A D25-Oct-20249 KiB

test_map_in_map_kern.cH A D25-Oct-20243.9 KiB

test_map_in_map_user.cH A D25-Oct-20244.4 KiB

test_overhead_kprobe_kern.cH A D25-Oct-20241.3 KiB

test_overhead_raw_tp_kern.cH A D25-Oct-2024361

test_overhead_tp_kern.cH A D25-Oct-2024832

test_overhead_user.cH A D25-Oct-20243.6 KiB

test_override_return.shH A D25-Oct-2024276

test_probe_write_user_kern.cH A D25-Oct-20241.8 KiB

test_probe_write_user_user.cH A D25-Oct-20243.3 KiB

trace_common.hH A D25-Oct-2024286

trace_event_kern.cH A D25-Oct-20242.3 KiB

trace_event_user.cH A D25-Oct-20247.9 KiB

trace_output_kern.cH A D25-Oct-2024660

trace_output_user.cH A D25-Oct-20242.3 KiB

tracex1_kern.cH A D25-Oct-20241.8 KiB

tracex1_user.cH A D25-Oct-20241.1 KiB

tracex2_kern.cH A D25-Oct-20242.3 KiB

tracex2_user.cH A D25-Oct-20244.2 KiB

tracex3_kern.cH A D25-Oct-20242.1 KiB

tracex3_user.cH A D25-Oct-20243.8 KiB

tracex4_kern.cH A D25-Oct-20241.2 KiB

tracex4_user.cH A D25-Oct-20242.2 KiB

tracex5_kern.cH A D25-Oct-20242.2 KiB

tracex5_user.cH A D25-Oct-20242.4 KiB

tracex6_kern.cH A D25-Oct-20241.9 KiB

tracex6_user.cH A D25-Oct-20245.6 KiB

tracex7_kern.cH A D25-Oct-2024339

tracex7_user.cH A D25-Oct-20241.2 KiB

xdp1_kern.cH A D25-Oct-20242.1 KiB

xdp1_user.cH A D25-Oct-20243.4 KiB

xdp2_kern.cH A D25-Oct-20242.4 KiB

xdp2skb_meta.shH A D25-Oct-20244.5 KiB

xdp2skb_meta_kern.cH A D25-Oct-20243 KiB

xdp_adjust_tail_kern.cH A D25-Oct-20243.8 KiB

xdp_adjust_tail_user.cH A D25-Oct-20244.7 KiB

xdp_fwd_kern.cH A D25-Oct-20244.5 KiB

xdp_fwd_user.cH A D25-Oct-20243.8 KiB

xdp_monitor_kern.cH A D25-Oct-20246.6 KiB

xdp_monitor_user.cH A D25-Oct-202418.6 KiB

xdp_redirect_cpu_kern.cH A D25-Oct-202417.2 KiB

xdp_redirect_cpu_user.cH A D25-Oct-202424 KiB

xdp_redirect_kern.cH A D25-Oct-20242.1 KiB

xdp_redirect_map_kern.cH A D25-Oct-20242.2 KiB

xdp_redirect_map_user.cH A D25-Oct-20245.4 KiB

xdp_redirect_user.cH A D25-Oct-20245.4 KiB

xdp_router_ipv4_kern.cH A D25-Oct-20244.4 KiB

xdp_router_ipv4_user.cH A D25-Oct-202418.4 KiB

xdp_rxq_info_kern.cH A D25-Oct-20243.2 KiB

xdp_rxq_info_user.cH A D25-Oct-202414 KiB

xdp_sample_pkts_kern.cH A D25-Oct-20241.5 KiB

xdp_sample_pkts_user.cH A D25-Oct-20244.1 KiB

xdp_tx_iptunnel_common.hH A D25-Oct-2024485

xdp_tx_iptunnel_kern.cH A D25-Oct-20245.6 KiB

xdp_tx_iptunnel_user.cH A D25-Oct-20247.5 KiB

xdpsock.hH A D25-Oct-2024167

xdpsock_kern.cH A D25-Oct-2024593

xdpsock_user.cH A D25-Oct-202438.3 KiB

xsk_fwd.cH A D25-Oct-202425.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
65Quick sniplet for manually compiling LLVM and clang
66(build dependencies are cmake and gcc-c++)::
67
68 $ git clone http://llvm.org/git/llvm.git
69 $ cd llvm/tools
70 $ git clone --depth 1 http://llvm.org/git/clang.git
71 $ cd ..; mkdir build; cd build
72 $ cmake .. -DLLVM_TARGETS_TO_BUILD="BPF;X86"
73 $ make -j $(getconf _NPROCESSORS_ONLN)
74
75It is also possible to point make to the newly compiled 'llc' or
76'clang' command via redefining LLC or CLANG on the make command line::
77
78 make M=samples/bpf LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
79
80Cross compiling samples
81-----------------------
82In order to cross-compile, say for arm64 targets, export CROSS_COMPILE and ARCH
83environment variables before calling make. But do this before clean,
84cofiguration and header install steps described above. This will direct make to
85build samples for the cross target::
86
87 export ARCH=arm64
88 export CROSS_COMPILE="aarch64-linux-gnu-"
89
90Headers can be also installed on RFS of target board if need to keep them in
91sync (not necessarily and it creates a local "usr/include" directory also)::
92
93 make INSTALL_HDR_PATH=~/some_sysroot/usr headers_install
94
95Pointing LLC and CLANG is not necessarily if it's installed on HOST and have
96in its targets appropriate arm64 arch (usually it has several arches).
97Build samples::
98
99 make M=samples/bpf
100
101Or build samples with SYSROOT if some header or library is absent in toolchain,
102say libelf, providing address to file system containing headers and libs,
103can be RFS of target board::
104
105 make M=samples/bpf SYSROOT=~/some_sysroot
106