Skip to content

Commit

Permalink
selftests/net: fix missing xdp_dummy
Browse files Browse the repository at this point in the history
After commit afef88e ("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: afef88e ("selftests/bpf: Store BPF object files with .bpf.o extension")
Signed-off-by: Wang Yufen <[email protected]>
Cc: Daniel Müller <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
wangyufen316 authored and davem330 committed Nov 18, 2022
1 parent 40b9d1a commit 302e57f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
8 changes: 5 additions & 3 deletions tools/testing/selftests/net/udpgro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -195,8 +197,8 @@ run_all() {
return $ret
}

if [ ! -f ../bpf/xdp_dummy.o ]; then
echo "Missing xdp_dummy helper. Build bpf selftest first"
if [ ! -f ${BPF_FILE} ]; then
echo "Missing ${BPF_FILE}. Build bpf selftest first"
exit -1
fi

Expand Down
8 changes: 5 additions & 3 deletions tools/testing/selftests/net/udpgro_bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down Expand Up @@ -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 &

Expand Down Expand Up @@ -80,8 +82,8 @@ run_all() {
run_udp "${ipv6_args}"
}

if [ ! -f ../bpf/xdp_dummy.o ]; then
echo "Missing xdp_dummy helper. Build bpf selftest first"
if [ ! -f ${BPF_FILE} ]; then
echo "Missing ${BPF_FILE}. Build bpf selftest first"
exit -1
fi

Expand Down
8 changes: 5 additions & 3 deletions tools/testing/selftests/net/udpgro_frglist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -81,8 +83,8 @@ run_all() {
run_udp "${ipv6_args}"
}

if [ ! -f ../bpf/xdp_dummy.o ]; then
echo "Missing xdp_dummy helper. Build bpf selftest first"
if [ ! -f ${BPF_FILE} ]; then
echo "Missing ${BPF_FILE}. Build bpf selftest first"
exit -1
fi

Expand Down
3 changes: 2 additions & 1 deletion tools/testing/selftests/net/udpgro_fwd.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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() {
Expand Down
11 changes: 6 additions & 5 deletions tools/testing/selftests/net/veth.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -216,8 +217,8 @@ while getopts "hs:" option; do
esac
done

if [ ! -f ../bpf/xdp_dummy.o ]; then
echo "Missing xdp_dummy helper. Build bpf selftest first"
if [ ! -f ${BPF_FILE} ]; then
echo "Missing ${BPF_FILE}. Build bpf selftest first"
exit 1
fi

Expand Down Expand Up @@ -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 &&\
Expand All @@ -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
Expand Down

0 comments on commit 302e57f

Please sign in to comment.