Commit 98af3746 authored by Wang Yufen's avatar Wang Yufen Committed by Alexei Starovoitov
Browse files

selftests/bpf: fix missing BPF object files



After commit afef88e6 ("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: afef88e6 ("selftests/bpf: Store BPF object files with .bpf.o extension")
Signed-off-by: default avatarWang Yufen <wangyufen@huawei.com>
Acked-by: default avatarStanislav Fomichev <sdf@google.com>
Link: https://lore.kernel.org/r/1666235134-562-1-git-send-email-wangyufen@huawei.com


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent fb73a20e
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -4,6 +4,9 @@
# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4

BPF_FILE_USED="metadata_used.bpf.o"
BPF_FILE_UNUSED="metadata_unused.bpf.o"

TESTNAME=bpftool_metadata
BPF_FS=$(awk '$3 == "bpf" {print $2; exit}' /proc/mounts)
BPF_DIR=$BPF_FS/test_$TESTNAME
@@ -55,7 +58,7 @@ mkdir $BPF_DIR

trap cleanup EXIT

bpftool prog load metadata_unused.o $BPF_DIR/unused
bpftool prog load $BPF_FILE_UNUSED $BPF_DIR/unused

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

rm $BPF_DIR/unused

bpftool prog load metadata_used.o $BPF_DIR/used
bpftool prog load $BPF_FILE_USED $BPF_DIR/used

METADATA_PLAIN="$(bpftool prog)"
echo "$METADATA_PLAIN" | grep 'a = "bar"' > /dev/null
+4 −2
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@
# SPDX-License-Identifier: GPL-2.0
#
# Load BPF flow dissector and verify it correctly dissects traffic

BPF_FILE="bpf_flow.bpf.o"
export TESTNAME=test_flow_dissector
unmount=0

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

		$bpftool prog loadall ./bpf_flow.o /sys/fs/bpf/flow \
		$bpftool prog loadall $BPF_FILE /sys/fs/bpf/flow \
			type flow_dissector

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

# Attach BPF program
./flow_dissector_load -p bpf_flow.o -s _dissect
./flow_dissector_load -p $BPF_FILE -s _dissect

# Setup
tc qdisc add dev lo ingress
+9 −8
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@
#       ping: SRC->[encap at veth2:ingress]->GRE:decap->DST
#       ping replies go DST->SRC directly

BPF_FILE="test_lwt_ip_encap.bpf.o"
if [[ $EUID -ne 0 ]]; then
	echo "This script must be run as root"
	echo "FAIL"
@@ -373,14 +374,14 @@ test_egress()
	# install replacement routes (LWT/eBPF), pings succeed
	if [ "${ENCAP}" == "IPv4" ] ; then
		ip -netns ${NS1} route add ${IPv4_DST} encap bpf xmit obj \
			test_lwt_ip_encap.o sec encap_gre dev veth1 ${VRF}
			${BPF_FILE} sec encap_gre dev veth1 ${VRF}
		ip -netns ${NS1} -6 route add ${IPv6_DST} encap bpf xmit obj \
			test_lwt_ip_encap.o sec encap_gre dev veth1 ${VRF}
			${BPF_FILE} sec encap_gre dev veth1 ${VRF}
	elif [ "${ENCAP}" == "IPv6" ] ; then
		ip -netns ${NS1} route add ${IPv4_DST} encap bpf xmit obj \
			test_lwt_ip_encap.o sec encap_gre6 dev veth1 ${VRF}
			${BPF_FILE} sec encap_gre6 dev veth1 ${VRF}
		ip -netns ${NS1} -6 route add ${IPv6_DST} encap bpf xmit obj \
			test_lwt_ip_encap.o sec encap_gre6 dev veth1 ${VRF}
			${BPF_FILE} sec encap_gre6 dev veth1 ${VRF}
	else
		echo "    unknown encap ${ENCAP}"
		TEST_STATUS=1
@@ -431,14 +432,14 @@ test_ingress()
	# install replacement routes (LWT/eBPF), pings succeed
	if [ "${ENCAP}" == "IPv4" ] ; then
		ip -netns ${NS2} route add ${IPv4_DST} encap bpf in obj \
			test_lwt_ip_encap.o sec encap_gre dev veth2 ${VRF}
			${BPF_FILE} sec encap_gre dev veth2 ${VRF}
		ip -netns ${NS2} -6 route add ${IPv6_DST} encap bpf in obj \
			test_lwt_ip_encap.o sec encap_gre dev veth2 ${VRF}
			${BPF_FILE} sec encap_gre dev veth2 ${VRF}
	elif [ "${ENCAP}" == "IPv6" ] ; then
		ip -netns ${NS2} route add ${IPv4_DST} encap bpf in obj \
			test_lwt_ip_encap.o sec encap_gre6 dev veth2 ${VRF}
			${BPF_FILE} sec encap_gre6 dev veth2 ${VRF}
		ip -netns ${NS2} -6 route add ${IPv6_DST} encap bpf in obj \
			test_lwt_ip_encap.o sec encap_gre6 dev veth2 ${VRF}
			${BPF_FILE} sec encap_gre6 dev veth2 ${VRF}
	else
		echo "FAIL: unknown encap ${ENCAP}"
		TEST_STATUS=1
+5 −4
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@

# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4
BPF_FILE="test_lwt_seg6local.bpf.o"
readonly NS1="ns1-$(mktemp -u XXXXXX)"
readonly NS2="ns2-$(mktemp -u XXXXXX)"
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
ip netns exec ${NS1} ip -6 addr add fb00::1/16 dev lo
ip netns exec ${NS1} ip -6 route add fb00::6 dev veth1 via fb00::21

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

ip netns exec ${NS3} ip -6 route add fc42::1 dev veth5 via fb00::65
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
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

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
ip netns exec ${NS4} ip -6 route add fd00::2 encap seg6local action End.BPF endpoint obj ${BPF_FILE} sec pop_egr dev veth6
ip netns exec ${NS4} ip -6 addr add fc42::1 dev lo
ip netns exec ${NS4} ip -6 route add fd00::3 dev veth7 via fb00::87

ip netns exec ${NS5} ip -6 route add fd00::4 table 117 dev veth9 via fb00::109
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
ip netns exec ${NS5} ip -6 route add fd00::3 encap seg6local action End.BPF endpoint obj ${BPF_FILE} sec inspect_t dev veth8

ip netns exec ${NS6} ip -6 addr add fb00::6/16 dev lo
ip netns exec ${NS6} ip -6 addr add fd00::4/16 dev lo
+2 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
# with dst port = 9000 down to 5MBps. Then it measures actual
# throughput of the flow.

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


# start the listener
Loading