Skip to content

Commit

Permalink
samples: bpf: remove load_sock_ops in favour of bpftool
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Quentin Monnet <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
  • Loading branch information
Jakub Kicinski authored and borkmann committed Feb 28, 2019
1 parent 5c3cf87 commit ea9b636
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 114 deletions.
1 change: 0 additions & 1 deletion samples/bpf/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
cpustat
fds_example
lathist
load_sock_ops
lwt_len_hist
map_perf_test
offwaketime
Expand Down
2 changes: 0 additions & 2 deletions samples/bpf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ hostprogs-y += lwt_len_hist
hostprogs-y += xdp_tx_iptunnel
hostprogs-y += test_map_in_map
hostprogs-y += per_socket_stats_example
hostprogs-y += load_sock_ops
hostprogs-y += xdp_redirect
hostprogs-y += xdp_redirect_map
hostprogs-y += xdp_redirect_cpu
Expand Down Expand Up @@ -71,7 +70,6 @@ tracex4-objs := bpf_load.o tracex4_user.o
tracex5-objs := bpf_load.o tracex5_user.o
tracex6-objs := bpf_load.o tracex6_user.o
tracex7-objs := bpf_load.o tracex7_user.o
load_sock_ops-objs := bpf_load.o load_sock_ops.o
test_probe_write_user-objs := bpf_load.o test_probe_write_user_user.o
trace_output-objs := bpf_load.o trace_output_user.o $(TRACE_HELPERS)
lathist-objs := bpf_load.o lathist_user.o
Expand Down
97 changes: 0 additions & 97 deletions samples/bpf/load_sock_ops.c

This file was deleted.

2 changes: 1 addition & 1 deletion samples/bpf/tcp_basertt_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* BPF program to set base_rtt to 80us when host is running TCP-NV and
* both hosts are in the same datacenter (as determined by IPv6 prefix).
*
* Use load_sock_ops to load this BPF program.
* Use "bpftool cgroup attach $cg sock_ops $prog" to load this BPF program.
*/

#include <uapi/linux/bpf.h>
Expand Down
14 changes: 8 additions & 6 deletions samples/bpf/tcp_bpf.readme
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@ a cgroupv2 and attach a bash shell to the group.
bash
echo $$ >> /tmp/cgroupv2/foo/cgroup.procs

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

./load_sock_ops -l /tmp/cgroupv2/foo tcp_basertt_kern.o
bpftool prog load tcp_basertt_kern.o /sys/fs/bpf/tcp_prog
bpftool cgroup attach /tmp/cgroupv2/foo sock_ops pinned /sys/fs/bpf/tcp_prog
bpftool prog tracelog

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

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

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

./load_sock_ops -r /tmp/cgroupv2/foo
bpftool cgroup attach /tmp/cgroupv2/foo sock_ops pinned /sys/fs/bpf/tcp_prog
2 changes: 1 addition & 1 deletion samples/bpf/tcp_bufs_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* doing appropriate checks that indicate the hosts are far enough
* away (i.e. large RTT).
*
* Use load_sock_ops to load this BPF program.
* Use "bpftool cgroup attach $cg sock_ops $prog" to load this BPF program.
*/

#include <uapi/linux/bpf.h>
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/tcp_clamp_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* the same datacenter. For his example, we assume they are within the same
* datacenter when the first 5.5 bytes of their IPv6 addresses are the same.
*
* Use load_sock_ops to load this BPF program.
* Use "bpftool cgroup attach $cg sock_ops $prog" to load this BPF program.
*/

#include <uapi/linux/bpf.h>
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/tcp_cong_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* BPF program to set congestion control to dctcp when both hosts are
* in the same datacenter (as deteremined by IPv6 prefix).
*
* Use load_sock_ops to load this BPF program.
* Use "bpftool cgroup attach $cg sock_ops $prog" to load this BPF program.
*/

#include <uapi/linux/bpf.h>
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/tcp_iw_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* would usually be done after doing appropriate checks that indicate
* the hosts are far enough away (i.e. large RTT).
*
* Use load_sock_ops to load this BPF program.
* Use "bpftool cgroup attach $cg sock_ops $prog" to load this BPF program.
*/

#include <uapi/linux/bpf.h>
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/tcp_rwnd_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* and the first 5.5 bytes of the IPv6 addresses are not the same (in this
* example that means both hosts are not the same datacenter).
*
* Use load_sock_ops to load this BPF program.
* Use "bpftool cgroup attach $cg sock_ops $prog" to load this BPF program.
*/

#include <uapi/linux/bpf.h>
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/tcp_synrto_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* and the first 5.5 bytes of the IPv6 addresses are the same (in this example
* that means both hosts are in the same datacenter).
*
* Use load_sock_ops to load this BPF program.
* Use "bpftool cgroup attach $cg sock_ops $prog" to load this BPF program.
*/

#include <uapi/linux/bpf.h>
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/tcp_tos_reflect_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* BPF program to automatically reflect TOS option from received syn packet
*
* Use load_sock_ops to load this BPF program.
* Use "bpftool cgroup attach $cg sock_ops $prog" to load this BPF program.
*/

#include <uapi/linux/bpf.h>
Expand Down

0 comments on commit ea9b636

Please sign in to comment.