From 22f1a38a547b5ce5e73b0a77339cbf23f70dee5d Mon Sep 17 00:00:00 2001 From: Willem de Bruijn Date: Tue, 18 Jun 2019 16:03:04 -0400 Subject: 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 Signed-off-by: David S. Miller --- tools/testing/selftests/net/udpgso_bench_tx.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'tools/testing/selftests/net/udpgso_bench_tx.c') diff --git a/tools/testing/selftests/net/udpgso_bench_tx.c b/tools/testing/selftests/net/udpgso_bench_tx.c index dfa83ad57206..ada99496634a 100644 --- a/tools/testing/selftests/net/udpgso_bench_tx.c +++ b/tools/testing/selftests/net/udpgso_bench_tx.c @@ -25,6 +25,8 @@ #include #include +#include "../kselftest.h" + #ifndef ETH_MAX_MTU #define ETH_MAX_MTU 0xFFFFU #endif @@ -45,6 +47,10 @@ #define MSG_ZEROCOPY 0x4000000 #endif +#ifndef ENOTSUPP +#define ENOTSUPP 524 +#endif + #define NUM_PKT 100 static bool cfg_cache_trash; @@ -603,7 +609,7 @@ int main(int argc, char **argv) { unsigned long num_msgs, num_sends; unsigned long tnow, treport, tstop; - int fd, i, val; + int fd, i, val, ret; parse_opts(argc, argv); @@ -623,8 +629,16 @@ int main(int argc, char **argv) if (cfg_zerocopy) { 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"); + } } if (cfg_connected && -- cgit v1.2.3-59-g8ed1b