Commit 98cb12eb authored by Paolo Abeni's avatar Paolo Abeni Committed by Jakub Kicinski

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: default avatarPaolo Abeni <pabeni@redhat.com>
Reviewed-by: default avatarWillem de Bruijn <willemb@google.com>
Link: https://lore.kernel.org/r/28e7af7c031557f691dc8045ee41dd549dd5e74c.1706131762.git.pabeni@redhat.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent b6478784
...@@ -84,6 +84,7 @@ TEST_PROGS += sctp_vrf.sh ...@@ -84,6 +84,7 @@ TEST_PROGS += sctp_vrf.sh
TEST_GEN_FILES += sctp_hello TEST_GEN_FILES += sctp_hello
TEST_GEN_FILES += csum TEST_GEN_FILES += csum
TEST_GEN_FILES += nat6to4.o TEST_GEN_FILES += nat6to4.o
TEST_GEN_FILES += xdp_dummy.o
TEST_GEN_FILES += ip_local_port_range TEST_GEN_FILES += ip_local_port_range
TEST_GEN_FILES += bind_wildcard TEST_GEN_FILES += bind_wildcard
TEST_PROGS += test_vxlan_mdb.sh TEST_PROGS += test_vxlan_mdb.sh
...@@ -104,7 +105,7 @@ $(OUTPUT)/tcp_inq: LDLIBS += -lpthread ...@@ -104,7 +105,7 @@ $(OUTPUT)/tcp_inq: LDLIBS += -lpthread
$(OUTPUT)/bind_bhash: LDLIBS += -lpthread $(OUTPUT)/bind_bhash: LDLIBS += -lpthread
$(OUTPUT)/io_uring_zerocopy_tx: CFLAGS += -I../../../include/ $(OUTPUT)/io_uring_zerocopy_tx: CFLAGS += -I../../../include/
# Rules to generate bpf obj nat6to4.o # Rules to generate bpf objs
CLANG ?= clang CLANG ?= clang
SCRATCH_DIR := $(OUTPUT)/tools SCRATCH_DIR := $(OUTPUT)/tools
BUILD_DIR := $(SCRATCH_DIR)/build BUILD_DIR := $(SCRATCH_DIR)/build
...@@ -139,7 +140,7 @@ endif ...@@ -139,7 +140,7 @@ endif
CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH)) CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH))
$(OUTPUT)/nat6to4.o: nat6to4.c $(BPFOBJ) | $(MAKE_DIRS) $(OUTPUT)/nat6to4.o $(OUTPUT)/xdp_dummy.o: $(OUTPUT)/%.o : %.c $(BPFOBJ) | $(MAKE_DIRS)
$(CLANG) -O2 --target=bpf -c $< $(CCINCLUDE) $(CLANG_SYS_INCLUDES) -o $@ $(CLANG) -O2 --target=bpf -c $< $(CCINCLUDE) $(CLANG_SYS_INCLUDES) -o $@
$(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \ $(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \
......
...@@ -7,7 +7,7 @@ source net_helper.sh ...@@ -7,7 +7,7 @@ source net_helper.sh
readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)" readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
BPF_FILE="../bpf/xdp_dummy.bpf.o" BPF_FILE="xdp_dummy.o"
# set global exit status, but never reset nonzero one. # set global exit status, but never reset nonzero one.
check_err() check_err()
...@@ -197,7 +197,7 @@ run_all() { ...@@ -197,7 +197,7 @@ run_all() {
} }
if [ ! -f ${BPF_FILE} ]; then if [ ! -f ${BPF_FILE} ]; then
echo "Missing ${BPF_FILE}. Build bpf selftest first" echo "Missing ${BPF_FILE}. Run 'make' first"
exit -1 exit -1
fi fi
......
...@@ -7,7 +7,7 @@ source net_helper.sh ...@@ -7,7 +7,7 @@ source net_helper.sh
readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)" readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
BPF_FILE="../bpf/xdp_dummy.bpf.o" BPF_FILE="xdp_dummy.o"
cleanup() { cleanup() {
local -r jobs="$(jobs -p)" local -r jobs="$(jobs -p)"
...@@ -84,7 +84,7 @@ run_all() { ...@@ -84,7 +84,7 @@ run_all() {
} }
if [ ! -f ${BPF_FILE} ]; then if [ ! -f ${BPF_FILE} ]; then
echo "Missing ${BPF_FILE}. Build bpf selftest first" echo "Missing ${BPF_FILE}. Run 'make' first"
exit -1 exit -1
fi fi
......
...@@ -7,7 +7,7 @@ source net_helper.sh ...@@ -7,7 +7,7 @@ source net_helper.sh
readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)" readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
BPF_FILE="../bpf/xdp_dummy.bpf.o" BPF_FILE="xdp_dummy.o"
cleanup() { cleanup() {
local -r jobs="$(jobs -p)" local -r jobs="$(jobs -p)"
...@@ -85,12 +85,12 @@ run_all() { ...@@ -85,12 +85,12 @@ run_all() {
} }
if [ ! -f ${BPF_FILE} ]; then if [ ! -f ${BPF_FILE} ]; then
echo "Missing ${BPF_FILE}. Build bpf selftest first" echo "Missing ${BPF_FILE}. Run 'make' first"
exit -1 exit -1
fi fi
if [ ! -f nat6to4.o ]; then if [ ! -f nat6to4.o ]; then
echo "Missing nat6to4 helper. Build bpf nat6to4.o selftest first" echo "Missing nat6to4 helper. Run 'make' first"
exit -1 exit -1
fi fi
......
#!/bin/bash #!/bin/bash
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
BPF_FILE="../bpf/xdp_dummy.bpf.o" BPF_FILE="xdp_dummy.o"
readonly BASE="ns-$(mktemp -u XXXXXX)" readonly BASE="ns-$(mktemp -u XXXXXX)"
readonly SRC=2 readonly SRC=2
readonly DST=1 readonly DST=1
......
#!/bin/sh #!/bin/sh
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
BPF_FILE="../bpf/xdp_dummy.bpf.o" BPF_FILE="xdp_dummy.o"
readonly STATS="$(mktemp -p /tmp ns-XXXXXX)" readonly STATS="$(mktemp -p /tmp ns-XXXXXX)"
readonly BASE=`basename $STATS` readonly BASE=`basename $STATS`
readonly SRC=2 readonly SRC=2
...@@ -218,7 +218,7 @@ while getopts "hs:" option; do ...@@ -218,7 +218,7 @@ while getopts "hs:" option; do
done done
if [ ! -f ${BPF_FILE} ]; then if [ ! -f ${BPF_FILE} ]; then
echo "Missing ${BPF_FILE}. Build bpf selftest first" echo "Missing ${BPF_FILE}. Run 'make' first"
exit 1 exit 1
fi fi
......
// SPDX-License-Identifier: GPL-2.0
#define KBUILD_MODNAME "xdp_dummy"
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>
SEC("xdp")
int xdp_dummy_prog(struct xdp_md *ctx)
{
return XDP_PASS;
}
char _license[] SEC("license") = "GPL";
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment