Skip to content

Commit ea9b636

Browse files
Jakub Kicinskiborkmann
authored andcommitted
samples: bpf: remove load_sock_ops in favour of bpftool
bpftool can do all the things load_sock_ops used to do, and more. Point users to bpftool instead of maintaining this sample utility. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com> Acked-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent 5c3cf87 commit ea9b636

File tree

12 files changed

+16
-114
lines changed

12 files changed

+16
-114
lines changed

samples/bpf/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
cpustat
22
fds_example
33
lathist
4-
load_sock_ops
54
lwt_len_hist
65
map_perf_test
76
offwaketime

samples/bpf/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ hostprogs-y += lwt_len_hist
4040
hostprogs-y += xdp_tx_iptunnel
4141
hostprogs-y += test_map_in_map
4242
hostprogs-y += per_socket_stats_example
43-
hostprogs-y += load_sock_ops
4443
hostprogs-y += xdp_redirect
4544
hostprogs-y += xdp_redirect_map
4645
hostprogs-y += xdp_redirect_cpu
@@ -71,7 +70,6 @@ tracex4-objs := bpf_load.o tracex4_user.o
7170
tracex5-objs := bpf_load.o tracex5_user.o
7271
tracex6-objs := bpf_load.o tracex6_user.o
7372
tracex7-objs := bpf_load.o tracex7_user.o
74-
load_sock_ops-objs := bpf_load.o load_sock_ops.o
7573
test_probe_write_user-objs := bpf_load.o test_probe_write_user_user.o
7674
trace_output-objs := bpf_load.o trace_output_user.o $(TRACE_HELPERS)
7775
lathist-objs := bpf_load.o lathist_user.o

samples/bpf/load_sock_ops.c

Lines changed: 0 additions & 97 deletions
This file was deleted.

samples/bpf/tcp_basertt_kern.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* BPF program to set base_rtt to 80us when host is running TCP-NV and
88
* both hosts are in the same datacenter (as determined by IPv6 prefix).
99
*
10-
* Use load_sock_ops to load this BPF program.
10+
* Use "bpftool cgroup attach $cg sock_ops $prog" to load this BPF program.
1111
*/
1212

1313
#include <uapi/linux/bpf.h>

samples/bpf/tcp_bpf.readme

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,21 @@ a cgroupv2 and attach a bash shell to the group.
88
bash
99
echo $$ >> /tmp/cgroupv2/foo/cgroup.procs
1010

11-
Anything that runs under this shell belongs to the foo cgroupv2 To load
11+
Anything that runs under this shell belongs to the foo cgroupv2. To load
1212
(attach) one of the tcp_*_kern.o programs:
1313

14-
./load_sock_ops -l /tmp/cgroupv2/foo tcp_basertt_kern.o
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
1517

16-
If the "-l" flag is used, the load_sock_ops program will continue to run
17-
printing the BPF log buffer. The tcp_*_kern.o programs use special print
18-
functions to print logging information (if enabled by the ifdef).
18+
"bpftool prog tracelog" will continue to run printing the BPF log buffer.
19+
The tcp_*_kern.o programs use special print functions to print logging
20+
information (if enabled by the ifdef).
1921

2022
If using netperf/netserver to create traffic, you need to run them under the
2123
cgroupv2 to which the BPF programs are attached (i.e. under bash shell
2224
attached to the cgroupv2).
2325

2426
To remove (unattach) a socket_ops BPF program from a cgroupv2:
2527

26-
./load_sock_ops -r /tmp/cgroupv2/foo
28+
bpftool cgroup attach /tmp/cgroupv2/foo sock_ops pinned /sys/fs/bpf/tcp_prog

samples/bpf/tcp_bufs_kern.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* doing appropriate checks that indicate the hosts are far enough
1010
* away (i.e. large RTT).
1111
*
12-
* Use load_sock_ops to load this BPF program.
12+
* Use "bpftool cgroup attach $cg sock_ops $prog" to load this BPF program.
1313
*/
1414

1515
#include <uapi/linux/bpf.h>

samples/bpf/tcp_clamp_kern.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* the same datacenter. For his example, we assume they are within the same
1010
* datacenter when the first 5.5 bytes of their IPv6 addresses are the same.
1111
*
12-
* Use load_sock_ops to load this BPF program.
12+
* Use "bpftool cgroup attach $cg sock_ops $prog" to load this BPF program.
1313
*/
1414

1515
#include <uapi/linux/bpf.h>

samples/bpf/tcp_cong_kern.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* BPF program to set congestion control to dctcp when both hosts are
88
* in the same datacenter (as deteremined by IPv6 prefix).
99
*
10-
* Use load_sock_ops to load this BPF program.
10+
* Use "bpftool cgroup attach $cg sock_ops $prog" to load this BPF program.
1111
*/
1212

1313
#include <uapi/linux/bpf.h>

samples/bpf/tcp_iw_kern.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* would usually be done after doing appropriate checks that indicate
1010
* the hosts are far enough away (i.e. large RTT).
1111
*
12-
* Use load_sock_ops to load this BPF program.
12+
* Use "bpftool cgroup attach $cg sock_ops $prog" to load this BPF program.
1313
*/
1414

1515
#include <uapi/linux/bpf.h>

samples/bpf/tcp_rwnd_kern.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* and the first 5.5 bytes of the IPv6 addresses are not the same (in this
99
* example that means both hosts are not the same datacenter).
1010
*
11-
* Use load_sock_ops to load this BPF program.
11+
* Use "bpftool cgroup attach $cg sock_ops $prog" to load this BPF program.
1212
*/
1313

1414
#include <uapi/linux/bpf.h>

0 commit comments

Comments
 (0)