Skip to contentSkip to conversation

some fixes for selftest/net

PATCH Superseded Wang Yufen 3 participants 8 messages Nov 15, 2022 – Nov 18, 2022

Subsystems (5)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Wang Yufen

author
#0 lore raw

v2 cover some fixes for selftest/net

v1: https://lkml.kernel.org/netdev/[email protected]/T/

Wang Yufen (2):
selftests/net: fix missing xdp_dummy
selftests/net: fix opening object file failed

 tools/testing/selftests/bpf/Makefile               |   7 +-
 tools/testing/selftests/bpf/in_netns.sh            |  23 +
 .../testing/selftests/bpf/progs/nat6to4_egress4.c  | 184 ++++++
 .../testing/selftests/bpf/progs/nat6to4_ingress6.c | 149 +++++
 tools/testing/selftests/bpf/test_udpgro_frglist.sh | 110 ++++
 tools/testing/selftests/bpf/udpgso_bench_rx.c      | 409 ++++++++++++
 tools/testing/selftests/bpf/udpgso_bench_tx.c      | 712 +++++++++++++++++++++
 tools/testing/selftests/net/Makefile               |   2 -
 tools/testing/selftests/net/bpf/Makefile           |  14 -
 tools/testing/selftests/net/bpf/nat6to4.c          | 285 ---------
 tools/testing/selftests/net/udpgro.sh              |   6 +-
 tools/testing/selftests/net/udpgro_bench.sh        |   6 +-
 tools/testing/selftests/net/udpgro_frglist.sh      | 101 ---
 tools/testing/selftests/net/udpgro_fwd.sh          |   3 +-
 tools/testing/selftests/net/veth.sh                |   9 +-
 15 files changed, 1607 insertions(+), 413 deletions(-)
 create mode 100755 tools/testing/selftests/bpf/in_netns.sh
 create mode 100644 tools/testing/selftests/bpf/progs/nat6to4_egress4.c
 create mode 100644 tools/testing/selftests/bpf/progs/nat6to4_ingress6.c
 create mode 100755 tools/testing/selftests/bpf/test_udpgro_frglist.sh
 create mode 100644 tools/testing/selftests/bpf/udpgso_bench_rx.c
 create mode 100644 tools/testing/selftests/bpf/udpgso_bench_tx.c
 delete mode 100644 tools/testing/selftests/net/bpf/Makefile
 delete mode 100644 tools/testing/selftests/net/bpf/nat6to4.c
 delete mode 100755 tools/testing/selftests/net/udpgro_frglist.sh
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH v2 1/2 selftests/net: fix missing xdp_dummy

After commit afef88e65554 ("selftests/bpf: Store BPF object files with .bpf.o extension"), we should use xdp_dummy.bpf.o instade of xdp_dummy.o.

In addition, use the BPF_FILE variable to save the BPF object file name, which can be better identified and modified.

Fixes afef88e65554 ("selftests/bpf: Store BPF object files with .bpf.o extension")
Cc Daniel Müller <[email protected]>
---
 tools/testing/selftests/net/udpgro.sh         | 6 ++++--
 tools/testing/selftests/net/udpgro_bench.sh   | 6 ++++--
 tools/testing/selftests/net/udpgro_frglist.sh | 6 ++++--
 tools/testing/selftests/net/udpgro_fwd.sh     | 3 ++-
 tools/testing/selftests/net/veth.sh           | 9 +++++----
 5 files changed, 19 insertions(+), 11 deletions(-)
tools/testing/selftests/net/udpgro.sh +4 -2
index 6a443ca..a66d62e 100755
@@ -5,6 +5,8 @@
 
 readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
 
+BPF_FILE="../bpf/xdp_dummy.bpf.o"
+
 # set global exit status, but never reset nonzero one.
 check_err()
 {
@@ -34,7 +36,7 @@ cfg_veth() {
 	ip -netns "${PEER_NS}" addr add dev veth1 192.168.1.1/24
 	ip -netns "${PEER_NS}" addr add dev veth1 2001:db8::1/64 nodad
 	ip -netns "${PEER_NS}" link set dev veth1 up
-	ip -n "${PEER_NS}" link set veth1 xdp object ../bpf/xdp_dummy.o section xdp
+	ip -n "${PEER_NS}" link set veth1 xdp object ${BPF_FILE} section xdp
 }
 
 run_one() {
@@ -195,7 +197,7 @@ run_all() {
 	return $ret
 }
 
-if [ ! -f ../bpf/xdp_dummy.o ]; then
+if [ ! -f ${BPF_FILE} ]; then
 	echo "Missing xdp_dummy helper. Build bpf selftest first"
 	exit -1
 fi
tools/testing/selftests/net/udpgro_bench.sh +4 -2
index 8a1109a..09c4934 100755
@@ -5,6 +5,8 @@
 
 readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
 
+BPF_FILE="../bpf/xdp_dummy.bpf.o"
+
 cleanup() {
 	local -r jobs="$(jobs -p)"
 	local -r ns="$(ip netns list|grep $PEER_NS)"
@@ -34,7 +36,7 @@ run_one() {
 	ip -netns "${PEER_NS}" addr add dev veth1 2001:db8::1/64 nodad
 	ip -netns "${PEER_NS}" link set dev veth1 up
 
-	ip -n "${PEER_NS}" link set veth1 xdp object ../bpf/xdp_dummy.o section xdp
+	ip -n "${PEER_NS}" link set veth1 xdp object ${BPF_FILE} section xdp
 	ip netns exec "${PEER_NS}" ./udpgso_bench_rx ${rx_args} -r &
 	ip netns exec "${PEER_NS}" ./udpgso_bench_rx -t ${rx_args} -r &
 
@@ -80,7 +82,7 @@ run_all() {
 	run_udp "${ipv6_args}"
 }
 
-if [ ! -f ../bpf/xdp_dummy.o ]; then
+if [ ! -f ${BPF_FILE} ]; then
 	echo "Missing xdp_dummy helper. Build bpf selftest first"
 	exit -1
 fi
tools/testing/selftests/net/udpgro_frglist.sh +4 -2
index 7fe85ba..7f94175 100755
@@ -5,6 +5,8 @@
 
 readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
 
+BPF_FILE="../bpf/xdp_dummy.bpf.o"
+
 cleanup() {
 	local -r jobs="$(jobs -p)"
 	local -r ns="$(ip netns list|grep $PEER_NS)"
@@ -36,7 +38,7 @@ run_one() {
 	ip netns exec "${PEER_NS}" ethtool -K veth1 rx-gro-list on
 
 
-	ip -n "${PEER_NS}" link set veth1 xdp object ../bpf/xdp_dummy.o section xdp
+	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
@@ -81,7 +83,7 @@ run_all() {
 	run_udp "${ipv6_args}"
 }
 
-if [ ! -f ../bpf/xdp_dummy.o ]; then
+if [ ! -f ${BPF_FILE} ]; then
 	echo "Missing xdp_dummy helper. Build bpf selftest first"
 	exit -1
 fi
tools/testing/selftests/net/udpgro_fwd.sh +2 -1
index 1bcd82e..c079565 100755
@@ -1,6 +1,7 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
 
+BPF_FILE="../bpf/xdp_dummy.bpf.o"
 readonly BASE="ns-$(mktemp -u XXXXXX)"
 readonly SRC=2
 readonly DST=1
@@ -46,7 +47,7 @@ create_ns() {
 		ip -n $BASE$ns addr add dev veth$ns $BM_NET_V4$ns/24
 		ip -n $BASE$ns addr add dev veth$ns $BM_NET_V6$ns/64 nodad
 	done
-	ip -n $NS_DST link set veth$DST xdp object ../bpf/xdp_dummy.o section xdp 2>/dev/null
+	ip -n $NS_DST link set veth$DST xdp object ${BPF_FILE} section xdp 2>/dev/null
 }
 
 create_vxlan_endpoint() {
tools/testing/selftests/net/veth.sh +5 -4
index 430895d..c9732f7 100755
@@ -1,6 +1,7 @@
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0
 
+BPF_FILE="../bpf/xdp_dummy.bpf.o"
 readonly STATS="$(mktemp -p /tmp ns-XXXXXX)"
 readonly BASE=`basename $STATS`
 readonly SRC=2
@@ -216,7 +217,7 @@ while getopts "hs:" option; do
 	esac
 done
 
-if [ ! -f ../bpf/xdp_dummy.o ]; then
+if [ ! -f ${BPF_FILE} ]; then
 	echo "Missing xdp_dummy helper. Build bpf selftest first"
 	exit 1
 fi
@@ -288,14 +289,14 @@ if [ $CPUS -gt 1 ]; then
 	ip netns exec $NS_DST ethtool -L veth$DST rx 1 tx 2 2>/dev/null
 	ip netns exec $NS_SRC ethtool -L veth$SRC rx 1 tx 2 2>/dev/null
 	printf "%-60s" "bad setting: XDP with RX nr less than TX"
-	ip -n $NS_DST link set dev veth$DST xdp object ../bpf/xdp_dummy.o \
+	ip -n $NS_DST link set dev veth$DST xdp object ${BPF_FILE} \
 		section xdp 2>/dev/null &&\
 		echo "fail - set operation successful ?!?" || echo " ok "
 
 	# the following tests will run with multiple channels active
 	ip netns exec $NS_SRC ethtool -L veth$SRC rx 2
 	ip netns exec $NS_DST ethtool -L veth$DST rx 2
-	ip -n $NS_DST link set dev veth$DST xdp object ../bpf/xdp_dummy.o \
+	ip -n $NS_DST link set dev veth$DST xdp object ${BPF_FILE} \
 		section xdp 2>/dev/null
 	printf "%-60s" "bad setting: reducing RX nr below peer TX with XDP set"
 	ip netns exec $NS_DST ethtool -L veth$DST rx 1 2>/dev/null &&\
@@ -311,7 +312,7 @@ if [ $CPUS -gt 2 ]; then
 	chk_channels "setting invalid channels nr" $DST 2 2
 fi
 
-ip -n $NS_DST link set dev veth$DST xdp object ../bpf/xdp_dummy.o section xdp 2>/dev/null
+ip -n $NS_DST link set dev veth$DST xdp object ${BPF_FILE} section xdp 2>/dev/null
 chk_gro_flag "with xdp attached - gro flag" $DST on
 chk_gro_flag "        - peer gro flag" $SRC off
 chk_tso_flag "        - tso flag" $SRC off
Signature · 1 line
1.8.3.1
#2 lore raw

Re: [PATCH v2 1/2] selftests/net: fix missing xdp_dummy

Quoted 40 lines · Wang Yufen

After commit afef88e65554 ("selftests/bpf: Store BPF object files with .bpf.o extension"), we should use xdp_dummy.bpf.o instade of xdp_dummy.o.

In addition, use the BPF_FILE variable to save the BPF object file name, which can be better identified and modified.

Fixes afef88e65554 ("selftests/bpf: Store BPF object files with .bpf.o extension")
Cc Daniel Müller <[email protected]>

---

tools/testing/selftests/net/udpgro.sh         | 6 ++++--
tools/testing/selftests/net/udpgro_bench.sh   | 6 ++++--
tools/testing/selftests/net/udpgro_frglist.sh | 6 ++++--
tools/testing/selftests/net/udpgro_fwd.sh     | 3 ++-
tools/testing/selftests/net/veth.sh           | 9 +++++----
5 files changed, 19 insertions(+), 11 deletions(-)
tools/testing/selftests/net/udpgro.sh +0 -0
index 6a443ca..a66d62e 100755
@@ -5,6 +5,8 @@
 

readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"

tools/testing/selftests/net/udpgro.sh +2 -0
+BPF_FILE="../bpf/xdp_dummy.bpf.o"
+
# set global exit status, but never reset nonzero one.
check_err()
{
tools/testing/selftests/net/udpgro.sh +1 -1
@@ -34,7 +36,7 @@ cfg_veth() {
 	ip -netns "${PEER_NS}" addr add dev veth1 192.168.1.1/24
 	ip -netns "${PEER_NS}" addr add dev veth1 2001:db8::1/64 nodad
 	ip -netns "${PEER_NS}" link set dev veth1 up
-	ip -n "${PEER_NS}" link set veth1 xdp object ../bpf/xdp_dummy.o section xdp
+	ip -n "${PEER_NS}" link set veth1 xdp object ${BPF_FILE} section xdp
 }
 
 run_one() {

tools/testing/selftests/net/udpgro.sh run_all() { · line 201

Quoted 6 lines
tools/testing/selftests/net/udpgro.sh +1 -1
@@ -195,7 +197,7 @@ run_all() {
 	return $ret
 }
 
-if [ ! -f ../bpf/xdp_dummy.o ]; then
+if [ ! -f ${BPF_FILE} ]; then
 	echo "Missing xdp_dummy helper. Build bpf selftest first"

nit: I would improve the error message here to print ${BPF_FILE}. There are 3 more spots in the rest of this patch.

author
#3 lore raw

Re: [PATCH v2 1/2] selftests/net: fix missing xdp_dummy

Quoted 45 lines · Saeed Mahameed
Quoted 44 lines · Wang Yufen

After commit afef88e65554 ("selftests/bpf: Store BPF object files with .bpf.o extension"), we should use xdp_dummy.bpf.o instade of xdp_dummy.o.

In addition, use the BPF_FILE variable to save the BPF object file name, which can be better identified and modified.

Fixes afef88e65554 ("selftests/bpf: Store BPF object files with .bpf.o extension")
Cc Daniel Müller <[email protected]>

---
tools/testing/selftests/net/udpgro.sh         | 6 ++++-- tools/testing/selftests/net/udpgro_bench.sh   | 6 ++++-- tools/testing/selftests/net/udpgro_frglist.sh | 6 ++++-- tools/testing/selftests/net/udpgro_fwd.sh     | 3 ++- tools/testing/selftests/net/veth.sh           | 9 +++++----

5 files changed, 19 insertions(+), 11 deletions(-)
tools/testing/selftests/net/udpgro.sh +0 -0
index 6a443ca..a66d62e 100755
@@ -5,6 +5,8 @@
 

readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"

tools/testing/selftests/net/udpgro.sh +2 -0
+BPF_FILE="../bpf/xdp_dummy.bpf.o"
+
# set global exit status, but never reset nonzero one.
check_err()
{
tools/testing/selftests/net/udpgro.sh +0 -0
@@ -34,7 +36,7 @@ cfg_veth() {

    ip -netns "${PEER_NS}" addr add dev veth1 192.168.1.1/24 ip -netns "${PEER_NS}" addr add dev veth1 2001:db8::1/64 nodad ip -netns "${PEER_NS}" link set dev veth1 up
-    ip -n "${PEER_NS}" link set veth1 xdp object ../bpf/xdp_dummy.o section xdp
+    ip -n "${PEER_NS}" link set veth1 xdp object ${BPF_FILE} section xdp }

run_one() {

tools/testing/selftests/net/udpgro.sh +0 -0
@@ -195,7 +197,7 @@ run_all() {

    return $ret
}

Quoted 6 lines
Quoted 3 lines
tools/testing/selftests/net/udpgro.sh +1 -1
-if [ ! -f ../bpf/xdp_dummy.o ]; then
+if [ ! -f ${BPF_FILE} ]; then

    echo "Missing xdp_dummy helper. Build bpf selftest first"

nit: I would improve the error message here to print  ${BPF_FILE}. There are 3 more spots in the rest of this patch.

got it, thanks!

author
#4 lore raw

PATCH v2 2/2 selftests/net: fix opening object file failed

In reply to Wang Yufen

The program file used in the udpgro_frglist testcase is "../bpf/nat6to4.o", but the actual nat6to4.o file is in "bpf/" not "../bpf".
The following error occurs:
Error opening object ../bpf/nat6to4.o: No such file or directory Cannot initialize ELF context!
Unable to load program

In addition, all the kernel bpf source files are centred under the subdir "progs" after commit bd4aed0ee73c ("selftests: bpf: centre kernel bpf objects under new subdir "progs""). So mv nat6to4.c to "../bpf/progs" and use "../bpf/nat6to4.bpf.o". And also move the test program to selftests/bpf.

Fixes edae34a3ed92 ("selftests net: add UDP GRO fraglist + bpf self-tests")
---
 tools/testing/selftests/bpf/Makefile               |   7 +-
 tools/testing/selftests/bpf/in_netns.sh            |  23 +
 .../testing/selftests/bpf/progs/nat6to4_egress4.c  | 184 ++++++
 .../testing/selftests/bpf/progs/nat6to4_ingress6.c | 149 +++++
 tools/testing/selftests/bpf/test_udpgro_frglist.sh | 110 ++++
 tools/testing/selftests/bpf/udpgso_bench_rx.c      | 409 ++++++++++++
 tools/testing/selftests/bpf/udpgso_bench_tx.c      | 712 +++++++++++++++++++++
 tools/testing/selftests/net/Makefile               |   2 -
 tools/testing/selftests/net/bpf/Makefile           |  14 -
 tools/testing/selftests/net/bpf/nat6to4.c          | 285 ---------
 tools/testing/selftests/net/udpgro_frglist.sh      | 103 ---
 11 files changed, 1592 insertions(+), 406 deletions(-)
 create mode 100755 tools/testing/selftests/bpf/in_netns.sh
 create mode 100644 tools/testing/selftests/bpf/progs/nat6to4_egress4.c
 create mode 100644 tools/testing/selftests/bpf/progs/nat6to4_ingress6.c
 create mode 100755 tools/testing/selftests/bpf/test_udpgro_frglist.sh
 create mode 100644 tools/testing/selftests/bpf/udpgso_bench_rx.c
 create mode 100644 tools/testing/selftests/bpf/udpgso_bench_tx.c
 delete mode 100644 tools/testing/selftests/net/bpf/Makefile
 delete mode 100644 tools/testing/selftests/net/bpf/nat6to4.c
 delete mode 100755 tools/testing/selftests/net/udpgro_frglist.sh
tools/testing/selftests/bpf/Makefile +5 -2
index e6cf21f..e81e32d 100644
@@ -39,7 +39,9 @@ TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test
 	test_sock test_sockmap get_cgroup_id_user \
 	test_cgroup_storage \
 	test_tcpnotify_user test_sysctl \
-	test_progs-no_alu32
+	test_progs-no_alu32 \
+	udpgso_bench_rx \
+	udpgso_bench_tx
 
 # Also test bpf-gcc, if present
 ifneq ($(BPF_GCC),)
@@ -73,7 +75,8 @@ TEST_PROGS := test_kmod.sh \
 	test_bpftool.sh \
 	test_bpftool_metadata.sh \
 	test_doc_build.sh \
-	test_xsk.sh
+	test_xsk.sh \
+	test_udpgro_frglist.sh
 
 TEST_PROGS_EXTENDED := with_addr.sh \
 	with_tunnels.sh ima_setup.sh verify_sig_setup.sh \
tools/testing/selftests/bpf/in_netns.sh new file +23 -0
new file mode 100755
index 0000000..88795b5
@@ -0,0 +1,23 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# Execute a subprocess in a network namespace
+
+set -e
+
+readonly NETNS="ns-$(mktemp -u XXXXXX)"
+
+setup() {
+	ip netns add "${NETNS}"
+	ip -netns "${NETNS}" link set lo up
+}
+
+cleanup() {
+	ip netns del "${NETNS}"
+}
+
+trap cleanup EXIT
+setup
+
+ip netns exec "${NETNS}" "$@"
+exit "$?"
tools/testing/selftests/bpf/progs/nat6to4_egress4.c new file +184 -0

184 lines not on this page · raw message

tools/testing/selftests/bpf/progs/nat6to4_ingress6.c new file +149 -0

149 lines not on this page · raw message

tools/testing/selftests/bpf/test_udpgro_frglist.sh new file +110 -0

110 lines not on this page · raw message

tools/testing/selftests/bpf/udpgso_bench_rx.c new file +409 -0

409 lines not on this page · raw message

tools/testing/selftests/bpf/udpgso_bench_tx.c new file +712 -0

712 lines not on this page · raw message

tools/testing/selftests/net/Makefile +0 -2
index 69c5836..a2ac42a 100644
@@ -76,8 +76,6 @@ 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
tools/testing/selftests/net/bpf/Makefile deleted +0 -14
deleted file mode 100644
index 8ccaf87..0000000
@@ -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/bpf/nat6to4.c deleted +0 -285

285 lines not on this page · raw message

tools/testing/selftests/net/udpgro_frglist.sh deleted +0 -103

103 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#5 lore raw

Re: [PATCH v2 2/2] selftests/net: fix opening object file failed

Quoted 10 lines · Wang Yufen

The program file used in the udpgro_frglist testcase is "../bpf/nat6to4.o", but the actual nat6to4.o file is in "bpf/" not "../bpf".
The following error occurs:
Error opening object ../bpf/nat6to4.o: No such file or directory Cannot initialize ELF context!
Unable to load program

In addition, all the kernel bpf source files are centred under the subdir "progs" after commit bd4aed0ee73c ("selftests: bpf: centre kernel bpf objects under new subdir "progs""). So mv nat6to4.c to

                                                  ^^ move :) 
Quoted 3 lines

"../bpf/progs" and use "../bpf/nat6to4.bpf.o". And also move the test program to selftests/bpf.

Can you separate the fix from the mv ?

Quoted 15 lines
Fixes edae34a3ed92 ("selftests net: add UDP GRO fraglist + bpf self-tests")

---

tools/testing/selftests/bpf/Makefile               |   7 +-
tools/testing/selftests/bpf/in_netns.sh            |  23 +
.../testing/selftests/bpf/progs/nat6to4_egress4.c  | 184 ++++++
.../testing/selftests/bpf/progs/nat6to4_ingress6.c | 149 +++++
tools/testing/selftests/bpf/test_udpgro_frglist.sh | 110 ++++
tools/testing/selftests/bpf/udpgso_bench_rx.c      | 409 ++++++++++++
tools/testing/selftests/bpf/udpgso_bench_tx.c      | 712 +++++++++++++++++++++
tools/testing/selftests/net/Makefile               |   2 -
tools/testing/selftests/net/bpf/Makefile           |  14 -
tools/testing/selftests/net/bpf/nat6to4.c          | 285 ---------
tools/testing/selftests/net/udpgro_frglist.sh      | 103 ---
11 files changed, 1592 insertions(+), 406 deletions(-)
Quoted 10 lines

create mode 100755 tools/testing/selftests/bpf/in_netns.sh create mode 100644 tools/testing/selftests/bpf/progs/nat6to4_egress4.c create mode 100644 tools/testing/selftests/bpf/progs/nat6to4_ingress6.c create mode 100755 tools/testing/selftests/bpf/test_udpgro_frglist.sh create mode 100644 tools/testing/selftests/bpf/udpgso_bench_rx.c create mode 100644 tools/testing/selftests/bpf/udpgso_bench_tx.c delete mode 100644 tools/testing/selftests/net/bpf/Makefile delete mode 100644 tools/testing/selftests/net/bpf/nat6to4.c delete mode 100755 tools/testing/selftests/net/udpgro_frglist.sh

created more files than deleted? also moving files should appear as rename. Did you do the mv with git mv ? I am surprised how git didn't pick this up as "rename".

For next version please use tag [PATCH bpf-next]

author
#6 lore raw

Re: [PATCH v2 2/2] selftests/net: fix opening object file failed

Quoted 8 lines · Saeed Mahameed
Quoted 7 lines · Wang Yufen

The program file used in the udpgro_frglist testcase is "../bpf/nat6to4.o", but the actual nat6to4.o file is in "bpf/" not "../bpf".
The following error occurs:
 Error opening object ../bpf/nat6to4.o: No such file or directory Cannot initialize ELF context!
 Unable to load program

Quoted 4 lines
Quoted 3 lines

In addition, all the kernel bpf source files are centred under the subdir "progs" after commit bd4aed0ee73c ("selftests: bpf: centre kernel bpf objects under new subdir "progs""). So mv nat6to4.c to

                                                  ^^ move :)

got it :)

Quoted 5 lines
Quoted 3 lines

"../bpf/progs" and use "../bpf/nat6to4.bpf.o". And also move the test program to selftests/bpf.

Can you separate the fix from the mv ?

got it, will change in v3

Quoted 28 lines
Quoted 17 lines
Fixes edae34a3ed92 ("selftests net: add UDP GRO fraglist + bpf self-tests")

---
tools/testing/selftests/bpf/Makefile               |   7 +- tools/testing/selftests/bpf/in_netns.sh            |  23 + .../testing/selftests/bpf/progs/nat6to4_egress4.c  | 184 ++++++ .../testing/selftests/bpf/progs/nat6to4_ingress6.c | 149 +++++ tools/testing/selftests/bpf/test_udpgro_frglist.sh | 110 ++++ tools/testing/selftests/bpf/udpgso_bench_rx.c      | 409 ++++++++++++ tools/testing/selftests/bpf/udpgso_bench_tx.c      | 712
+++++++++++++++++++++
tools/testing/selftests/net/Makefile               |   2 - tools/testing/selftests/net/bpf/Makefile           |  14 - tools/testing/selftests/net/bpf/nat6to4.c          | 285 --------- tools/testing/selftests/net/udpgro_frglist.sh      | 103 ---

11 files changed, 1592 insertions(+), 406 deletions(-)
Quoted 10 lines

create mode 100755 tools/testing/selftests/bpf/in_netns.sh create mode 100644 tools/testing/selftests/bpf/progs/nat6to4_egress4.c create mode 100644 tools/testing/selftests/bpf/progs/nat6to4_ingress6.c create mode 100755 tools/testing/selftests/bpf/test_udpgro_frglist.sh create mode 100644 tools/testing/selftests/bpf/udpgso_bench_rx.c create mode 100644 tools/testing/selftests/bpf/udpgso_bench_tx.c delete mode 100644 tools/testing/selftests/net/bpf/Makefile delete mode 100644 tools/testing/selftests/net/bpf/nat6to4.c delete mode 100755 tools/testing/selftests/net/udpgro_frglist.sh

Quoted 3 lines

created more files than deleted? also moving files should appear as rename. Did you do the mv with git mv ? I am surprised how git didn't pick this up as "rename".

in_netns.sh,udpgso_bench_rx.c and udpgso_bench_tx.c also used by other tests of selftests/net, so create new copy here.
The two progs of nat6to4.c are separately defined in nat6to4_ingress6.c and nat6to4_egress4.c files. SEC("schedcls/ingress6/nat_6") and SEC("schedcls/egress4/snat4") are defined as SEC ("tc"). I will separate the fix from the mv in v3

Quoted 2 lines

For next version please use tag [PATCH bpf-next]

got it.
Thanks.

#7 lore raw

Re: [PATCH v2 2/2] selftests/net: fix opening object file failed

In reply to Wang Yufen
Quoted 13 lines · Wang Yufen

The program file used in the udpgro_frglist testcase is "../bpf/nat6to4.o", but the actual nat6to4.o file is in "bpf/" not "../bpf".
The following error occurs:
Error opening object ../bpf/nat6to4.o: No such file or directory Cannot initialize ELF context!
Unable to load program

In addition, all the kernel bpf source files are centred under the subdir "progs" after commit bd4aed0ee73c ("selftests: bpf: centre kernel bpf objects under new subdir "progs""). So mv nat6to4.c to "../bpf/progs" and use "../bpf/nat6to4.bpf.o". And also move the test program to selftests/bpf.

Quoted 8 lines
Fixes edae34a3ed92 ("selftests net: add UDP GRO fraglist + bpf self-tests")
---
  tools/testing/selftests/bpf/Makefile               |   7 +-
  tools/testing/selftests/bpf/in_netns.sh            |  23 +
  .../testing/selftests/bpf/progs/nat6to4_egress4.c  | 184 ++++++
  .../testing/selftests/bpf/progs/nat6to4_ingress6.c | 149 +++++
  tools/testing/selftests/bpf/test_udpgro_frglist.sh | 110 ++++

Love to have more tests in the BPF CI which is run continuously: eg: https://github.com/kernel-patches/bpf/actions/runs/3491826279/jobs/5845219757

However, script like this does not get run in CI. test_progs has a more consistent error output and ensures some environment cleanup before running the next test. Please take some effort to adapt this test to the bpf/test_progs.c framework which had already been suggested in the previous revision.

Try to run ./test_progs under the bpf selftests directory. There are existing examples to setup/switch net ns and test_progs has logic in place to ensure the netns is restored before running the next selftest. eg. take a look at bpf/prog_tests/{test_tunnel,tc_redirect}.c.

Quoted 2 lines
  tools/testing/selftests/bpf/udpgso_bench_rx.c      | 409 ++++++++++++
  tools/testing/selftests/bpf/udpgso_bench_tx.c      | 712 +++++++++++++++++++++

hmmm, it is a copy? Does it need all the bench marking feature (e.g. all the cmd args)? If not, please simply because I expect the test_udpgro_frglist.sh, udpgso_bench_rx.c, and udpgso_bench_tx.c will become one file 'selftests/bpf/prog_tests/udpgrp_frglish.c' which loads the bpf prog and generates traffic to exercise the bpf prog.

Please tag it with bpf-next in the next spin which Saeed has also mentioned in another thread.

Quoted 14 lines
  tools/testing/selftests/net/Makefile               |   2 -
  tools/testing/selftests/net/bpf/Makefile           |  14 -
  tools/testing/selftests/net/bpf/nat6to4.c          | 285 ---------
  tools/testing/selftests/net/udpgro_frglist.sh      | 103 ---
  11 files changed, 1592 insertions(+), 406 deletions(-)

create mode 100755 tools/testing/selftests/bpf/in_netns.sh create mode 100644 tools/testing/selftests/bpf/progs/nat6to4_egress4.c create mode 100644 tools/testing/selftests/bpf/progs/nat6to4_ingress6.c create mode 100755 tools/testing/selftests/bpf/test_udpgro_frglist.sh create mode 100644 tools/testing/selftests/bpf/udpgso_bench_rx.c create mode 100644 tools/testing/selftests/bpf/udpgso_bench_tx.c delete mode 100644 tools/testing/selftests/net/bpf/Makefile delete mode 100644 tools/testing/selftests/net/bpf/nat6to4.c delete mode 100755 tools/testing/selftests/net/udpgro_frglist.sh