Skip to content

Commit 98af374

Browse files
wangyufen316Alexei Starovoitov
authored andcommitted
selftests/bpf: fix missing BPF object files
After commit afef88e ("selftests/bpf: Store BPF object files with .bpf.o extension"), we should use *.bpf.o instead of *.o. In addition, use the BPF_FILE variable to save the BPF object file name, which can be better identified and modified. Fixes: afef88e ("selftests/bpf: Store BPF object files with .bpf.o extension") Signed-off-by: Wang Yufen <wangyufen@huawei.com> Acked-by: Stanislav Fomichev <sdf@google.com> Link: https://lore.kernel.org/r/1666235134-562-1-git-send-email-wangyufen@huawei.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent fb73a20 commit 98af374

File tree

9 files changed

+40
-29
lines changed

9 files changed

+40
-29
lines changed

tools/testing/selftests/bpf/test_bpftool_metadata.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
# Kselftest framework requirement - SKIP code is 4.
55
ksft_skip=4
66

7+
BPF_FILE_USED="metadata_used.bpf.o"
8+
BPF_FILE_UNUSED="metadata_unused.bpf.o"
9+
710
TESTNAME=bpftool_metadata
811
BPF_FS=$(awk '$3 == "bpf" {print $2; exit}' /proc/mounts)
912
BPF_DIR=$BPF_FS/test_$TESTNAME
@@ -55,7 +58,7 @@ mkdir $BPF_DIR
5558

5659
trap cleanup EXIT
5760

58-
bpftool prog load metadata_unused.o $BPF_DIR/unused
61+
bpftool prog load $BPF_FILE_UNUSED $BPF_DIR/unused
5962

6063
METADATA_PLAIN="$(bpftool prog)"
6164
echo "$METADATA_PLAIN" | grep 'a = "foo"' > /dev/null
@@ -67,7 +70,7 @@ bpftool map | grep 'metadata.rodata' > /dev/null
6770

6871
rm $BPF_DIR/unused
6972

70-
bpftool prog load metadata_used.o $BPF_DIR/used
73+
bpftool prog load $BPF_FILE_USED $BPF_DIR/used
7174

7275
METADATA_PLAIN="$(bpftool prog)"
7376
echo "$METADATA_PLAIN" | grep 'a = "bar"' > /dev/null

tools/testing/selftests/bpf/test_flow_dissector.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# SPDX-License-Identifier: GPL-2.0
33
#
44
# Load BPF flow dissector and verify it correctly dissects traffic
5+
6+
BPF_FILE="bpf_flow.bpf.o"
57
export TESTNAME=test_flow_dissector
68
unmount=0
79

@@ -22,7 +24,7 @@ if [[ -z $(ip netns identify $$) ]]; then
2224
if bpftool="$(which bpftool)"; then
2325
echo "Testing global flow dissector..."
2426

25-
$bpftool prog loadall ./bpf_flow.o /sys/fs/bpf/flow \
27+
$bpftool prog loadall $BPF_FILE /sys/fs/bpf/flow \
2628
type flow_dissector
2729

2830
if ! unshare --net $bpftool prog attach pinned \
@@ -95,7 +97,7 @@ else
9597
fi
9698

9799
# Attach BPF program
98-
./flow_dissector_load -p bpf_flow.o -s _dissect
100+
./flow_dissector_load -p $BPF_FILE -s _dissect
99101

100102
# Setup
101103
tc qdisc add dev lo ingress

tools/testing/selftests/bpf/test_lwt_ip_encap.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
# ping: SRC->[encap at veth2:ingress]->GRE:decap->DST
3939
# ping replies go DST->SRC directly
4040

41+
BPF_FILE="test_lwt_ip_encap.bpf.o"
4142
if [[ $EUID -ne 0 ]]; then
4243
echo "This script must be run as root"
4344
echo "FAIL"
@@ -373,14 +374,14 @@ test_egress()
373374
# install replacement routes (LWT/eBPF), pings succeed
374375
if [ "${ENCAP}" == "IPv4" ] ; then
375376
ip -netns ${NS1} route add ${IPv4_DST} encap bpf xmit obj \
376-
test_lwt_ip_encap.o sec encap_gre dev veth1 ${VRF}
377+
${BPF_FILE} sec encap_gre dev veth1 ${VRF}
377378
ip -netns ${NS1} -6 route add ${IPv6_DST} encap bpf xmit obj \
378-
test_lwt_ip_encap.o sec encap_gre dev veth1 ${VRF}
379+
${BPF_FILE} sec encap_gre dev veth1 ${VRF}
379380
elif [ "${ENCAP}" == "IPv6" ] ; then
380381
ip -netns ${NS1} route add ${IPv4_DST} encap bpf xmit obj \
381-
test_lwt_ip_encap.o sec encap_gre6 dev veth1 ${VRF}
382+
${BPF_FILE} sec encap_gre6 dev veth1 ${VRF}
382383
ip -netns ${NS1} -6 route add ${IPv6_DST} encap bpf xmit obj \
383-
test_lwt_ip_encap.o sec encap_gre6 dev veth1 ${VRF}
384+
${BPF_FILE} sec encap_gre6 dev veth1 ${VRF}
384385
else
385386
echo " unknown encap ${ENCAP}"
386387
TEST_STATUS=1
@@ -431,14 +432,14 @@ test_ingress()
431432
# install replacement routes (LWT/eBPF), pings succeed
432433
if [ "${ENCAP}" == "IPv4" ] ; then
433434
ip -netns ${NS2} route add ${IPv4_DST} encap bpf in obj \
434-
test_lwt_ip_encap.o sec encap_gre dev veth2 ${VRF}
435+
${BPF_FILE} sec encap_gre dev veth2 ${VRF}
435436
ip -netns ${NS2} -6 route add ${IPv6_DST} encap bpf in obj \
436-
test_lwt_ip_encap.o sec encap_gre dev veth2 ${VRF}
437+
${BPF_FILE} sec encap_gre dev veth2 ${VRF}
437438
elif [ "${ENCAP}" == "IPv6" ] ; then
438439
ip -netns ${NS2} route add ${IPv4_DST} encap bpf in obj \
439-
test_lwt_ip_encap.o sec encap_gre6 dev veth2 ${VRF}
440+
${BPF_FILE} sec encap_gre6 dev veth2 ${VRF}
440441
ip -netns ${NS2} -6 route add ${IPv6_DST} encap bpf in obj \
441-
test_lwt_ip_encap.o sec encap_gre6 dev veth2 ${VRF}
442+
${BPF_FILE} sec encap_gre6 dev veth2 ${VRF}
442443
else
443444
echo "FAIL: unknown encap ${ENCAP}"
444445
TEST_STATUS=1

tools/testing/selftests/bpf/test_lwt_seg6local.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
# Kselftest framework requirement - SKIP code is 4.
2525
ksft_skip=4
26+
BPF_FILE="test_lwt_seg6local.bpf.o"
2627
readonly NS1="ns1-$(mktemp -u XXXXXX)"
2728
readonly NS2="ns2-$(mktemp -u XXXXXX)"
2829
readonly NS3="ns3-$(mktemp -u XXXXXX)"
@@ -117,18 +118,18 @@ ip netns exec ${NS6} ip -6 addr add fb00::109/16 dev veth10 scope link
117118
ip netns exec ${NS1} ip -6 addr add fb00::1/16 dev lo
118119
ip netns exec ${NS1} ip -6 route add fb00::6 dev veth1 via fb00::21
119120

120-
ip netns exec ${NS2} ip -6 route add fb00::6 encap bpf in obj test_lwt_seg6local.o sec encap_srh dev veth2
121+
ip netns exec ${NS2} ip -6 route add fb00::6 encap bpf in obj ${BPF_FILE} sec encap_srh dev veth2
121122
ip netns exec ${NS2} ip -6 route add fd00::1 dev veth3 via fb00::43 scope link
122123

123124
ip netns exec ${NS3} ip -6 route add fc42::1 dev veth5 via fb00::65
124-
ip netns exec ${NS3} ip -6 route add fd00::1 encap seg6local action End.BPF endpoint obj test_lwt_seg6local.o sec add_egr_x dev veth4
125+
ip netns exec ${NS3} ip -6 route add fd00::1 encap seg6local action End.BPF endpoint obj ${BPF_FILE} sec add_egr_x dev veth4
125126

126-
ip netns exec ${NS4} ip -6 route add fd00::2 encap seg6local action End.BPF endpoint obj test_lwt_seg6local.o sec pop_egr dev veth6
127+
ip netns exec ${NS4} ip -6 route add fd00::2 encap seg6local action End.BPF endpoint obj ${BPF_FILE} sec pop_egr dev veth6
127128
ip netns exec ${NS4} ip -6 addr add fc42::1 dev lo
128129
ip netns exec ${NS4} ip -6 route add fd00::3 dev veth7 via fb00::87
129130

130131
ip netns exec ${NS5} ip -6 route add fd00::4 table 117 dev veth9 via fb00::109
131-
ip netns exec ${NS5} ip -6 route add fd00::3 encap seg6local action End.BPF endpoint obj test_lwt_seg6local.o sec inspect_t dev veth8
132+
ip netns exec ${NS5} ip -6 route add fd00::3 encap seg6local action End.BPF endpoint obj ${BPF_FILE} sec inspect_t dev veth8
132133

133134
ip netns exec ${NS6} ip -6 addr add fb00::6/16 dev lo
134135
ip netns exec ${NS6} ip -6 addr add fd00::4/16 dev lo

tools/testing/selftests/bpf/test_tc_edt.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# with dst port = 9000 down to 5MBps. Then it measures actual
66
# throughput of the flow.
77

8+
BPF_FILE="test_tc_edt.bpf.o"
89
if [[ $EUID -ne 0 ]]; then
910
echo "This script must be run as root"
1011
echo "FAIL"
@@ -54,7 +55,7 @@ ip -netns ${NS_DST} route add ${IP_SRC}/32 dev veth_dst
5455
ip netns exec ${NS_SRC} tc qdisc add dev veth_src root fq
5556
ip netns exec ${NS_SRC} tc qdisc add dev veth_src clsact
5657
ip netns exec ${NS_SRC} tc filter add dev veth_src egress \
57-
bpf da obj test_tc_edt.o sec cls_test
58+
bpf da obj ${BPF_FILE} sec cls_test
5859

5960

6061
# start the listener

tools/testing/selftests/bpf/test_tc_tunnel.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44
# In-place tunneling
55

6+
BPF_FILE="test_tc_tunnel.bpf.o"
67
# must match the port that the bpf program filters on
78
readonly port=8000
89

@@ -196,7 +197,7 @@ verify_data
196197
# client can no longer connect
197198
ip netns exec "${ns1}" tc qdisc add dev veth1 clsact
198199
ip netns exec "${ns1}" tc filter add dev veth1 egress \
199-
bpf direct-action object-file ./test_tc_tunnel.o \
200+
bpf direct-action object-file ${BPF_FILE} \
200201
section "encap_${tuntype}_${mac}"
201202
echo "test bpf encap without decap (expect failure)"
202203
server_listen
@@ -296,7 +297,7 @@ fi
296297
ip netns exec "${ns2}" ip link del dev testtun0
297298
ip netns exec "${ns2}" tc qdisc add dev veth2 clsact
298299
ip netns exec "${ns2}" tc filter add dev veth2 ingress \
299-
bpf direct-action object-file ./test_tc_tunnel.o section decap
300+
bpf direct-action object-file ${BPF_FILE} section decap
300301
echo "test bpf encap with bpf decap"
301302
client_connect
302303
verify_data

tools/testing/selftests/bpf/test_tunnel.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
# 5) Tunnel protocol handler, ex: vxlan_rcv, decap the packet
4646
# 6) Forward the packet to the overlay tnl dev
4747

48+
BPF_FILE="test_tunnel_kern.bpf.o"
4849
BPF_PIN_TUNNEL_DIR="/sys/fs/bpf/tc/tunnel"
4950
PING_ARG="-c 3 -w 10 -q"
5051
ret=0
@@ -545,7 +546,7 @@ test_xfrm_tunnel()
545546
> /sys/kernel/debug/tracing/trace
546547
setup_xfrm_tunnel
547548
mkdir -p ${BPF_PIN_TUNNEL_DIR}
548-
bpftool prog loadall ./test_tunnel_kern.o ${BPF_PIN_TUNNEL_DIR}
549+
bpftool prog loadall ${BPF_FILE} ${BPF_PIN_TUNNEL_DIR}
549550
tc qdisc add dev veth1 clsact
550551
tc filter add dev veth1 proto ip ingress bpf da object-pinned \
551552
${BPF_PIN_TUNNEL_DIR}/xfrm_get_state
@@ -572,7 +573,7 @@ attach_bpf()
572573
SET=$2
573574
GET=$3
574575
mkdir -p ${BPF_PIN_TUNNEL_DIR}
575-
bpftool prog loadall ./test_tunnel_kern.o ${BPF_PIN_TUNNEL_DIR}/
576+
bpftool prog loadall ${BPF_FILE} ${BPF_PIN_TUNNEL_DIR}/
576577
tc qdisc add dev $DEV clsact
577578
tc filter add dev $DEV egress bpf da object-pinned ${BPF_PIN_TUNNEL_DIR}/$SET
578579
tc filter add dev $DEV ingress bpf da object-pinned ${BPF_PIN_TUNNEL_DIR}/$GET

tools/testing/selftests/bpf/test_xdp_meta.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/sh
22

3+
BPF_FILE="test_xdp_meta.bpf.o"
34
# Kselftest framework requirement - SKIP code is 4.
45
readonly KSFT_SKIP=4
56
readonly NS1="ns1-$(mktemp -u XXXXXX)"
@@ -42,11 +43,11 @@ ip netns exec ${NS2} ip addr add 10.1.1.22/24 dev veth2
4243
ip netns exec ${NS1} tc qdisc add dev veth1 clsact
4344
ip netns exec ${NS2} tc qdisc add dev veth2 clsact
4445

45-
ip netns exec ${NS1} tc filter add dev veth1 ingress bpf da obj test_xdp_meta.o sec t
46-
ip netns exec ${NS2} tc filter add dev veth2 ingress bpf da obj test_xdp_meta.o sec t
46+
ip netns exec ${NS1} tc filter add dev veth1 ingress bpf da obj ${BPF_FILE} sec t
47+
ip netns exec ${NS2} tc filter add dev veth2 ingress bpf da obj ${BPF_FILE} sec t
4748

48-
ip netns exec ${NS1} ip link set dev veth1 xdp obj test_xdp_meta.o sec x
49-
ip netns exec ${NS2} ip link set dev veth2 xdp obj test_xdp_meta.o sec x
49+
ip netns exec ${NS1} ip link set dev veth1 xdp obj ${BPF_FILE} sec x
50+
ip netns exec ${NS2} ip link set dev veth2 xdp obj ${BPF_FILE} sec x
5051

5152
ip netns exec ${NS1} ip link set dev veth1 up
5253
ip netns exec ${NS2} ip link set dev veth2 up

tools/testing/selftests/bpf/test_xdp_vlan.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,19 +200,19 @@ ip netns exec ${NS2} sh -c 'ping -W 1 -c 1 100.64.41.1 || echo "Success: First p
200200
# ----------------------------------------------------------------------
201201
# In ns1: ingress use XDP to remove VLAN tags
202202
export DEVNS1=veth1
203-
export FILE=test_xdp_vlan.o
203+
export BPF_FILE=test_xdp_vlan.bpf.o
204204

205205
# First test: Remove VLAN by setting VLAN ID 0, using "xdp_vlan_change"
206206
export XDP_PROG=xdp_vlan_change
207-
ip netns exec ${NS1} ip link set $DEVNS1 $XDP_MODE object $FILE section $XDP_PROG
207+
ip netns exec ${NS1} ip link set $DEVNS1 $XDP_MODE object $BPF_FILE section $XDP_PROG
208208

209209
# In ns1: egress use TC to add back VLAN tag 4011
210210
# (del cmd)
211211
# tc qdisc del dev $DEVNS1 clsact 2> /dev/null
212212
#
213213
ip netns exec ${NS1} tc qdisc add dev $DEVNS1 clsact
214214
ip netns exec ${NS1} tc filter add dev $DEVNS1 egress \
215-
prio 1 handle 1 bpf da obj $FILE sec tc_vlan_push
215+
prio 1 handle 1 bpf da obj $BPF_FILE sec tc_vlan_push
216216

217217
# Now the namespaces can reach each-other, test with ping:
218218
ip netns exec ${NS2} ping -i 0.2 -W 2 -c 2 $IPADDR1
@@ -226,7 +226,7 @@ ip netns exec ${NS1} ping -i 0.2 -W 2 -c 2 $IPADDR2
226226
#
227227
export XDP_PROG=xdp_vlan_remove_outer2
228228
ip netns exec ${NS1} ip link set $DEVNS1 $XDP_MODE off
229-
ip netns exec ${NS1} ip link set $DEVNS1 $XDP_MODE object $FILE section $XDP_PROG
229+
ip netns exec ${NS1} ip link set $DEVNS1 $XDP_MODE object $BPF_FILE section $XDP_PROG
230230

231231
# Now the namespaces should still be able reach each-other, test with ping:
232232
ip netns exec ${NS2} ping -i 0.2 -W 2 -c 2 $IPADDR1

0 commit comments

Comments
 (0)