Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
.gitignore | D | 11-Mar-2024 | 630 | 50 | 49 | |
Makefile | D | 11-Mar-2024 | 9.5 KiB | 279 | 236 | |
README.rst | D | 11-Mar-2024 | 2.3 KiB | 77 | 53 | |
bpf_insn.h | D | 11-Mar-2024 | 4.9 KiB | 198 | 143 | |
bpf_load.c | D | 11-Mar-2024 | 16.1 KiB | 672 | 539 | |
bpf_load.h | D | 11-Mar-2024 | 1.6 KiB | 59 | 33 | |
cookie_uid_helper_example.c | D | 11-Mar-2024 | 9.2 KiB | 324 | 236 | |
cpustat_kern.c | D | 11-Mar-2024 | 7 KiB | 282 | 141 | |
cpustat_user.c | D | 11-Mar-2024 | 4.7 KiB | 220 | 152 | |
fds_example.c | D | 11-Mar-2024 | 4.1 KiB | 189 | 159 | |
hash_func01.h | D | 11-Mar-2024 | 1.3 KiB | 56 | 39 | |
lathist_kern.c | D | 11-Mar-2024 | 2.1 KiB | 100 | 68 | |
lathist_user.c | D | 11-Mar-2024 | 2 KiB | 104 | 75 | |
load_sock_ops.c | D | 11-Mar-2024 | 2.4 KiB | 98 | 83 | |
lwt_len_hist.sh | D | 11-Mar-2024 | 956 | 39 | 29 | |
lwt_len_hist_kern.c | D | 11-Mar-2024 | 1.8 KiB | 83 | 59 | |
lwt_len_hist_user.c | D | 11-Mar-2024 | 1.7 KiB | 80 | 61 | |
map_perf_test_kern.c | D | 11-Mar-2024 | 6.1 KiB | 284 | 232 | |
map_perf_test_user.c | D | 11-Mar-2024 | 10.6 KiB | 465 | 375 | |
offwaketime_kern.c | D | 11-Mar-2024 | 3.5 KiB | 152 | 118 | |
offwaketime_user.c | D | 11-Mar-2024 | 2.5 KiB | 123 | 98 | |
parse_ldabs.c | D | 11-Mar-2024 | 1.2 KiB | 43 | 32 | |
parse_simple.c | D | 11-Mar-2024 | 1.3 KiB | 50 | 36 | |
parse_varlen.c | D | 11-Mar-2024 | 3.4 KiB | 151 | 122 | |
run_cookie_uid_helper_example.sh | D | 11-Mar-2024 | 341 | 16 | 11 | |
sampleip_kern.c | D | 11-Mar-2024 | 924 | 39 | 26 | |
sampleip_user.c | D | 11-Mar-2024 | 4.3 KiB | 200 | 155 | |
sock_example.c | D | 11-Mar-2024 | 2.9 KiB | 107 | 74 | |
sock_example.h | D | 11-Mar-2024 | 814 | 36 | 30 | |
sock_flags_kern.c | D | 11-Mar-2024 | 1.2 KiB | 50 | 34 | |
sockex1_kern.c | D | 11-Mar-2024 | 648 | 30 | 24 | |
sockex1_user.c | D | 11-Mar-2024 | 1 KiB | 52 | 38 | |
sockex2_kern.c | D | 11-Mar-2024 | 4.7 KiB | 222 | 188 | |
sockex2_user.c | D | 11-Mar-2024 | 1.1 KiB | 55 | 44 | |
sockex3_kern.c | D | 11-Mar-2024 | 6.1 KiB | 291 | 226 | |
sockex3_user.c | D | 11-Mar-2024 | 1.9 KiB | 85 | 70 | |
spintest_kern.c | D | 11-Mar-2024 | 2.1 KiB | 69 | 55 | |
spintest_user.c | D | 11-Mar-2024 | 1.1 KiB | 53 | 45 | |
syscall_nrs.c | D | 11-Mar-2024 | 267 | 14 | 10 | |
syscall_tp_kern.c | D | 11-Mar-2024 | 1.3 KiB | 63 | 48 | |
syscall_tp_user.c | D | 11-Mar-2024 | 2.6 KiB | 112 | 82 | |
task_fd_query_kern.c | D | 11-Mar-2024 | 409 | 20 | 16 | |
task_fd_query_user.c | D | 11-Mar-2024 | 10.5 KiB | 383 | 324 | |
tc_l2_redirect.sh | D | 11-Mar-2024 | 4.9 KiB | 175 | 135 | |
tc_l2_redirect_kern.c | D | 11-Mar-2024 | 6 KiB | 238 | 182 | |
tc_l2_redirect_user.c | D | 11-Mar-2024 | 1.5 KiB | 74 | 56 | |
tcbpf1_kern.c | D | 11-Mar-2024 | 2.5 KiB | 91 | 75 | |
tcp_basertt_kern.c | D | 11-Mar-2024 | 1.8 KiB | 79 | 55 | |
tcp_bpf.readme | D | 11-Mar-2024 | 1,010 | 27 | 19 | |
tcp_bufs_kern.c | D | 11-Mar-2024 | 2.2 KiB | 89 | 58 | |
tcp_clamp_kern.c | D | 11-Mar-2024 | 2.8 KiB | 105 | 74 | |
tcp_cong_kern.c | D | 11-Mar-2024 | 2 KiB | 86 | 59 | |
tcp_iw_kern.c | D | 11-Mar-2024 | 2.3 KiB | 91 | 61 | |
tcp_rwnd_kern.c | D | 11-Mar-2024 | 1.8 KiB | 72 | 42 | |
tcp_synrto_kern.c | D | 11-Mar-2024 | 1.8 KiB | 72 | 42 | |
test_cgrp2_array_pin.c | D | 11-Mar-2024 | 2.2 KiB | 110 | 91 | |
test_cgrp2_attach.c | D | 11-Mar-2024 | 4.6 KiB | 173 | 126 | |
test_cgrp2_attach2.c | D | 11-Mar-2024 | 11.5 KiB | 443 | 352 | |
test_cgrp2_sock.c | D | 11-Mar-2024 | 6.2 KiB | 291 | 224 | |
test_cgrp2_sock.sh | D | 11-Mar-2024 | 2.9 KiB | 136 | 86 | |
test_cgrp2_sock2.c | D | 11-Mar-2024 | 1.4 KiB | 69 | 47 | |
test_cgrp2_sock2.sh | D | 11-Mar-2024 | 1.5 KiB | 86 | 65 | |
test_cgrp2_tc.sh | D | 11-Mar-2024 | 4.2 KiB | 186 | 158 | |
test_cgrp2_tc_kern.c | D | 11-Mar-2024 | 1.8 KiB | 71 | 55 | |
test_cls_bpf.sh | D | 11-Mar-2024 | 915 | 39 | 31 | |
test_current_task_under_cgroup_kern.c | D | 11-Mar-2024 | 1.1 KiB | 44 | 29 | |
test_current_task_under_cgroup_user.c | D | 11-Mar-2024 | 1.7 KiB | 86 | 56 | |
test_ipip.sh | D | 11-Mar-2024 | 5.6 KiB | 180 | 147 | |
test_lru_dist.c | D | 11-Mar-2024 | 12.1 KiB | 544 | 421 | |
test_lwt_bpf.c | D | 11-Mar-2024 | 6 KiB | 254 | 194 | |
test_lwt_bpf.sh | D | 11-Mar-2024 | 9 KiB | 401 | 348 | |
test_map_in_map_kern.c | D | 11-Mar-2024 | 3.8 KiB | 174 | 128 | |
test_map_in_map_user.c | D | 11-Mar-2024 | 3.2 KiB | 134 | 98 | |
test_overhead_kprobe_kern.c | D | 11-Mar-2024 | 1 KiB | 42 | 29 | |
test_overhead_raw_tp_kern.c | D | 11-Mar-2024 | 357 | 18 | 13 | |
test_overhead_tp_kern.c | D | 11-Mar-2024 | 828 | 37 | 26 | |
test_overhead_user.c | D | 11-Mar-2024 | 3.7 KiB | 186 | 157 | |
test_override_return.sh | D | 11-Mar-2024 | 263 | 16 | 13 | |
test_probe_write_user_kern.c | D | 11-Mar-2024 | 1.6 KiB | 53 | 32 | |
test_probe_write_user_user.c | D | 11-Mar-2024 | 2.5 KiB | 80 | 60 | |
trace_event_kern.c | D | 11-Mar-2024 | 2.3 KiB | 80 | 62 | |
trace_event_user.c | D | 11-Mar-2024 | 7 KiB | 309 | 252 | |
trace_output_kern.c | D | 11-Mar-2024 | 609 | 31 | 24 | |
trace_output_user.c | D | 11-Mar-2024 | 2.2 KiB | 107 | 82 | |
tracex1_kern.c | D | 11-Mar-2024 | 1.4 KiB | 49 | 25 | |
tracex1_user.c | D | 11-Mar-2024 | 440 | 27 | 19 | |
tracex2_kern.c | D | 11-Mar-2024 | 2.3 KiB | 101 | 76 | |
tracex2_user.c | D | 11-Mar-2024 | 3.3 KiB | 161 | 132 | |
tracex3_kern.c | D | 11-Mar-2024 | 2.1 KiB | 90 | 58 | |
tracex3_user.c | D | 11-Mar-2024 | 3.3 KiB | 167 | 138 | |
tracex4_kern.c | D | 11-Mar-2024 | 1.2 KiB | 55 | 36 | |
tracex4_user.c | D | 11-Mar-2024 | 1.6 KiB | 78 | 57 | |
tracex5_kern.c | D | 11-Mar-2024 | 2 KiB | 80 | 59 | |
tracex5_user.c | D | 11-Mar-2024 | 1.1 KiB | 51 | 38 | |
tracex6_kern.c | D | 11-Mar-2024 | 1.5 KiB | 68 | 57 | |
tracex6_user.c | D | 11-Mar-2024 | 4.6 KiB | 190 | 162 | |
tracex7_kern.c | D | 11-Mar-2024 | 335 | 17 | 13 | |
tracex7_user.c | D | 11-Mar-2024 | 484 | 29 | 22 | |
xdp1_kern.c | D | 11-Mar-2024 | 2.1 KiB | 94 | 72 | |
xdp1_user.c | D | 11-Mar-2024 | 2.8 KiB | 139 | 108 | |
xdp2_kern.c | D | 11-Mar-2024 | 2.4 KiB | 115 | 90 | |
xdp2skb_meta.sh | D | 11-Mar-2024 | 4.5 KiB | 221 | 168 | |
xdp2skb_meta_kern.c | D | 11-Mar-2024 | 3 KiB | 106 | 36 | |
xdp_adjust_tail_kern.c | D | 11-Mar-2024 | 3.7 KiB | 153 | 119 | |
xdp_adjust_tail_user.c | D | 11-Mar-2024 | 3.4 KiB | 151 | 117 | |
xdp_fwd_kern.c | D | 11-Mar-2024 | 3.6 KiB | 139 | 96 | |
xdp_fwd_user.c | D | 11-Mar-2024 | 3.1 KiB | 149 | 116 | |
xdp_monitor_kern.c | D | 11-Mar-2024 | 6.7 KiB | 260 | 184 | |
xdp_monitor_user.c | D | 11-Mar-2024 | 17.1 KiB | 716 | 572 | |
xdp_redirect_cpu_kern.c | D | 11-Mar-2024 | 17 KiB | 722 | 540 | |
xdp_redirect_cpu_user.c | D | 11-Mar-2024 | 17 KiB | 699 | 556 | |
xdp_redirect_kern.c | D | 11-Mar-2024 | 2.1 KiB | 91 | 64 | |
xdp_redirect_map_kern.c | D | 11-Mar-2024 | 2.2 KiB | 93 | 62 | |
xdp_redirect_map_user.c | D | 11-Mar-2024 | 3.5 KiB | 153 | 115 | |
xdp_redirect_user.c | D | 11-Mar-2024 | 3.4 KiB | 151 | 113 | |
xdp_router_ipv4_kern.c | D | 11-Mar-2024 | 4.4 KiB | 187 | 151 | |
xdp_router_ipv4_user.c | D | 11-Mar-2024 | 16.4 KiB | 661 | 587 | |
xdp_rxq_info_kern.c | D | 11-Mar-2024 | 3.2 KiB | 140 | 94 | |
xdp_rxq_info_user.c | D | 11-Mar-2024 | 13.2 KiB | 582 | 482 | |
xdp_sample_pkts_kern.c | D | 11-Mar-2024 | 1.7 KiB | 67 | 44 | |
xdp_sample_pkts_user.c | D | 11-Mar-2024 | 3.4 KiB | 170 | 137 | |
xdp_tx_iptunnel_common.h | D | 11-Mar-2024 | 634 | 38 | 26 | |
xdp_tx_iptunnel_kern.c | D | 11-Mar-2024 | 5.6 KiB | 238 | 180 | |
xdp_tx_iptunnel_user.c | D | 11-Mar-2024 | 6.3 KiB | 268 | 224 | |
xdpsock.h | D | 11-Mar-2024 | 201 | 12 | 5 | |
xdpsock_kern.c | D | 11-Mar-2024 | 1.1 KiB | 57 | 44 | |
xdpsock_user.c | D | 11-Mar-2024 | 20.6 KiB | 988 | 790 |
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 17Kernel headers 18-------------- 19 20There are usually dependencies to header files of the current kernel. 21To avoid installing devel kernel headers system wide, as a normal 22user, simply call:: 23 24 make headers_install 25 26This will creates a local "usr/include" directory in the git/build top 27level directory, that the make system automatically pickup first. 28 29Compiling 30========= 31 32For building the BPF samples, issue the below command from the kernel 33top level directory:: 34 35 make samples/bpf/ 36 37Do notice the "/" slash after the directory name. 38 39It is also possible to call make from this directory. This will just 40hide the the invocation of make as above with the appended "/". 41 42Manually compiling LLVM with 'bpf' support 43------------------------------------------ 44 45Since version 3.7.0, LLVM adds a proper LLVM backend target for the 46BPF bytecode architecture. 47 48By default llvm will build all non-experimental backends including bpf. 49To generate a smaller llc binary one can use:: 50 51 -DLLVM_TARGETS_TO_BUILD="BPF" 52 53Quick sniplet for manually compiling LLVM and clang 54(build dependencies are cmake and gcc-c++):: 55 56 $ git clone http://llvm.org/git/llvm.git 57 $ cd llvm/tools 58 $ git clone --depth 1 http://llvm.org/git/clang.git 59 $ cd ..; mkdir build; cd build 60 $ cmake .. -DLLVM_TARGETS_TO_BUILD="BPF;X86" 61 $ make -j $(getconf _NPROCESSORS_ONLN) 62 63It is also possible to point make to the newly compiled 'llc' or 64'clang' command via redefining LLC or CLANG on the make command line:: 65 66 make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang 67 68Cross compiling samples 69----------------------- 70In order to cross-compile, say for arm64 targets, export CROSS_COMPILE and ARCH 71environment variables before calling make. This will direct make to build 72samples for the cross target. 73 74export ARCH=arm64 75export CROSS_COMPILE="aarch64-linux-gnu-" 76make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang 77
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 ./load_sock_ops -l /tmp/cgroupv2/foo tcp_basertt_kern.o 15 16If the "-l" flag is used, the load_sock_ops program will continue to run 17printing the BPF log buffer. The tcp_*_kern.o programs use special print 18functions to print logging information (if enabled by the ifdef). 19 20If using netperf/netserver to create traffic, you need to run them under the 21cgroupv2 to which the BPF programs are attached (i.e. under bash shell 22attached to the cgroupv2). 23 24To remove (unattach) a socket_ops BPF program from a cgroupv2: 25 26 ./load_sock_ops -r /tmp/cgroupv2/foo 27