• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

.gitignoreD11-Mar-2024630 5049

MakefileD11-Mar-20249.5 KiB279236

README.rstD11-Mar-20242.3 KiB7753

bpf_insn.hD11-Mar-20244.9 KiB198143

bpf_load.cD11-Mar-202416.1 KiB672539

bpf_load.hD11-Mar-20241.6 KiB5933

cookie_uid_helper_example.cD11-Mar-20249.2 KiB324236

cpustat_kern.cD11-Mar-20247 KiB282141

cpustat_user.cD11-Mar-20244.7 KiB220152

fds_example.cD11-Mar-20244.1 KiB189159

hash_func01.hD11-Mar-20241.3 KiB5639

lathist_kern.cD11-Mar-20242.1 KiB10068

lathist_user.cD11-Mar-20242 KiB10475

load_sock_ops.cD11-Mar-20242.4 KiB9883

lwt_len_hist.shD11-Mar-2024956 3929

lwt_len_hist_kern.cD11-Mar-20241.8 KiB8359

lwt_len_hist_user.cD11-Mar-20241.7 KiB8061

map_perf_test_kern.cD11-Mar-20246.1 KiB284232

map_perf_test_user.cD11-Mar-202410.6 KiB465375

offwaketime_kern.cD11-Mar-20243.5 KiB152118

offwaketime_user.cD11-Mar-20242.5 KiB12398

parse_ldabs.cD11-Mar-20241.2 KiB4332

parse_simple.cD11-Mar-20241.3 KiB5036

parse_varlen.cD11-Mar-20243.4 KiB151122

run_cookie_uid_helper_example.shD11-Mar-2024341 1611

sampleip_kern.cD11-Mar-2024924 3926

sampleip_user.cD11-Mar-20244.3 KiB200155

sock_example.cD11-Mar-20242.9 KiB10774

sock_example.hD11-Mar-2024814 3630

sock_flags_kern.cD11-Mar-20241.2 KiB5034

sockex1_kern.cD11-Mar-2024648 3024

sockex1_user.cD11-Mar-20241 KiB5238

sockex2_kern.cD11-Mar-20244.7 KiB222188

sockex2_user.cD11-Mar-20241.1 KiB5544

sockex3_kern.cD11-Mar-20246.1 KiB291226

sockex3_user.cD11-Mar-20241.9 KiB8570

spintest_kern.cD11-Mar-20242.1 KiB6955

spintest_user.cD11-Mar-20241.1 KiB5345

syscall_nrs.cD11-Mar-2024267 1410

syscall_tp_kern.cD11-Mar-20241.3 KiB6348

syscall_tp_user.cD11-Mar-20242.6 KiB11282

task_fd_query_kern.cD11-Mar-2024409 2016

task_fd_query_user.cD11-Mar-202410.5 KiB383324

tc_l2_redirect.shD11-Mar-20244.9 KiB175135

tc_l2_redirect_kern.cD11-Mar-20246 KiB238182

tc_l2_redirect_user.cD11-Mar-20241.5 KiB7456

tcbpf1_kern.cD11-Mar-20242.5 KiB9175

tcp_basertt_kern.cD11-Mar-20241.8 KiB7955

tcp_bpf.readmeD11-Mar-20241,010 2719

tcp_bufs_kern.cD11-Mar-20242.2 KiB8958

tcp_clamp_kern.cD11-Mar-20242.8 KiB10574

tcp_cong_kern.cD11-Mar-20242 KiB8659

tcp_iw_kern.cD11-Mar-20242.3 KiB9161

tcp_rwnd_kern.cD11-Mar-20241.8 KiB7242

tcp_synrto_kern.cD11-Mar-20241.8 KiB7242

test_cgrp2_array_pin.cD11-Mar-20242.2 KiB11091

test_cgrp2_attach.cD11-Mar-20244.6 KiB173126

test_cgrp2_attach2.cD11-Mar-202411.5 KiB443352

test_cgrp2_sock.cD11-Mar-20246.2 KiB291224

test_cgrp2_sock.shD11-Mar-20242.9 KiB13686

test_cgrp2_sock2.cD11-Mar-20241.4 KiB6947

test_cgrp2_sock2.shD11-Mar-20241.5 KiB8665

test_cgrp2_tc.shD11-Mar-20244.2 KiB186158

test_cgrp2_tc_kern.cD11-Mar-20241.8 KiB7155

test_cls_bpf.shD11-Mar-2024915 3931

test_current_task_under_cgroup_kern.cD11-Mar-20241.1 KiB4429

test_current_task_under_cgroup_user.cD11-Mar-20241.7 KiB8656

test_ipip.shD11-Mar-20245.6 KiB180147

test_lru_dist.cD11-Mar-202412.1 KiB544421

test_lwt_bpf.cD11-Mar-20246 KiB254194

test_lwt_bpf.shD11-Mar-20249 KiB401348

test_map_in_map_kern.cD11-Mar-20243.8 KiB174128

test_map_in_map_user.cD11-Mar-20243.2 KiB13498

test_overhead_kprobe_kern.cD11-Mar-20241 KiB4229

test_overhead_raw_tp_kern.cD11-Mar-2024357 1813

test_overhead_tp_kern.cD11-Mar-2024828 3726

test_overhead_user.cD11-Mar-20243.7 KiB186157

test_override_return.shD11-Mar-2024263 1613

test_probe_write_user_kern.cD11-Mar-20241.6 KiB5332

test_probe_write_user_user.cD11-Mar-20242.5 KiB8060

trace_event_kern.cD11-Mar-20242.3 KiB8062

trace_event_user.cD11-Mar-20247 KiB309252

trace_output_kern.cD11-Mar-2024609 3124

trace_output_user.cD11-Mar-20242.2 KiB10782

tracex1_kern.cD11-Mar-20241.4 KiB4925

tracex1_user.cD11-Mar-2024440 2719

tracex2_kern.cD11-Mar-20242.3 KiB10176

tracex2_user.cD11-Mar-20243.3 KiB161132

tracex3_kern.cD11-Mar-20242.1 KiB9058

tracex3_user.cD11-Mar-20243.3 KiB167138

tracex4_kern.cD11-Mar-20241.2 KiB5536

tracex4_user.cD11-Mar-20241.6 KiB7857

tracex5_kern.cD11-Mar-20242 KiB8059

tracex5_user.cD11-Mar-20241.1 KiB5138

tracex6_kern.cD11-Mar-20241.5 KiB6857

tracex6_user.cD11-Mar-20244.6 KiB190162

tracex7_kern.cD11-Mar-2024335 1713

tracex7_user.cD11-Mar-2024484 2922

xdp1_kern.cD11-Mar-20242.1 KiB9472

xdp1_user.cD11-Mar-20242.8 KiB139108

xdp2_kern.cD11-Mar-20242.4 KiB11590

xdp2skb_meta.shD11-Mar-20244.5 KiB221168

xdp2skb_meta_kern.cD11-Mar-20243 KiB10636

xdp_adjust_tail_kern.cD11-Mar-20243.7 KiB153119

xdp_adjust_tail_user.cD11-Mar-20243.4 KiB151117

xdp_fwd_kern.cD11-Mar-20243.6 KiB13996

xdp_fwd_user.cD11-Mar-20243.1 KiB149116

xdp_monitor_kern.cD11-Mar-20246.7 KiB260184

xdp_monitor_user.cD11-Mar-202417.1 KiB716572

xdp_redirect_cpu_kern.cD11-Mar-202417 KiB722540

xdp_redirect_cpu_user.cD11-Mar-202417 KiB699556

xdp_redirect_kern.cD11-Mar-20242.1 KiB9164

xdp_redirect_map_kern.cD11-Mar-20242.2 KiB9362

xdp_redirect_map_user.cD11-Mar-20243.5 KiB153115

xdp_redirect_user.cD11-Mar-20243.4 KiB151113

xdp_router_ipv4_kern.cD11-Mar-20244.4 KiB187151

xdp_router_ipv4_user.cD11-Mar-202416.4 KiB661587

xdp_rxq_info_kern.cD11-Mar-20243.2 KiB14094

xdp_rxq_info_user.cD11-Mar-202413.2 KiB582482

xdp_sample_pkts_kern.cD11-Mar-20241.7 KiB6744

xdp_sample_pkts_user.cD11-Mar-20243.4 KiB170137

xdp_tx_iptunnel_common.hD11-Mar-2024634 3826

xdp_tx_iptunnel_kern.cD11-Mar-20245.6 KiB238180

xdp_tx_iptunnel_user.cD11-Mar-20246.3 KiB268224

xdpsock.hD11-Mar-2024201 125

xdpsock_kern.cD11-Mar-20241.1 KiB5744

xdpsock_user.cD11-Mar-202420.6 KiB988790

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