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

selftests/net: mv bpf/nat6to4.c to net folder

There are some issues with the bpf/nat6to4.c building.

1. It use TEST_CUSTOM_PROGS, which will add the nat6to4.o to
kselftest-list file and run by common run_tests.
2. When building the test via `make -C tools/testing/selftests/
TARGETS="net"`, the nat6to4.o will be build in selftests/net/bpf/
folder. But in test udpgro_frglist.sh it refers to ../bpf/nat6to4.o.
The correct path should be ./bpf/nat6to4.o.
3. If building the test via `make -C tools/testing/selftests/ TARGETS="net"
install`. The nat6to4.o will be installed to kselftest_install/net/
folder. Then the udpgro_frglist.sh should refer to ./nat6to4.o.

To fix the confusing test path, let's just move the nat6to4.c to net folder
and build it as TEST_GEN_FILES.

Fixes: edae34a3ed92 ("selftests net: add UDP GRO fraglist + bpf self-tests")
Tested-by: Björn Töpel <bjorn@kernel.org>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Link: https://lore.kernel.org/r/20230118020927.3971864-1-liuhangbin@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Hangbin Liu and committed by
Paolo Abeni
3c107f36 9ffb07a3

+52 -57
+48 -2
tools/testing/selftests/net/Makefile
··· 75 75 TEST_PROGS += sctp_vrf.sh 76 76 TEST_GEN_FILES += sctp_hello 77 77 TEST_GEN_FILES += csum 78 + TEST_GEN_FILES += nat6to4.o 78 79 79 80 TEST_FILES := settings 80 81 81 82 include ../lib.mk 82 83 83 - include bpf/Makefile 84 - 85 84 $(OUTPUT)/reuseport_bpf_numa: LDLIBS += -lnuma 86 85 $(OUTPUT)/tcp_mmap: LDLIBS += -lpthread 87 86 $(OUTPUT)/tcp_inq: LDLIBS += -lpthread 88 87 $(OUTPUT)/bind_bhash: LDLIBS += -lpthread 88 + 89 + # Rules to generate bpf obj nat6to4.o 90 + CLANG ?= clang 91 + SCRATCH_DIR := $(OUTPUT)/tools 92 + BUILD_DIR := $(SCRATCH_DIR)/build 93 + BPFDIR := $(abspath ../../../lib/bpf) 94 + APIDIR := $(abspath ../../../include/uapi) 95 + 96 + CCINCLUDE += -I../bpf 97 + CCINCLUDE += -I../../../../usr/include/ 98 + CCINCLUDE += -I$(SCRATCH_DIR)/include 99 + 100 + BPFOBJ := $(BUILD_DIR)/libbpf/libbpf.a 101 + 102 + MAKE_DIRS := $(BUILD_DIR)/libbpf 103 + $(MAKE_DIRS): 104 + mkdir -p $@ 105 + 106 + # Get Clang's default includes on this system, as opposed to those seen by 107 + # '-target bpf'. This fixes "missing" files on some architectures/distros, 108 + # such as asm/byteorder.h, asm/socket.h, asm/sockios.h, sys/cdefs.h etc. 109 + # 110 + # Use '-idirafter': Don't interfere with include mechanics except where the 111 + # build would have failed anyways. 112 + define get_sys_includes 113 + $(shell $(1) $(2) -v -E - </dev/null 2>&1 \ 114 + | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \ 115 + $(shell $(1) $(2) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}') 116 + endef 117 + 118 + ifneq ($(CROSS_COMPILE),) 119 + CLANG_TARGET_ARCH = --target=$(notdir $(CROSS_COMPILE:%-=%)) 120 + endif 121 + 122 + CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH)) 123 + 124 + $(OUTPUT)/nat6to4.o: nat6to4.c $(BPFOBJ) | $(MAKE_DIRS) 125 + $(CLANG) -O2 -target bpf -c $< $(CCINCLUDE) $(CLANG_SYS_INCLUDES) -o $@ 126 + 127 + $(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \ 128 + $(APIDIR)/linux/bpf.h \ 129 + | $(BUILD_DIR)/libbpf 130 + $(MAKE) $(submake_extras) -C $(BPFDIR) OUTPUT=$(BUILD_DIR)/libbpf/ \ 131 + EXTRA_CFLAGS='-g -O0' \ 132 + DESTDIR=$(SCRATCH_DIR) prefix= all install_headers 133 + 134 + EXTRA_CLEAN := $(SCRATCH_DIR)
-51
tools/testing/selftests/net/bpf/Makefile
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - 3 - CLANG ?= clang 4 - SCRATCH_DIR := $(OUTPUT)/tools 5 - BUILD_DIR := $(SCRATCH_DIR)/build 6 - BPFDIR := $(abspath ../../../lib/bpf) 7 - APIDIR := $(abspath ../../../include/uapi) 8 - 9 - CCINCLUDE += -I../../bpf 10 - CCINCLUDE += -I../../../../../usr/include/ 11 - CCINCLUDE += -I$(SCRATCH_DIR)/include 12 - 13 - BPFOBJ := $(BUILD_DIR)/libbpf/libbpf.a 14 - 15 - MAKE_DIRS := $(BUILD_DIR)/libbpf $(OUTPUT)/bpf 16 - $(MAKE_DIRS): 17 - mkdir -p $@ 18 - 19 - TEST_CUSTOM_PROGS = $(OUTPUT)/bpf/nat6to4.o 20 - all: $(TEST_CUSTOM_PROGS) 21 - 22 - # Get Clang's default includes on this system, as opposed to those seen by 23 - # '-target bpf'. This fixes "missing" files on some architectures/distros, 24 - # such as asm/byteorder.h, asm/socket.h, asm/sockios.h, sys/cdefs.h etc. 25 - # 26 - # Use '-idirafter': Don't interfere with include mechanics except where the 27 - # build would have failed anyways. 28 - define get_sys_includes 29 - $(shell $(1) $(2) -v -E - </dev/null 2>&1 \ 30 - | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \ 31 - $(shell $(1) $(2) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}') 32 - endef 33 - 34 - ifneq ($(CROSS_COMPILE),) 35 - CLANG_TARGET_ARCH = --target=$(notdir $(CROSS_COMPILE:%-=%)) 36 - endif 37 - 38 - CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH)) 39 - 40 - $(TEST_CUSTOM_PROGS): $(OUTPUT)/%.o: %.c $(BPFOBJ) | $(MAKE_DIRS) 41 - $(CLANG) -O2 -target bpf -c $< $(CCINCLUDE) $(CLANG_SYS_INCLUDES) -o $@ 42 - 43 - $(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \ 44 - $(APIDIR)/linux/bpf.h \ 45 - | $(BUILD_DIR)/libbpf 46 - $(MAKE) $(submake_extras) -C $(BPFDIR) OUTPUT=$(BUILD_DIR)/libbpf/ \ 47 - EXTRA_CFLAGS='-g -O0' \ 48 - DESTDIR=$(SCRATCH_DIR) prefix= all install_headers 49 - 50 - EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(SCRATCH_DIR) 51 -
tools/testing/selftests/net/bpf/nat6to4.c tools/testing/selftests/net/nat6to4.c
+4 -4
tools/testing/selftests/net/udpgro_frglist.sh
··· 40 40 41 41 ip -n "${PEER_NS}" link set veth1 xdp object ${BPF_FILE} section xdp 42 42 tc -n "${PEER_NS}" qdisc add dev veth1 clsact 43 - tc -n "${PEER_NS}" filter add dev veth1 ingress prio 4 protocol ipv6 bpf object-file ../bpf/nat6to4.o section schedcls/ingress6/nat_6 direct-action 44 - tc -n "${PEER_NS}" filter add dev veth1 egress prio 4 protocol ip bpf object-file ../bpf/nat6to4.o section schedcls/egress4/snat4 direct-action 43 + tc -n "${PEER_NS}" filter add dev veth1 ingress prio 4 protocol ipv6 bpf object-file nat6to4.o section schedcls/ingress6/nat_6 direct-action 44 + tc -n "${PEER_NS}" filter add dev veth1 egress prio 4 protocol ip bpf object-file nat6to4.o section schedcls/egress4/snat4 direct-action 45 45 echo ${rx_args} 46 46 ip netns exec "${PEER_NS}" ./udpgso_bench_rx ${rx_args} -r & 47 47 ··· 88 88 exit -1 89 89 fi 90 90 91 - if [ ! -f bpf/nat6to4.o ]; then 92 - echo "Missing nat6to4 helper. Build bpfnat6to4.o selftest first" 91 + if [ ! -f nat6to4.o ]; then 92 + echo "Missing nat6to4 helper. Build bpf nat6to4.o selftest first" 93 93 exit -1 94 94 fi 95 95