Skip to contentSkip to conversation

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

PATCH Superseded Hangbin Liu 2 participants 2 messages Dec 13, 2022 – Dec 15, 2022

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 tools/testing/selftests/net/Makefile            | 11 +++++++++--
 tools/testing/selftests/net/bpf/Makefile        | 14 --------------
 tools/testing/selftests/net/{bpf => }/nat6to4.c |  0
 tools/testing/selftests/net/udpgro_frglist.sh   |  6 +++---
 4 files changed, 12 insertions(+), 19 deletions(-)
 delete mode 100644 tools/testing/selftests/net/bpf/Makefile
 rename tools/testing/selftests/net/{bpf => }/nat6to4.c (100%)
tools/testing/selftests/net/Makefile +9 -2
index 69c58362c0ed..d1495107a320 100644
@@ -71,14 +71,21 @@ TEST_GEN_FILES += bind_bhash
 TEST_GEN_PROGS += sk_bind_sendto_listen
 TEST_GEN_PROGS += sk_connect_zero_addr
 TEST_PROGS += test_ingress_egress_chaining.sh
+TEST_GEN_FILES += nat6to4.o
 
 TEST_FILES := settings
 
 include ../lib.mk
 
-include bpf/Makefile
-
 $(OUTPUT)/reuseport_bpf_numa: LDLIBS += -lnuma
 $(OUTPUT)/tcp_mmap: LDLIBS += -lpthread
 $(OUTPUT)/tcp_inq: LDLIBS += -lpthread
 $(OUTPUT)/bind_bhash: LDLIBS += -lpthread
+
+CLANG ?= clang
+CCINCLUDE += -I../bpf
+CCINCLUDE += -I../../../lib
+CCINCLUDE += -I../../../../usr/include/
+
+$(OUTPUT)/nat6to4.o: nat6to4.c
+	$(CLANG) -O2 -target bpf -c $< $(CCINCLUDE) -o $@
tools/testing/selftests/net/bpf/Makefile deleted +0 -14
deleted file mode 100644
index 8ccaf8732eb2..000000000000
@@ -1,14 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-
-CLANG ?= clang
-CCINCLUDE += -I../../bpf
-CCINCLUDE += -I../../../../lib
-CCINCLUDE += -I../../../../../usr/include/
-
-TEST_CUSTOM_PROGS = $(OUTPUT)/bpf/nat6to4.o
-all: $(TEST_CUSTOM_PROGS)
-
-$(OUTPUT)/%.o: %.c
-	$(CLANG) -O2 -target bpf -c $< $(CCINCLUDE) -o $@
-
-EXTRA_CLEAN := $(TEST_CUSTOM_PROGS)
tools/testing/selftests/net/nat6to4.c renamed from tools/testing/selftests/net/bpf/nat6to4.c +0 -0
similarity index 100%
rename from tools/testing/selftests/net/bpf/nat6to4.c
rename to tools/testing/selftests/net/nat6to4.c
tools/testing/selftests/net/udpgro_frglist.sh +3 -3
index c9c4b9d65839..4f58444c90a1 100755
@@ -40,8 +40,8 @@ run_one() {
 
 	ip -n "${PEER_NS}" link set veth1 xdp object ${BPF_FILE} section xdp
 	tc -n "${PEER_NS}" qdisc add dev veth1 clsact
-	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
-	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
+	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
+	tc -n "${PEER_NS}" filter add dev veth1 egress prio 4 protocol ip bpf object-file nat6to4.o section schedcls/egress4/snat4 direct-action
         echo ${rx_args}
 	ip netns exec "${PEER_NS}" ./udpgso_bench_rx ${rx_args} -r &
 
@@ -88,7 +88,7 @@ if [ ! -f ${BPF_FILE} ]; then
 	exit -1
 fi
 
-if [ ! -f bpf/nat6to4.o ]; then
+if [ ! -f nat6to4.o ]; then
 	echo "Missing nat6to4 helper. Build bpfnat6to4.o selftest first"
 	exit -1
 fi
Signature · 1 line
2.38.1
maintainer
#1 lore raw

Hello,

Quoted 64 lines · Hangbin Liu

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")
---
 tools/testing/selftests/net/Makefile            | 11 +++++++++--
 tools/testing/selftests/net/bpf/Makefile        | 14 --------------
 tools/testing/selftests/net/{bpf => }/nat6to4.c |  0
 tools/testing/selftests/net/udpgro_frglist.sh   |  6 +++---
 4 files changed, 12 insertions(+), 19 deletions(-)
 delete mode 100644 tools/testing/selftests/net/bpf/Makefile
 rename tools/testing/selftests/net/{bpf => }/nat6to4.c (100%)
tools/testing/selftests/net/Makefile +9 -2
index 69c58362c0ed..d1495107a320 100644
@@ -71,14 +71,21 @@ TEST_GEN_FILES += bind_bhash
 TEST_GEN_PROGS += sk_bind_sendto_listen
 TEST_GEN_PROGS += sk_connect_zero_addr
 TEST_PROGS += test_ingress_egress_chaining.sh
+TEST_GEN_FILES += nat6to4.o
 
 TEST_FILES := settings
 
 include ../lib.mk
 
-include bpf/Makefile
-
 $(OUTPUT)/reuseport_bpf_numa: LDLIBS += -lnuma
 $(OUTPUT)/tcp_mmap: LDLIBS += -lpthread
 $(OUTPUT)/tcp_inq: LDLIBS += -lpthread
 $(OUTPUT)/bind_bhash: LDLIBS += -lpthread
+
+CLANG ?= clang
+CCINCLUDE += -I../bpf
+CCINCLUDE += -I../../../lib
+CCINCLUDE += -I../../../../usr/include/
+
+$(OUTPUT)/nat6to4.o: nat6to4.c
+	$(CLANG) -O2 -target bpf -c $< $(CCINCLUDE) -o $@
tools/testing/selftests/net/bpf/Makefile deleted +0 -4
deleted file mode 100644
index 8ccaf8732eb2..000000000000
@@ -1,14 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-
-CLANG ?= clang
-CCINCLUDE += -I../../bpf

tools/testing/selftests/net/bpf/Makefile line 14

Quoted 10 lines
tools/testing/selftests/net/bpf/Makefile deleted +0 -10
-CCINCLUDE += -I../../../../lib
-CCINCLUDE += -I../../../../../usr/include/
-
-TEST_CUSTOM_PROGS = $(OUTPUT)/bpf/nat6to4.o
-all: $(TEST_CUSTOM_PROGS)
-
-$(OUTPUT)/%.o: %.c
-	$(CLANG) -O2 -target bpf -c $< $(CCINCLUDE) -o $@
-
-EXTRA_CLEAN := $(TEST_CUSTOM_PROGS)

With the above, nat6to4.o is going to lose the cross compilation support introduced with commit 837a3d66d698 ("selftests: net: Add cross-compilation support for BPF programs"), you need to include such make builerplate, too.

Side note: it would be nice to factor out the cross-compiler ebpf and libbpf support into lib.mk or the like.

Thanks!

Paolo