mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-31 08:28:13 +00:00
d4b6f87e8d
There are several test cases in the bpf directory are still using exit 0 when they need to be skipped. Use kselftest framework skip code instead so it can help us to distinguish the return status. Criterion to filter out what should be fixed in bpf directory: grep -r "exit 0" -B1 | grep -i skip This change might cause some false-positives if people are running these test scripts directly and only checking their return codes, which will change from 0 to 4. However I think the impact should be small as most of our scripts here are already using this skip code. And there will be no such issue if running them with the kselftest framework. Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20210929051250.13831-1-po-hsu.lin@canonical.com
55 lines
1.3 KiB
Bash
Executable file
55 lines
1.3 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
# Kselftest framework requirement - SKIP code is 4.
|
|
readonly KSFT_SKIP=4
|
|
|
|
cleanup()
|
|
{
|
|
if [ "$?" = "0" ]; then
|
|
echo "selftests: test_xdp_meta [PASS]";
|
|
else
|
|
echo "selftests: test_xdp_meta [FAILED]";
|
|
fi
|
|
|
|
set +e
|
|
ip link del veth1 2> /dev/null
|
|
ip netns del ns1 2> /dev/null
|
|
ip netns del ns2 2> /dev/null
|
|
}
|
|
|
|
ip link set dev lo xdp off 2>/dev/null > /dev/null
|
|
if [ $? -ne 0 ];then
|
|
echo "selftests: [SKIP] Could not run test without the ip xdp support"
|
|
exit $KSFT_SKIP
|
|
fi
|
|
set -e
|
|
|
|
ip netns add ns1
|
|
ip netns add ns2
|
|
|
|
trap cleanup 0 2 3 6 9
|
|
|
|
ip link add veth1 type veth peer name veth2
|
|
|
|
ip link set veth1 netns ns1
|
|
ip link set veth2 netns ns2
|
|
|
|
ip netns exec ns1 ip addr add 10.1.1.11/24 dev veth1
|
|
ip netns exec ns2 ip addr add 10.1.1.22/24 dev veth2
|
|
|
|
ip netns exec ns1 tc qdisc add dev veth1 clsact
|
|
ip netns exec ns2 tc qdisc add dev veth2 clsact
|
|
|
|
ip netns exec ns1 tc filter add dev veth1 ingress bpf da obj test_xdp_meta.o sec t
|
|
ip netns exec ns2 tc filter add dev veth2 ingress bpf da obj test_xdp_meta.o sec t
|
|
|
|
ip netns exec ns1 ip link set dev veth1 xdp obj test_xdp_meta.o sec x
|
|
ip netns exec ns2 ip link set dev veth2 xdp obj test_xdp_meta.o sec x
|
|
|
|
ip netns exec ns1 ip link set dev veth1 up
|
|
ip netns exec ns2 ip link set dev veth2 up
|
|
|
|
ip netns exec ns1 ping -c 1 10.1.1.22
|
|
ip netns exec ns2 ping -c 1 10.1.1.11
|
|
|
|
exit 0
|