selftests/net: make udpgso_bench skip unsupported testcases
Kselftest can be run against older kernels. Instead of failing hard when a feature is unsupported, return the KSFT_SKIP exit code. Specifically, do not fail hard on missing udp zerocopy. The udp gso bench test runs multiple test cases from a single script. Fail if any case fails, else return skip if any test is skipped. Link: https://lore.kernel.org/lkml/20190618171516.GA17547@kroah.com/ Signed-off-by: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
25cec75689
commit
22f1a38a54
@ -3,9 +3,47 @@
|
|||||||
#
|
#
|
||||||
# Run a series of udpgso benchmarks
|
# Run a series of udpgso benchmarks
|
||||||
|
|
||||||
GREEN='\033[0;92m'
|
readonly GREEN='\033[0;92m'
|
||||||
RED='\033[0;31m'
|
readonly YELLOW='\033[0;33m'
|
||||||
NC='\033[0m' # No Color
|
readonly RED='\033[0;31m'
|
||||||
|
readonly NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
readonly KSFT_PASS=0
|
||||||
|
readonly KSFT_FAIL=1
|
||||||
|
readonly KSFT_SKIP=4
|
||||||
|
|
||||||
|
num_pass=0
|
||||||
|
num_err=0
|
||||||
|
num_skip=0
|
||||||
|
|
||||||
|
kselftest_test_exitcode() {
|
||||||
|
local -r exitcode=$1
|
||||||
|
|
||||||
|
if [[ ${exitcode} -eq ${KSFT_PASS} ]]; then
|
||||||
|
num_pass=$(( $num_pass + 1 ))
|
||||||
|
elif [[ ${exitcode} -eq ${KSFT_SKIP} ]]; then
|
||||||
|
num_skip=$(( $num_skip + 1 ))
|
||||||
|
else
|
||||||
|
num_err=$(( $num_err + 1 ))
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
kselftest_exit() {
|
||||||
|
echo -e "$(basename $0): PASS=${num_pass} SKIP=${num_skip} FAIL=${num_err}"
|
||||||
|
|
||||||
|
if [[ $num_err -ne 0 ]]; then
|
||||||
|
echo -e "$(basename $0): ${RED}FAIL${NC}"
|
||||||
|
exit ${KSFT_FAIL}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $num_skip -ne 0 ]]; then
|
||||||
|
echo -e "$(basename $0): ${YELLOW}SKIP${NC}"
|
||||||
|
exit ${KSFT_SKIP}
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "$(basename $0): ${GREEN}PASS${NC}"
|
||||||
|
exit ${KSFT_PASS}
|
||||||
|
}
|
||||||
|
|
||||||
wake_children() {
|
wake_children() {
|
||||||
local -r jobs="$(jobs -p)"
|
local -r jobs="$(jobs -p)"
|
||||||
@ -29,93 +67,66 @@ run_in_netns() {
|
|||||||
local -r args=$@
|
local -r args=$@
|
||||||
|
|
||||||
./in_netns.sh $0 __subprocess ${args}
|
./in_netns.sh $0 __subprocess ${args}
|
||||||
|
kselftest_test_exitcode $?
|
||||||
}
|
}
|
||||||
|
|
||||||
run_udp() {
|
run_udp() {
|
||||||
local -r args=$@
|
local -r args=$@
|
||||||
local errors=0
|
|
||||||
|
|
||||||
echo "udp"
|
echo "udp"
|
||||||
run_in_netns ${args}
|
run_in_netns ${args}
|
||||||
errors=$(( $errors + $? ))
|
|
||||||
|
|
||||||
echo "udp gso"
|
echo "udp gso"
|
||||||
run_in_netns ${args} -S 0
|
run_in_netns ${args} -S 0
|
||||||
errors=$(( $errors + $? ))
|
|
||||||
|
|
||||||
echo "udp gso zerocopy"
|
echo "udp gso zerocopy"
|
||||||
run_in_netns ${args} -S 0 -z
|
run_in_netns ${args} -S 0 -z
|
||||||
errors=$(( $errors + $? ))
|
|
||||||
|
|
||||||
echo "udp gso timestamp"
|
echo "udp gso timestamp"
|
||||||
run_in_netns ${args} -S 0 -T
|
run_in_netns ${args} -S 0 -T
|
||||||
errors=$(( $errors + $? ))
|
|
||||||
|
|
||||||
echo "udp gso zerocopy audit"
|
echo "udp gso zerocopy audit"
|
||||||
run_in_netns ${args} -S 0 -z -a
|
run_in_netns ${args} -S 0 -z -a
|
||||||
errors=$(( $errors + $? ))
|
|
||||||
|
|
||||||
echo "udp gso timestamp audit"
|
echo "udp gso timestamp audit"
|
||||||
run_in_netns ${args} -S 0 -T -a
|
run_in_netns ${args} -S 0 -T -a
|
||||||
errors=$(( $errors + $? ))
|
|
||||||
|
|
||||||
echo "udp gso zerocopy timestamp audit"
|
echo "udp gso zerocopy timestamp audit"
|
||||||
run_in_netns ${args} -S 0 -T -z -a
|
run_in_netns ${args} -S 0 -T -z -a
|
||||||
errors=$(( $errors + $? ))
|
|
||||||
|
|
||||||
return $errors
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run_tcp() {
|
run_tcp() {
|
||||||
local -r args=$@
|
local -r args=$@
|
||||||
local errors=0
|
|
||||||
|
|
||||||
echo "tcp"
|
echo "tcp"
|
||||||
run_in_netns ${args} -t
|
run_in_netns ${args} -t
|
||||||
errors=$(( $errors + $? ))
|
|
||||||
|
|
||||||
echo "tcp zerocopy"
|
echo "tcp zerocopy"
|
||||||
run_in_netns ${args} -t -z
|
run_in_netns ${args} -t -z
|
||||||
errors=$(( $errors + $? ))
|
|
||||||
|
|
||||||
# excluding for now because test fails intermittently
|
# excluding for now because test fails intermittently
|
||||||
# add -P option to include poll() to reduce possibility of lost messages
|
# add -P option to include poll() to reduce possibility of lost messages
|
||||||
#echo "tcp zerocopy audit"
|
#echo "tcp zerocopy audit"
|
||||||
#run_in_netns ${args} -t -z -P -a
|
#run_in_netns ${args} -t -z -P -a
|
||||||
#errors=$(( $errors + $? ))
|
|
||||||
|
|
||||||
return $errors
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run_all() {
|
run_all() {
|
||||||
local -r core_args="-l 3"
|
local -r core_args="-l 3"
|
||||||
local -r ipv4_args="${core_args} -4 -D 127.0.0.1"
|
local -r ipv4_args="${core_args} -4 -D 127.0.0.1"
|
||||||
local -r ipv6_args="${core_args} -6 -D ::1"
|
local -r ipv6_args="${core_args} -6 -D ::1"
|
||||||
local errors=0
|
|
||||||
|
|
||||||
echo "ipv4"
|
echo "ipv4"
|
||||||
run_tcp "${ipv4_args}"
|
run_tcp "${ipv4_args}"
|
||||||
errors=$(( $errors + $? ))
|
|
||||||
run_udp "${ipv4_args}"
|
run_udp "${ipv4_args}"
|
||||||
errors=$(( $errors + $? ))
|
|
||||||
|
|
||||||
echo "ipv6"
|
echo "ipv6"
|
||||||
run_tcp "${ipv4_args}"
|
run_tcp "${ipv4_args}"
|
||||||
errors=$(( $errors + $? ))
|
|
||||||
run_udp "${ipv6_args}"
|
run_udp "${ipv6_args}"
|
||||||
errors=$(( $errors + $? ))
|
|
||||||
|
|
||||||
return $errors
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $# -eq 0 ]]; then
|
if [[ $# -eq 0 ]]; then
|
||||||
run_all
|
run_all
|
||||||
if [ $? -ne 0 ]; then
|
kselftest_exit
|
||||||
echo -e "$(basename $0): ${RED}FAIL${NC}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "$(basename $0): ${GREEN}PASS${NC}"
|
|
||||||
elif [[ $1 == "__subprocess" ]]; then
|
elif [[ $1 == "__subprocess" ]]; then
|
||||||
shift
|
shift
|
||||||
run_one $@
|
run_one $@
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "../kselftest.h"
|
||||||
|
|
||||||
#ifndef ETH_MAX_MTU
|
#ifndef ETH_MAX_MTU
|
||||||
#define ETH_MAX_MTU 0xFFFFU
|
#define ETH_MAX_MTU 0xFFFFU
|
||||||
#endif
|
#endif
|
||||||
@ -45,6 +47,10 @@
|
|||||||
#define MSG_ZEROCOPY 0x4000000
|
#define MSG_ZEROCOPY 0x4000000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENOTSUPP
|
||||||
|
#define ENOTSUPP 524
|
||||||
|
#endif
|
||||||
|
|
||||||
#define NUM_PKT 100
|
#define NUM_PKT 100
|
||||||
|
|
||||||
static bool cfg_cache_trash;
|
static bool cfg_cache_trash;
|
||||||
@ -603,7 +609,7 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
unsigned long num_msgs, num_sends;
|
unsigned long num_msgs, num_sends;
|
||||||
unsigned long tnow, treport, tstop;
|
unsigned long tnow, treport, tstop;
|
||||||
int fd, i, val;
|
int fd, i, val, ret;
|
||||||
|
|
||||||
parse_opts(argc, argv);
|
parse_opts(argc, argv);
|
||||||
|
|
||||||
@ -623,8 +629,16 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (cfg_zerocopy) {
|
if (cfg_zerocopy) {
|
||||||
val = 1;
|
val = 1;
|
||||||
if (setsockopt(fd, SOL_SOCKET, SO_ZEROCOPY, &val, sizeof(val)))
|
|
||||||
|
ret = setsockopt(fd, SOL_SOCKET, SO_ZEROCOPY,
|
||||||
|
&val, sizeof(val));
|
||||||
|
if (ret) {
|
||||||
|
if (errno == ENOPROTOOPT || errno == ENOTSUPP) {
|
||||||
|
fprintf(stderr, "SO_ZEROCOPY not supported");
|
||||||
|
exit(KSFT_SKIP);
|
||||||
|
}
|
||||||
error(1, errno, "setsockopt zerocopy");
|
error(1, errno, "setsockopt zerocopy");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfg_connected &&
|
if (cfg_connected &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user