Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: net: remove dependency on ebpf tests

Several net tests requires an XDP program build under the ebpf
directory, and error out if such program is not available.

That makes running successful net test hard, let's duplicate into the
net dir the [very small] program, re-using the existing rules to build
it, and finally dropping the bogus dependency.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://lore.kernel.org/r/28e7af7c031557f691dc8045ee41dd549dd5e74c.1706131762.git.pabeni@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Paolo Abeni and committed by
Jakub Kicinski
98cb12eb b6478784

+26 -12
+3 -2
tools/testing/selftests/net/Makefile
··· 84 84 TEST_GEN_FILES += sctp_hello 85 85 TEST_GEN_FILES += csum 86 86 TEST_GEN_FILES += nat6to4.o 87 + TEST_GEN_FILES += xdp_dummy.o 87 88 TEST_GEN_FILES += ip_local_port_range 88 89 TEST_GEN_FILES += bind_wildcard 89 90 TEST_PROGS += test_vxlan_mdb.sh ··· 105 104 $(OUTPUT)/bind_bhash: LDLIBS += -lpthread 106 105 $(OUTPUT)/io_uring_zerocopy_tx: CFLAGS += -I../../../include/ 107 106 108 - # Rules to generate bpf obj nat6to4.o 107 + # Rules to generate bpf objs 109 108 CLANG ?= clang 110 109 SCRATCH_DIR := $(OUTPUT)/tools 111 110 BUILD_DIR := $(SCRATCH_DIR)/build ··· 140 139 141 140 CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH)) 142 141 143 - $(OUTPUT)/nat6to4.o: nat6to4.c $(BPFOBJ) | $(MAKE_DIRS) 142 + $(OUTPUT)/nat6to4.o $(OUTPUT)/xdp_dummy.o: $(OUTPUT)/%.o : %.c $(BPFOBJ) | $(MAKE_DIRS) 144 143 $(CLANG) -O2 --target=bpf -c $< $(CCINCLUDE) $(CLANG_SYS_INCLUDES) -o $@ 145 144 146 145 $(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \
+2 -2
tools/testing/selftests/net/udpgro.sh
··· 7 7 8 8 readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)" 9 9 10 - BPF_FILE="../bpf/xdp_dummy.bpf.o" 10 + BPF_FILE="xdp_dummy.o" 11 11 12 12 # set global exit status, but never reset nonzero one. 13 13 check_err() ··· 197 197 } 198 198 199 199 if [ ! -f ${BPF_FILE} ]; then 200 - echo "Missing ${BPF_FILE}. Build bpf selftest first" 200 + echo "Missing ${BPF_FILE}. Run 'make' first" 201 201 exit -1 202 202 fi 203 203
+2 -2
tools/testing/selftests/net/udpgro_bench.sh
··· 7 7 8 8 readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)" 9 9 10 - BPF_FILE="../bpf/xdp_dummy.bpf.o" 10 + BPF_FILE="xdp_dummy.o" 11 11 12 12 cleanup() { 13 13 local -r jobs="$(jobs -p)" ··· 84 84 } 85 85 86 86 if [ ! -f ${BPF_FILE} ]; then 87 - echo "Missing ${BPF_FILE}. Build bpf selftest first" 87 + echo "Missing ${BPF_FILE}. Run 'make' first" 88 88 exit -1 89 89 fi 90 90
+3 -3
tools/testing/selftests/net/udpgro_frglist.sh
··· 7 7 8 8 readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)" 9 9 10 - BPF_FILE="../bpf/xdp_dummy.bpf.o" 10 + BPF_FILE="xdp_dummy.o" 11 11 12 12 cleanup() { 13 13 local -r jobs="$(jobs -p)" ··· 85 85 } 86 86 87 87 if [ ! -f ${BPF_FILE} ]; then 88 - echo "Missing ${BPF_FILE}. Build bpf selftest first" 88 + echo "Missing ${BPF_FILE}. Run 'make' first" 89 89 exit -1 90 90 fi 91 91 92 92 if [ ! -f nat6to4.o ]; then 93 - echo "Missing nat6to4 helper. Build bpf nat6to4.o selftest first" 93 + echo "Missing nat6to4 helper. Run 'make' first" 94 94 exit -1 95 95 fi 96 96
+1 -1
tools/testing/selftests/net/udpgro_fwd.sh
··· 1 1 #!/bin/bash 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 - BPF_FILE="../bpf/xdp_dummy.bpf.o" 4 + BPF_FILE="xdp_dummy.o" 5 5 readonly BASE="ns-$(mktemp -u XXXXXX)" 6 6 readonly SRC=2 7 7 readonly DST=1
+2 -2
tools/testing/selftests/net/veth.sh
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 - BPF_FILE="../bpf/xdp_dummy.bpf.o" 4 + BPF_FILE="xdp_dummy.o" 5 5 readonly STATS="$(mktemp -p /tmp ns-XXXXXX)" 6 6 readonly BASE=`basename $STATS` 7 7 readonly SRC=2 ··· 218 218 done 219 219 220 220 if [ ! -f ${BPF_FILE} ]; then 221 - echo "Missing ${BPF_FILE}. Build bpf selftest first" 221 + echo "Missing ${BPF_FILE}. Run 'make' first" 222 222 exit 1 223 223 fi 224 224
+13
tools/testing/selftests/net/xdp_dummy.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #define KBUILD_MODNAME "xdp_dummy" 4 + #include <linux/bpf.h> 5 + #include <bpf/bpf_helpers.h> 6 + 7 + SEC("xdp") 8 + int xdp_dummy_prog(struct xdp_md *ctx) 9 + { 10 + return XDP_PASS; 11 + } 12 + 13 + char _license[] SEC("license") = "GPL";