xref: /linux-tools/ebpf/kernel-samples-bpf/README.MD (revision de922be4e919572d28577568db563e691d5e7702)
1# Build
2
3- clone linux kernel source
4```
5# for us who live in China
6git clone https://mirrors.tuna.tsinghua.edu.cn/git/linux.git
7```
8
9- copy codes in this directory to `samples/bpf`
10
11- change the Makefile, following is a example for building l3lb.*
12
13```
14diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
15index f87ee02073ba..d35832a6a13e 100644
16--- a/samples/bpf/Makefile
17+++ b/samples/bpf/Makefile
18@@ -109,6 +109,7 @@ task_fd_query-objs := bpf_load.o task_fd_query_user.o $(TRACE_HELPERS)
19 xdp_sample_pkts-objs := xdp_sample_pkts_user.o $(TRACE_HELPERS)
20 ibumad-objs := bpf_load.o ibumad_user.o $(TRACE_HELPERS)
21 hbm-objs := bpf_load.o hbm.o $(CGROUP_HELPERS)
22+l3lb-objs := l3lb.o
23
24 # Tell kbuild to always build the programs
25 always-y := $(tprogs-y)
26@@ -170,6 +171,9 @@ always-y += ibumad_kern.o
27 always-y += hbm_out_kern.o
28 always-y += hbm_edt_kern.o
29 always-y += xdpsock_kern.o
30+always-y := sock_sillycreate_kern.o
31+always-y += l3lb_kern.o l3lb
32+
33
34```
35
36- Build the binary
37
38```
39cd samples/bpf
40make
41
42# if the module has a userland admin tool, the tool needs to be build seperatedly, e.g.
43gcc -o l3lbadm l3lb_cmd.c
44```
45