Skip to content

Commit 1b580c9

Browse files
author
Alexei Starovoitov
committed
Merge branch 'samples-bpf-remove-unmaintained-xdp-sample-utilities'
Toke Høiland-Jørgensen says: ==================== samples/bpf: Remove unmaintained XDP sample utilities The samples/bpf directory in the kernel tree started out as a way of showcasing different aspects of BPF functionality by writing small utility programs for each feature. However, as the BPF subsystem has matured, the preferred way of including userspace code with a feature has become the BPF selftests, which also have the benefit of being consistently run as part of the BPF CI system. As a result of this shift, the utilities in samples/bpf have seen little love, and have slowly bitrotted. There have been sporadic cleanup patches over the years, but it's clear that the utilities are far from maintained. For XDP in particular, some of the utilities have been used as benchmarking aids when implementing new kernel features, which seems to be the main reason they have stuck around; any updates the utilities have seen have been targeted at this use case. However, as the BPF subsystem as a whole has moved on, it has become increasingly difficult to incorporate new features into these utilities because they predate most of the modern BPF features (such as kfuncs and BTF). Rather than try to update these utilities and keep maintaining them in the kernel tree, we have ported the useful features of the utilities to the xdp-tools package. In the porting process we also updated the utilities to take advantage of modern BPF features, integrated them with libxdp, and polished the user interface. As these utilities are standalone tools, maintaining them out of tree is simpler, and we plan to keep maintaining them in the xdp-tools repo. To direct users of these utilities to the right place, this series removes the utilities from samples/bpf, leaving in place only a couple of utilities whose functionality have not yet been ported to xdp-tools. The xdp-tools repository is located on Github at the following URL: https://github.com/xdp-project/xdp-tools The commits in the series removes one utility each, explaining how the equivalent functionality can be obtained with xdp-tools. v2: - Add equivalent xdp-tools commands for each removed utility v3: - Add link to xdp-tools in the README Toke Høiland-Jørgensen (7): samples/bpf: Remove the xdp_monitor utility samples/bpf: Remove the xdp_redirect* utilities samples/bpf: Remove the xdp_rxq_info utility samples/bpf: Remove the xdp1 and xdp2 utilities samples/bpf: Remove the xdp_sample_pkts utility samples/bpf: Cleanup .gitignore samples/bpf: Add note to README about the XDP utilities moved to xdp-tools samples/bpf/.gitignore | 12 - samples/bpf/Makefile | 48 +- samples/bpf/README.rst | 6 + samples/bpf/xdp1_kern.c | 100 ---- samples/bpf/xdp1_user.c | 166 ------ samples/bpf/xdp2_kern.c | 125 ----- samples/bpf/xdp_monitor.bpf.c | 8 - samples/bpf/xdp_monitor_user.c | 118 ----- samples/bpf/xdp_redirect.bpf.c | 49 -- samples/bpf/xdp_redirect_cpu.bpf.c | 539 ------------------- samples/bpf/xdp_redirect_cpu_user.c | 559 -------------------- samples/bpf/xdp_redirect_map.bpf.c | 97 ---- samples/bpf/xdp_redirect_map_multi.bpf.c | 77 --- samples/bpf/xdp_redirect_map_multi_user.c | 232 -------- samples/bpf/xdp_redirect_map_user.c | 228 -------- samples/bpf/xdp_redirect_user.c | 172 ------ samples/bpf/xdp_rxq_info_kern.c | 140 ----- samples/bpf/xdp_rxq_info_user.c | 614 ---------------------- samples/bpf/xdp_sample_pkts_kern.c | 57 -- samples/bpf/xdp_sample_pkts_user.c | 196 ------- 20 files changed, 7 insertions(+), 3536 deletions(-) delete mode 100644 samples/bpf/xdp1_kern.c delete mode 100644 samples/bpf/xdp1_user.c delete mode 100644 samples/bpf/xdp2_kern.c delete mode 100644 samples/bpf/xdp_monitor.bpf.c delete mode 100644 samples/bpf/xdp_monitor_user.c delete mode 100644 samples/bpf/xdp_redirect.bpf.c delete mode 100644 samples/bpf/xdp_redirect_cpu.bpf.c delete mode 100644 samples/bpf/xdp_redirect_cpu_user.c delete mode 100644 samples/bpf/xdp_redirect_map.bpf.c delete mode 100644 samples/bpf/xdp_redirect_map_multi.bpf.c delete mode 100644 samples/bpf/xdp_redirect_map_multi_user.c delete mode 100644 samples/bpf/xdp_redirect_map_user.c delete mode 100644 samples/bpf/xdp_redirect_user.c delete mode 100644 samples/bpf/xdp_rxq_info_kern.c delete mode 100644 samples/bpf/xdp_rxq_info_user.c delete mode 100644 samples/bpf/xdp_sample_pkts_kern.c delete mode 100644 samples/bpf/xdp_sample_pkts_user.c ==================== Link: https://lore.kernel.org/r/20230824102255.1561885-1-toke@redhat.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2 parents 001feda + 5a9fd0f commit 1b580c9

20 files changed

+7
-3536
lines changed

samples/bpf/.gitignore

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,10 @@ tracex4
3737
tracex5
3838
tracex6
3939
tracex7
40-
xdp1
41-
xdp2
4240
xdp_adjust_tail
4341
xdp_fwd
44-
xdp_monitor
45-
xdp_redirect
46-
xdp_redirect_cpu
47-
xdp_redirect_map
48-
xdp_redirect_map_multi
4942
xdp_router_ipv4
50-
xdp_rxq_info
51-
xdp_sample_pkts
5243
xdp_tx_iptunnel
53-
xdpsock
54-
xdpsock_ctrl_proc
55-
xsk_fwd
5644
testfile.img
5745
hbm_out.log
5846
iperf.*

samples/bpf/Makefile

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ tprogs-y += test_cgrp2_array_pin
3030
tprogs-y += test_cgrp2_attach
3131
tprogs-y += test_cgrp2_sock
3232
tprogs-y += test_cgrp2_sock2
33-
tprogs-y += xdp1
34-
tprogs-y += xdp2
3533
tprogs-y += xdp_router_ipv4
3634
tprogs-y += test_current_task_under_cgroup
3735
tprogs-y += trace_event
@@ -41,22 +39,14 @@ tprogs-y += lwt_len_hist
4139
tprogs-y += xdp_tx_iptunnel
4240
tprogs-y += test_map_in_map
4341
tprogs-y += per_socket_stats_example
44-
tprogs-y += xdp_rxq_info
4542
tprogs-y += syscall_tp
4643
tprogs-y += cpustat
4744
tprogs-y += xdp_adjust_tail
4845
tprogs-y += xdp_fwd
4946
tprogs-y += task_fd_query
50-
tprogs-y += xdp_sample_pkts
5147
tprogs-y += ibumad
5248
tprogs-y += hbm
5349

54-
tprogs-y += xdp_redirect_cpu
55-
tprogs-y += xdp_redirect_map_multi
56-
tprogs-y += xdp_redirect_map
57-
tprogs-y += xdp_redirect
58-
tprogs-y += xdp_monitor
59-
6050
# Libbpf dependencies
6151
LIBBPF_SRC = $(TOOLS_PATH)/lib/bpf
6252
LIBBPF_OUTPUT = $(abspath $(BPF_SAMPLES_PATH))/libbpf
@@ -90,9 +80,6 @@ test_cgrp2_array_pin-objs := test_cgrp2_array_pin.o
9080
test_cgrp2_attach-objs := test_cgrp2_attach.o
9181
test_cgrp2_sock-objs := test_cgrp2_sock.o
9282
test_cgrp2_sock2-objs := test_cgrp2_sock2.o
93-
xdp1-objs := xdp1_user.o
94-
# reuse xdp1 source intentionally
95-
xdp2-objs := xdp1_user.o
9683
test_current_task_under_cgroup-objs := $(CGROUP_HELPERS) \
9784
test_current_task_under_cgroup_user.o
9885
trace_event-objs := trace_event_user.o $(TRACE_HELPERS)
@@ -102,21 +89,14 @@ lwt_len_hist-objs := lwt_len_hist_user.o
10289
xdp_tx_iptunnel-objs := xdp_tx_iptunnel_user.o
10390
test_map_in_map-objs := test_map_in_map_user.o
10491
per_socket_stats_example-objs := cookie_uid_helper_example.o
105-
xdp_rxq_info-objs := xdp_rxq_info_user.o
10692
syscall_tp-objs := syscall_tp_user.o
10793
cpustat-objs := cpustat_user.o
10894
xdp_adjust_tail-objs := xdp_adjust_tail_user.o
10995
xdp_fwd-objs := xdp_fwd_user.o
11096
task_fd_query-objs := task_fd_query_user.o $(TRACE_HELPERS)
111-
xdp_sample_pkts-objs := xdp_sample_pkts_user.o
11297
ibumad-objs := ibumad_user.o
11398
hbm-objs := hbm.o $(CGROUP_HELPERS)
11499

115-
xdp_redirect_map_multi-objs := xdp_redirect_map_multi_user.o $(XDP_SAMPLE)
116-
xdp_redirect_cpu-objs := xdp_redirect_cpu_user.o $(XDP_SAMPLE)
117-
xdp_redirect_map-objs := xdp_redirect_map_user.o $(XDP_SAMPLE)
118-
xdp_redirect-objs := xdp_redirect_user.o $(XDP_SAMPLE)
119-
xdp_monitor-objs := xdp_monitor_user.o $(XDP_SAMPLE)
120100
xdp_router_ipv4-objs := xdp_router_ipv4_user.o $(XDP_SAMPLE)
121101

122102
# Tell kbuild to always build the programs
@@ -145,8 +125,6 @@ always-y += test_overhead_raw_tp.bpf.o
145125
always-y += test_overhead_kprobe.bpf.o
146126
always-y += parse_varlen.o parse_simple.o parse_ldabs.o
147127
always-y += test_cgrp2_tc.bpf.o
148-
always-y += xdp1_kern.o
149-
always-y += xdp2_kern.o
150128
always-y += test_current_task_under_cgroup.bpf.o
151129
always-y += trace_event_kern.o
152130
always-y += sampleip_kern.o
@@ -162,14 +140,12 @@ always-y += tcp_clamp_kern.o
162140
always-y += tcp_basertt_kern.o
163141
always-y += tcp_tos_reflect_kern.o
164142
always-y += tcp_dumpstats_kern.o
165-
always-y += xdp_rxq_info_kern.o
166143
always-y += xdp2skb_meta_kern.o
167144
always-y += syscall_tp_kern.o
168145
always-y += cpustat_kern.o
169146
always-y += xdp_adjust_tail_kern.o
170147
always-y += xdp_fwd_kern.o
171148
always-y += task_fd_query_kern.o
172-
always-y += xdp_sample_pkts_kern.o
173149
always-y += ibumad_kern.o
174150
always-y += hbm_out_kern.o
175151
always-y += hbm_edt_kern.o
@@ -207,11 +183,6 @@ TPROGS_LDFLAGS := -L$(SYSROOT)/usr/lib
207183
endif
208184

209185
TPROGS_LDLIBS += $(LIBBPF) -lelf -lz
210-
TPROGLDLIBS_xdp_monitor += -lm
211-
TPROGLDLIBS_xdp_redirect += -lm
212-
TPROGLDLIBS_xdp_redirect_cpu += -lm
213-
TPROGLDLIBS_xdp_redirect_map += -lm
214-
TPROGLDLIBS_xdp_redirect_map_multi += -lm
215186
TPROGLDLIBS_xdp_router_ipv4 += -lm -pthread
216187
TPROGLDLIBS_tracex4 += -lrt
217188
TPROGLDLIBS_trace_output += -lrt
@@ -326,11 +297,6 @@ $(obj)/$(TRACE_HELPERS) $(obj)/$(CGROUP_HELPERS) $(obj)/$(XDP_SAMPLE): | libbpf_
326297

327298
.PHONY: libbpf_hdrs
328299

329-
$(obj)/xdp_redirect_cpu_user.o: $(obj)/xdp_redirect_cpu.skel.h
330-
$(obj)/xdp_redirect_map_multi_user.o: $(obj)/xdp_redirect_map_multi.skel.h
331-
$(obj)/xdp_redirect_map_user.o: $(obj)/xdp_redirect_map.skel.h
332-
$(obj)/xdp_redirect_user.o: $(obj)/xdp_redirect.skel.h
333-
$(obj)/xdp_monitor_user.o: $(obj)/xdp_monitor.skel.h
334300
$(obj)/xdp_router_ipv4_user.o: $(obj)/xdp_router_ipv4.skel.h
335301

336302
$(obj)/tracex5.bpf.o: $(obj)/syscall_nrs.h
@@ -383,11 +349,6 @@ endef
383349

384350
CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG))
385351

386-
$(obj)/xdp_redirect_cpu.bpf.o: $(obj)/xdp_sample.bpf.o
387-
$(obj)/xdp_redirect_map_multi.bpf.o: $(obj)/xdp_sample.bpf.o
388-
$(obj)/xdp_redirect_map.bpf.o: $(obj)/xdp_sample.bpf.o
389-
$(obj)/xdp_redirect.bpf.o: $(obj)/xdp_sample.bpf.o
390-
$(obj)/xdp_monitor.bpf.o: $(obj)/xdp_sample.bpf.o
391352
$(obj)/xdp_router_ipv4.bpf.o: $(obj)/xdp_sample.bpf.o
392353

393354
$(obj)/%.bpf.o: $(src)/%.bpf.c $(obj)/vmlinux.h $(src)/xdp_sample.bpf.h $(src)/xdp_sample_shared.h
@@ -398,16 +359,9 @@ $(obj)/%.bpf.o: $(src)/%.bpf.c $(obj)/vmlinux.h $(src)/xdp_sample.bpf.h $(src)/x
398359
-I$(LIBBPF_INCLUDE) $(CLANG_SYS_INCLUDES) \
399360
-c $(filter %.bpf.c,$^) -o $@
400361

401-
LINKED_SKELS := xdp_redirect_cpu.skel.h xdp_redirect_map_multi.skel.h \
402-
xdp_redirect_map.skel.h xdp_redirect.skel.h xdp_monitor.skel.h \
403-
xdp_router_ipv4.skel.h
362+
LINKED_SKELS := xdp_router_ipv4.skel.h
404363
clean-files += $(LINKED_SKELS)
405364

406-
xdp_redirect_cpu.skel.h-deps := xdp_redirect_cpu.bpf.o xdp_sample.bpf.o
407-
xdp_redirect_map_multi.skel.h-deps := xdp_redirect_map_multi.bpf.o xdp_sample.bpf.o
408-
xdp_redirect_map.skel.h-deps := xdp_redirect_map.bpf.o xdp_sample.bpf.o
409-
xdp_redirect.skel.h-deps := xdp_redirect.bpf.o xdp_sample.bpf.o
410-
xdp_monitor.skel.h-deps := xdp_monitor.bpf.o xdp_sample.bpf.o
411365
xdp_router_ipv4.skel.h-deps := xdp_router_ipv4.bpf.o xdp_sample.bpf.o
412366

413367
LINKED_BPF_SRCS := $(patsubst %.bpf.o,%.bpf.c,$(foreach skel,$(LINKED_SKELS),$($(skel)-deps)))

samples/bpf/README.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ eBPF sample programs
44
This directory contains a test stubs, verifier test-suite and examples
55
for using eBPF. The examples use libbpf from tools/lib/bpf.
66

7+
Note that the XDP-specific samples have been removed from this directory and
8+
moved to the xdp-tools repository: https://github.com/xdp-project/xdp-tools
9+
See the commit messages removing each tool from this directory for how to
10+
convert specific command invocations between the old samples and the utilities
11+
in xdp-tools.
12+
713
Build dependencies
814
==================
915

samples/bpf/xdp1_kern.c

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

0 commit comments

Comments
 (0)