Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 18-Mar-2022 | - | ||||
.gitignore | A D | 18-Mar-2022 | 810 | 64 | 63 | |
Makefile | A D | 18-Mar-2022 | 15.3 KiB | 443 | 361 | |
Makefile.target | A D | 18-Mar-2022 | 2.9 KiB | 87 | 41 | |
README.rst | A D | 18-Mar-2022 | 3.4 KiB | 112 | 77 | |
asm_goto_workaround.h | A D | 18-Mar-2022 | 725 | 29 | 13 | |
bpf_insn.h | A D | 18-Mar-2022 | 6.3 KiB | 234 | 158 | |
cookie_uid_helper_example.c | A D | 18-Mar-2022 | 9.3 KiB | 329 | 241 | |
cpustat_kern.c | A D | 18-Mar-2022 | 7 KiB | 282 | 141 | |
cpustat_user.c | A D | 18-Mar-2022 | 5.7 KiB | 253 | 180 | |
do_hbm_test.sh | A D | 18-Mar-2022 | 12 KiB | 439 | 392 | |
fds_example.c | A D | 18-Mar-2022 | 4.2 KiB | 194 | 163 | |
hash_func01.h | A D | 18-Mar-2022 | 1.3 KiB | 56 | 39 | |
hbm.c | A D | 18-Mar-2022 | 13.4 KiB | 506 | 403 | |
hbm.h | A D | 18-Mar-2022 | 1.2 KiB | 39 | 26 | |
hbm_edt_kern.c | A D | 18-Mar-2022 | 5.3 KiB | 169 | 84 | |
hbm_kern.h | A D | 18-Mar-2022 | 5.7 KiB | 216 | 182 | |
hbm_out_kern.c | A D | 18-Mar-2022 | 5.5 KiB | 180 | 94 | |
ibumad_kern.c | A D | 18-Mar-2022 | 2.9 KiB | 139 | 100 | |
ibumad_user.c | A D | 18-Mar-2022 | 3.4 KiB | 160 | 123 | |
lathist_kern.c | A D | 18-Mar-2022 | 2.1 KiB | 100 | 68 | |
lathist_user.c | A D | 18-Mar-2022 | 2.6 KiB | 131 | 101 | |
lwt_len_hist.sh | A D | 18-Mar-2022 | 1 KiB | 41 | 30 | |
lwt_len_hist_kern.c | A D | 18-Mar-2022 | 1.9 KiB | 83 | 59 | |
lwt_len_hist_user.c | A D | 18-Mar-2022 | 1.6 KiB | 78 | 60 | |
map_perf_test_kern.c | A D | 18-Mar-2022 | 6.5 KiB | 292 | 239 | |
map_perf_test_user.c | A D | 18-Mar-2022 | 11.5 KiB | 502 | 404 | |
offwaketime_kern.c | A D | 18-Mar-2022 | 3.8 KiB | 159 | 125 | |
offwaketime_user.c | A D | 18-Mar-2022 | 3.2 KiB | 155 | 126 | |
parse_ldabs.c | A D | 18-Mar-2022 | 1.2 KiB | 44 | 33 | |
parse_simple.c | A D | 18-Mar-2022 | 1.3 KiB | 50 | 36 | |
parse_varlen.c | A D | 18-Mar-2022 | 3.4 KiB | 151 | 122 | |
run_cookie_uid_helper_example.sh | A D | 18-Mar-2022 | 341 | 16 | 11 | |
sampleip_kern.c | A D | 18-Mar-2022 | 915 | 39 | 26 | |
sampleip_user.c | A D | 18-Mar-2022 | 4.8 KiB | 228 | 180 | |
sock_example.c | A D | 18-Mar-2022 | 2.9 KiB | 107 | 74 | |
sock_example.h | A D | 18-Mar-2022 | 814 | 36 | 30 | |
sock_flags_kern.c | A D | 18-Mar-2022 | 1.2 KiB | 50 | 34 | |
sockex1_kern.c | A D | 18-Mar-2022 | 661 | 31 | 25 | |
sockex1_user.c | A D | 18-Mar-2022 | 1.1 KiB | 55 | 40 | |
sockex2_kern.c | A D | 18-Mar-2022 | 4.8 KiB | 224 | 190 | |
sockex2_user.c | A D | 18-Mar-2022 | 1.2 KiB | 56 | 44 | |
sockex3_kern.c | A D | 18-Mar-2022 | 6.2 KiB | 294 | 227 | |
sockex3_user.c | A D | 18-Mar-2022 | 2.4 KiB | 105 | 85 | |
spintest_kern.c | A D | 18-Mar-2022 | 2.1 KiB | 70 | 56 | |
spintest_user.c | A D | 18-Mar-2022 | 2.1 KiB | 94 | 79 | |
syscall_nrs.c | A D | 18-Mar-2022 | 337 | 20 | 15 | |
syscall_tp_kern.c | A D | 18-Mar-2022 | 1.4 KiB | 74 | 60 | |
syscall_tp_user.c | A D | 18-Mar-2022 | 3.2 KiB | 137 | 105 | |
task_fd_query_kern.c | A D | 18-Mar-2022 | 410 | 20 | 16 | |
task_fd_query_user.c | A D | 18-Mar-2022 | 11.4 KiB | 425 | 361 | |
tc_l2_redirect.sh | A D | 18-Mar-2022 | 4.9 KiB | 175 | 135 | |
tc_l2_redirect_kern.c | A D | 18-Mar-2022 | 6 KiB | 238 | 182 | |
tc_l2_redirect_user.c | A D | 18-Mar-2022 | 1.3 KiB | 71 | 56 | |
tcbpf1_kern.c | A D | 18-Mar-2022 | 2.6 KiB | 92 | 76 | |
tcp_basertt_kern.c | A D | 18-Mar-2022 | 1.7 KiB | 72 | 49 | |
tcp_bpf.readme | A D | 18-Mar-2022 | 1.1 KiB | 29 | 21 | |
tcp_bufs_kern.c | A D | 18-Mar-2022 | 2.1 KiB | 82 | 52 | |
tcp_clamp_kern.c | A D | 18-Mar-2022 | 2.7 KiB | 98 | 68 | |
tcp_cong_kern.c | A D | 18-Mar-2022 | 1.9 KiB | 79 | 53 | |
tcp_dumpstats_kern.c | A D | 18-Mar-2022 | 1.3 KiB | 69 | 51 | |
tcp_iw_kern.c | A D | 18-Mar-2022 | 2.2 KiB | 84 | 55 | |
tcp_rwnd_kern.c | A D | 18-Mar-2022 | 1.7 KiB | 65 | 36 | |
tcp_synrto_kern.c | A D | 18-Mar-2022 | 1.7 KiB | 65 | 36 | |
tcp_tos_reflect_kern.c | A D | 18-Mar-2022 | 1.8 KiB | 81 | 67 | |
test_cgrp2_array_pin.c | A D | 18-Mar-2022 | 2.1 KiB | 107 | 91 | |
test_cgrp2_attach.c | A D | 18-Mar-2022 | 4.5 KiB | 174 | 126 | |
test_cgrp2_sock.c | A D | 18-Mar-2022 | 6.2 KiB | 291 | 224 | |
test_cgrp2_sock.sh | A D | 18-Mar-2022 | 2.9 KiB | 136 | 86 | |
test_cgrp2_sock2.c | A D | 18-Mar-2022 | 2 KiB | 96 | 70 | |
test_cgrp2_sock2.sh | A D | 18-Mar-2022 | 1.8 KiB | 99 | 76 | |
test_cgrp2_tc.sh | A D | 18-Mar-2022 | 4.2 KiB | 186 | 158 | |
test_cgrp2_tc_kern.c | A D | 18-Mar-2022 | 1.8 KiB | 71 | 55 | |
test_cls_bpf.sh | A D | 18-Mar-2022 | 915 | 39 | 31 | |
test_current_task_under_cgroup_kern.c | A D | 18-Mar-2022 | 1.1 KiB | 45 | 30 | |
test_current_task_under_cgroup_user.c | A D | 18-Mar-2022 | 2.4 KiB | 114 | 81 | |
test_lru_dist.c | A D | 18-Mar-2022 | 11.9 KiB | 538 | 419 | |
test_lwt_bpf.c | A D | 18-Mar-2022 | 6 KiB | 254 | 194 | |
test_lwt_bpf.sh | A D | 18-Mar-2022 | 9 KiB | 401 | 348 | |
test_map_in_map_kern.c | A D | 18-Mar-2022 | 3.9 KiB | 177 | 131 | |
test_map_in_map_user.c | A D | 18-Mar-2022 | 4.3 KiB | 168 | 131 | |
test_overhead_kprobe_kern.c | A D | 18-Mar-2022 | 1.3 KiB | 49 | 36 | |
test_overhead_raw_tp_kern.c | A D | 18-Mar-2022 | 361 | 18 | 13 | |
test_overhead_tp_kern.c | A D | 18-Mar-2022 | 832 | 37 | 26 | |
test_overhead_user.c | A D | 18-Mar-2022 | 4.2 KiB | 217 | 179 | |
test_override_return.sh | A D | 18-Mar-2022 | 276 | 17 | 14 | |
test_probe_write_user_kern.c | A D | 18-Mar-2022 | 1.8 KiB | 57 | 36 | |
test_probe_write_user_user.c | A D | 18-Mar-2022 | 3.3 KiB | 109 | 85 | |
trace_common.h | A D | 18-Mar-2022 | 286 | 14 | 10 | |
trace_event_kern.c | A D | 18-Mar-2022 | 2.3 KiB | 80 | 62 | |
trace_event_user.c | A D | 18-Mar-2022 | 7.8 KiB | 353 | 288 | |
trace_output_kern.c | A D | 18-Mar-2022 | 660 | 32 | 25 | |
trace_output_user.c | A D | 18-Mar-2022 | 2.3 KiB | 108 | 87 | |
tracex1_kern.c | A D | 18-Mar-2022 | 1.8 KiB | 55 | 31 | |
tracex1_user.c | A D | 18-Mar-2022 | 1.1 KiB | 51 | 40 | |
tracex2_kern.c | A D | 18-Mar-2022 | 2.3 KiB | 103 | 78 | |
tracex2_user.c | A D | 18-Mar-2022 | 4 KiB | 188 | 154 | |
tracex3_kern.c | A D | 18-Mar-2022 | 2.1 KiB | 91 | 59 | |
tracex3_user.c | A D | 18-Mar-2022 | 3.7 KiB | 185 | 157 | |
tracex4_kern.c | A D | 18-Mar-2022 | 1.2 KiB | 56 | 37 | |
tracex4_user.c | A D | 18-Mar-2022 | 2 KiB | 98 | 77 | |
tracex5_kern.c | A D | 18-Mar-2022 | 2.2 KiB | 94 | 70 | |
tracex5_user.c | A D | 18-Mar-2022 | 2.3 KiB | 99 | 78 | |
tracex6_kern.c | A D | 18-Mar-2022 | 1.4 KiB | 70 | 57 | |
tracex6_user.c | A D | 18-Mar-2022 | 5.5 KiB | 224 | 189 | |
tracex7_kern.c | A D | 18-Mar-2022 | 339 | 17 | 13 | |
tracex7_user.c | A D | 18-Mar-2022 | 1.2 KiB | 57 | 46 | |
xdp1_kern.c | A D | 18-Mar-2022 | 2.1 KiB | 96 | 72 | |
xdp1_user.c | A D | 18-Mar-2022 | 3.3 KiB | 162 | 131 | |
xdp2_kern.c | A D | 18-Mar-2022 | 2.4 KiB | 117 | 90 | |
xdp2skb_meta.sh | A D | 18-Mar-2022 | 4.5 KiB | 221 | 168 | |
xdp2skb_meta_kern.c | A D | 18-Mar-2022 | 3 KiB | 106 | 36 | |
xdp_adjust_tail_kern.c | A D | 18-Mar-2022 | 3.8 KiB | 156 | 120 | |
xdp_adjust_tail_user.c | A D | 18-Mar-2022 | 4.5 KiB | 193 | 154 | |
xdp_fwd_kern.c | A D | 18-Mar-2022 | 4.5 KiB | 159 | 98 | |
xdp_fwd_user.c | A D | 18-Mar-2022 | 3.9 KiB | 173 | 131 | |
xdp_monitor.bpf.c | A D | 18-Mar-2022 | 218 | 9 | 2 | |
xdp_monitor_user.c | A D | 18-Mar-2022 | 2.8 KiB | 120 | 103 | |
xdp_redirect.bpf.c | A D | 18-Mar-2022 | 1.3 KiB | 50 | 29 | |
xdp_redirect_cpu.bpf.c | A D | 18-Mar-2022 | 12 KiB | 542 | 431 | |
xdp_redirect_cpu_user.c | A D | 18-Mar-2022 | 14.9 KiB | 561 | 463 | |
xdp_redirect_map.bpf.c | A D | 18-Mar-2022 | 2.4 KiB | 96 | 64 | |
xdp_redirect_map_multi.bpf.c | A D | 18-Mar-2022 | 1.7 KiB | 78 | 61 | |
xdp_redirect_map_multi_user.c | A D | 18-Mar-2022 | 5.8 KiB | 234 | 201 | |
xdp_redirect_map_user.c | A D | 18-Mar-2022 | 5.7 KiB | 220 | 187 | |
xdp_redirect_user.c | A D | 18-Mar-2022 | 4.3 KiB | 174 | 148 | |
xdp_router_ipv4_kern.c | A D | 18-Mar-2022 | 4.4 KiB | 187 | 151 | |
xdp_router_ipv4_user.c | A D | 18-Mar-2022 | 18.6 KiB | 751 | 667 | |
xdp_rxq_info_kern.c | A D | 18-Mar-2022 | 3.2 KiB | 141 | 94 | |
xdp_rxq_info_user.c | A D | 18-Mar-2022 | 13.8 KiB | 600 | 497 | |
xdp_sample.bpf.c | A D | 18-Mar-2022 | 7.1 KiB | 267 | 207 | |
xdp_sample.bpf.h | A D | 18-Mar-2022 | 3.9 KiB | 142 | 105 | |
xdp_sample_pkts_kern.c | A D | 18-Mar-2022 | 1.5 KiB | 58 | 36 | |
xdp_sample_pkts_user.c | A D | 18-Mar-2022 | 4 KiB | 198 | 167 | |
xdp_sample_shared.h | A D | 18-Mar-2022 | 295 | 18 | 14 | |
xdp_sample_user.c | A D | 18-Mar-2022 | 42.4 KiB | 1,676 | 1,418 | |
xdp_sample_user.h | A D | 18-Mar-2022 | 4.4 KiB | 109 | 94 | |
xdp_tx_iptunnel_common.h | A D | 18-Mar-2022 | 485 | 35 | 26 | |
xdp_tx_iptunnel_kern.c | A D | 18-Mar-2022 | 5.6 KiB | 238 | 180 | |
xdp_tx_iptunnel_user.c | A D | 18-Mar-2022 | 7.3 KiB | 309 | 263 | |
xdpsock.h | A D | 18-Mar-2022 | 298 | 20 | 9 | |
xdpsock_ctrl_proc.c | A D | 18-Mar-2022 | 3.7 KiB | 188 | 153 | |
xdpsock_kern.c | A D | 18-Mar-2022 | 593 | 25 | 15 | |
xdpsock_user.c | A D | 18-Mar-2022 | 42.1 KiB | 1,703 | 1,390 | |
xsk_fwd.c | A D | 18-Mar-2022 | 25.1 KiB | 1,086 | 768 |
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
tcp_bpf.readme
1This file describes how to run the tcp_*_kern.o tcp_bpf (or socket_ops) 2programs. These programs attach to a cgroupv2. The following commands create 3a cgroupv2 and attach a bash shell to the group. 4 5 mkdir -p /tmp/cgroupv2 6 mount -t cgroup2 none /tmp/cgroupv2 7 mkdir -p /tmp/cgroupv2/foo 8 bash 9 echo $$ >> /tmp/cgroupv2/foo/cgroup.procs 10 11Anything that runs under this shell belongs to the foo cgroupv2. To load 12(attach) one of the tcp_*_kern.o programs: 13 14 bpftool prog load tcp_basertt_kern.o /sys/fs/bpf/tcp_prog 15 bpftool cgroup attach /tmp/cgroupv2/foo sock_ops pinned /sys/fs/bpf/tcp_prog 16 bpftool prog tracelog 17 18"bpftool prog tracelog" will continue to run printing the BPF log buffer. 19The tcp_*_kern.o programs use special print functions to print logging 20information (if enabled by the ifdef). 21 22If using netperf/netserver to create traffic, you need to run them under the 23cgroupv2 to which the BPF programs are attached (i.e. under bash shell 24attached to the cgroupv2). 25 26To remove (unattach) a socket_ops BPF program from a cgroupv2: 27 28 bpftool cgroup detach /tmp/cgroupv2/foo sock_ops pinned /sys/fs/bpf/tcp_prog 29