~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/net/udpgso_bench.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0
  3 #
  4 # Run a series of udpgso benchmarks
  5 
  6 readonly GREEN='\033[0;92m'
  7 readonly YELLOW='\033[0;33m'
  8 readonly RED='\033[0;31m'
  9 readonly NC='\033[0m' # No Color
 10 readonly TESTPORT=8000
 11 
 12 readonly KSFT_PASS=0
 13 readonly KSFT_FAIL=1
 14 readonly KSFT_SKIP=4
 15 
 16 num_pass=0
 17 num_err=0
 18 num_skip=0
 19 
 20 kselftest_test_exitcode() {
 21         local -r exitcode=$1
 22 
 23         if [[ ${exitcode} -eq ${KSFT_PASS} ]]; then
 24                 num_pass=$(( $num_pass + 1 ))
 25         elif [[ ${exitcode} -eq ${KSFT_SKIP} ]]; then
 26                 num_skip=$(( $num_skip + 1 ))
 27         else
 28                 num_err=$(( $num_err + 1 ))
 29         fi
 30 }
 31 
 32 kselftest_exit() {
 33         echo -e "$(basename $0): PASS=${num_pass} SKIP=${num_skip} FAIL=${num_err}"
 34 
 35         if [[ $num_err -ne 0 ]]; then
 36                 echo -e "$(basename $0): ${RED}FAIL${NC}"
 37                 exit ${KSFT_FAIL}
 38         fi
 39 
 40         if [[ $num_skip -ne 0 ]]; then
 41                 echo -e "$(basename $0): ${YELLOW}SKIP${NC}"
 42                 exit ${KSFT_SKIP}
 43         fi
 44 
 45         echo -e "$(basename $0): ${GREEN}PASS${NC}"
 46         exit ${KSFT_PASS}
 47 }
 48 
 49 wake_children() {
 50         local -r jobs="$(jobs -p)"
 51 
 52         if [[ "${jobs}" != "" ]]; then
 53                 kill -1 ${jobs} 2>/dev/null
 54         fi
 55 }
 56 trap wake_children EXIT
 57 
 58 run_one() {
 59         local -r args=$@
 60         local nr_socks=0
 61         local i=0
 62         local -r timeout=10
 63 
 64         ./udpgso_bench_rx -p "$TESTPORT" &
 65         ./udpgso_bench_rx -p "$TESTPORT" -t &
 66 
 67         # Wait for the above test program to get ready to receive connections.
 68         while [ "$i" -lt "$timeout" ]; do
 69                 nr_socks="$(ss -lnHi | grep -c "\*:${TESTPORT}")"
 70                 [ "$nr_socks" -eq 2 ] && break
 71                 i=$((i + 1))
 72                 sleep 1
 73         done
 74         if [ "$nr_socks" -ne 2 ]; then
 75                 echo "timed out while waiting for udpgso_bench_rx"
 76                 exit 1
 77         fi
 78 
 79         ./udpgso_bench_tx -p "$TESTPORT" ${args}
 80 }
 81 
 82 run_in_netns() {
 83         local -r args=$@
 84 
 85         ./in_netns.sh $0 __subprocess ${args}
 86         kselftest_test_exitcode $?
 87 }
 88 
 89 run_udp() {
 90         local -r args=$@
 91 
 92         echo "udp"
 93         run_in_netns ${args}
 94 
 95         echo "udp gso"
 96         run_in_netns ${args} -S 0
 97 
 98         echo "udp gso zerocopy"
 99         run_in_netns ${args} -S 0 -z
100 
101         echo "udp gso timestamp"
102         run_in_netns ${args} -S 0 -T
103 
104         echo "udp gso zerocopy audit"
105         run_in_netns ${args} -S 0 -z -a
106 
107         echo "udp gso timestamp audit"
108         run_in_netns ${args} -S 0 -T -a
109 
110         echo "udp gso zerocopy timestamp audit"
111         run_in_netns ${args} -S 0 -T -z -a
112 }
113 
114 run_tcp() {
115         local -r args=$@
116 
117         echo "tcp"
118         run_in_netns ${args} -t
119 
120         echo "tcp zerocopy"
121         run_in_netns ${args} -t -z
122 
123         # excluding for now because test fails intermittently
124         # add -P option to include poll() to reduce possibility of lost messages
125         #echo "tcp zerocopy audit"
126         #run_in_netns ${args} -t -z -P -a
127 }
128 
129 run_all() {
130         local -r core_args="-l 3"
131         local -r ipv4_args="${core_args} -4 -D 127.0.0.1"
132         local -r ipv6_args="${core_args} -6 -D ::1"
133 
134         echo "ipv4"
135         run_tcp "${ipv4_args}"
136         run_udp "${ipv4_args}"
137 
138         echo "ipv6"
139         run_tcp "${ipv6_args}"
140         run_udp "${ipv6_args}"
141 }
142 
143 if [[ $# -eq 0 ]]; then
144         run_all
145         kselftest_exit
146 elif [[ $1 == "__subprocess" ]]; then
147         shift
148         run_one $@
149 else
150         run_in_netns $@
151 fi

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php