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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/test_xsk.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 ] ~

Diff markup

Differences between /tools/testing/selftests/bpf/test_xsk.sh (Version linux-6.12-rc7) and /tools/testing/selftests/bpf/test_xsk.sh (Version linux-5.11.22)


  1 #!/bin/bash                                         1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0                  2 # SPDX-License-Identifier: GPL-2.0
  3 # Copyright(c) 2020 Intel Corporation, Weqaar <      3 # Copyright(c) 2020 Intel Corporation, Weqaar Janjua <weqaar.a.janjua@intel.com>
  4                                                     4 
  5 # AF_XDP selftests based on veth                    5 # AF_XDP selftests based on veth
  6 #                                                   6 #
  7 # End-to-end AF_XDP over Veth test                  7 # End-to-end AF_XDP over Veth test
  8 #                                                   8 #
  9 # Topology:                                         9 # Topology:
 10 # ---------                                        10 # ---------
 11 #                 -----------                      11 #                 -----------
 12 #               _ | Process | _                    12 #               _ | Process | _
 13 #              /  -----------  \                   13 #              /  -----------  \
 14 #             /        |        \                  14 #             /        |        \
 15 #            /         |         \                 15 #            /         |         \
 16 #      -----------     |     -----------           16 #      -----------     |     -----------
 17 #      | Thread1 |     |     | Thread2 |           17 #      | Thread1 |     |     | Thread2 |
 18 #      -----------     |     -----------           18 #      -----------     |     -----------
 19 #           |          |          |                19 #           |          |          |
 20 #      -----------     |     -----------           20 #      -----------     |     -----------
 21 #      |  xskX   |     |     |  xskY   |           21 #      |  xskX   |     |     |  xskY   |
 22 #      -----------     |     -----------           22 #      -----------     |     -----------
 23 #           |          |          |                23 #           |          |          |
 24 #      -----------     |     ----------            24 #      -----------     |     ----------
 25 #      |  vethX  | --------- |  vethY |            25 #      |  vethX  | --------- |  vethY |
 26 #      -----------   peer    ----------            26 #      -----------   peer    ----------
                                                   >>  27 #           |          |          |
                                                   >>  28 #      namespaceX      |     namespaceY
 27 #                                                  29 #
 28 # AF_XDP is an address family optimized for hi     30 # AF_XDP is an address family optimized for high performance packet processing,
 29 # it is XDP’s user-space interface.              31 # it is XDP’s user-space interface.
 30 #                                                  32 #
 31 # An AF_XDP socket is linked to a single UMEM      33 # An AF_XDP socket is linked to a single UMEM which is a region of virtual
 32 # contiguous memory, divided into equal-sized      34 # contiguous memory, divided into equal-sized frames.
 33 #                                                  35 #
 34 # Refer to AF_XDP Kernel Documentation for det     36 # Refer to AF_XDP Kernel Documentation for detailed information:
 35 # https://www.kernel.org/doc/html/latest/netwo     37 # https://www.kernel.org/doc/html/latest/networking/af_xdp.html
 36 #                                                  38 #
 37 # Prerequisites setup by script:                   39 # Prerequisites setup by script:
 38 #                                                  40 #
 39 #   Set up veth interfaces as per the topology     41 #   Set up veth interfaces as per the topology shown ^^:
 40 #   * setup two veth interfaces                !!  42 #   * setup two veth interfaces and one namespace
 41 #   ** veth<xxxx>                              !!  43 #   ** veth<xxxx> in root namespace
 42 #   ** veth<yyyy>                              !!  44 #   ** veth<yyyy> in af_xdp<xxxx> namespace
                                                   >>  45 #   ** namespace af_xdp<xxxx>
                                                   >>  46 #   * create a spec file veth.spec that includes this run-time configuration
 43 #   *** xxxx and yyyy are randomly generated 4     47 #   *** xxxx and yyyy are randomly generated 4 digit numbers used to avoid
 44 #       conflict with any existing interface       48 #       conflict with any existing interface
 45 #   * tests the veth and xsk layers of the top     49 #   * tests the veth and xsk layers of the topology
 46 #                                                  50 #
 47 # See the source xskxceiver.c for information  !!  51 # See the source xdpxceiver.c for information on each test
 48 #                                                  52 #
 49 # Kernel configuration:                            53 # Kernel configuration:
 50 # ---------------------                            54 # ---------------------
 51 # See "config" file for recommended kernel con     55 # See "config" file for recommended kernel config options.
 52 #                                                  56 #
 53 # Turn on XDP sockets and veth support when co     57 # Turn on XDP sockets and veth support when compiling i.e.
 54 #       Networking support -->                     58 #       Networking support -->
 55 #               Networking options -->             59 #               Networking options -->
 56 #                       [ * ] XDP sockets          60 #                       [ * ] XDP sockets
 57 #                                                  61 #
 58 # Executing Tests:                                 62 # Executing Tests:
 59 # ----------------                                 63 # ----------------
 60 # Must run with CAP_NET_ADMIN capability.          64 # Must run with CAP_NET_ADMIN capability.
 61 #                                                  65 #
 62 # Run:                                         !!  66 # Run (full color-coded output):
 63 #   sudo ./test_xsk.sh                         !!  67 #   sudo ./test_xsk.sh -c
 64 #                                                  68 #
 65 # If running from kselftests:                      69 # If running from kselftests:
 66 #   sudo make run_tests                        !!  70 #   sudo make colorconsole=1 run_tests
 67 #                                              << 
 68 # Run with verbose output:                     << 
 69 #   sudo ./test_xsk.sh -v                      << 
 70 #                                              << 
 71 # Set up veth interfaces and leave them up so  << 
 72 #   sudo ./test_xsk.sh -d                      << 
 73 #                                              << 
 74 # Run test suite for physical device in loopba << 
 75 #   sudo ./test_xsk.sh -i IFACE                << 
 76 #                                              << 
 77 # Run test suite in a specific mode only [skb, << 
 78 #   sudo ./test_xsk.sh -m MODE                 << 
 79 #                                                  71 #
 80 # List available tests                         !!  72 # Run (full output without color-coding):
 81 #   ./test_xsk.sh -l                           !!  73 #   sudo ./test_xsk.sh
 82 #                                              << 
 83 # Run a specific test from the test suite      << 
 84 #   sudo ./test_xsk.sh -t TEST_NAME            << 
 85 #                                              << 
 86 # Display the available command line options   << 
 87 #   ./test_xsk.sh -h                           << 
 88                                                    74 
 89 . xsk_prereqs.sh                                   75 . xsk_prereqs.sh
 90                                                    76 
 91 ETH=""                                         !!  77 while getopts c flag
 92                                                << 
 93 while getopts "vi:dm:lt:h" flag                << 
 94 do                                                 78 do
 95         case "${flag}" in                          79         case "${flag}" in
 96                 v) verbose=1;;                 !!  80                 c) colorconsole=1;;
 97                 d) debug=1;;                   << 
 98                 i) ETH=${OPTARG};;             << 
 99                 m) MODE=${OPTARG};;            << 
100                 l) list=1;;                    << 
101                 t) TEST=${OPTARG};;            << 
102                 h) help=1;;                    << 
103         esac                                       81         esac
104 done                                               82 done
105                                                    83 
106 TEST_NAME="PREREQUISITES"                          84 TEST_NAME="PREREQUISITES"
107                                                    85 
108 URANDOM=/dev/urandom                               86 URANDOM=/dev/urandom
109 [ ! -e "${URANDOM}" ] && { echo "${URANDOM} no !!  87 [ ! -e "${URANDOM}" ] && { echo "${URANDOM} not found. Skipping tests."; test_exit 1 1; }
110                                                    88 
111 VETH0_POSTFIX=$(cat ${URANDOM} | tr -dc '0-9'      89 VETH0_POSTFIX=$(cat ${URANDOM} | tr -dc '0-9' | fold -w 256 | head -n 1 | head --bytes 4)
112 VETH0=ve${VETH0_POSTFIX}                           90 VETH0=ve${VETH0_POSTFIX}
113 VETH1_POSTFIX=$(cat ${URANDOM} | tr -dc '0-9'      91 VETH1_POSTFIX=$(cat ${URANDOM} | tr -dc '0-9' | fold -w 256 | head -n 1 | head --bytes 4)
114 VETH1=ve${VETH1_POSTFIX}                           92 VETH1=ve${VETH1_POSTFIX}
                                                   >>  93 NS0=root
                                                   >>  94 NS1=af_xdp${VETH1_POSTFIX}
115 MTU=1500                                           95 MTU=1500
116                                                    96 
117 trap ctrl_c INT                                << 
118                                                << 
119 function ctrl_c() {                            << 
120         cleanup_exit ${VETH0} ${VETH1}         << 
121         exit 1                                 << 
122 }                                              << 
123                                                << 
124 setup_vethPairs() {                                97 setup_vethPairs() {
125         if [[ $verbose -eq 1 ]]; then          !!  98         echo "setting up ${VETH0}: namespace: ${NS0}"
126                 echo "setting up ${VETH0}"     !!  99         ip netns add ${NS1}
127         fi                                     !! 100         ip link add ${VETH0} type veth peer name ${VETH1}
128         ip link add ${VETH0} numtxqueues 4 num << 
129         if [ -f /proc/net/if_inet6 ]; then        101         if [ -f /proc/net/if_inet6 ]; then
130                 echo 1 > /proc/sys/net/ipv6/co    102                 echo 1 > /proc/sys/net/ipv6/conf/${VETH0}/disable_ipv6
131                 echo 1 > /proc/sys/net/ipv6/co << 
132         fi                                     << 
133         if [[ $verbose -eq 1 ]]; then          << 
134                 echo "setting up ${VETH1}"     << 
135         fi                                     << 
136                                                << 
137         if [[ $busy_poll -eq 1 ]]; then        << 
138                 echo 2 > /sys/class/net/${VETH << 
139                 echo 200000 > /sys/class/net/$ << 
140                 echo 2 > /sys/class/net/${VETH << 
141                 echo 200000 > /sys/class/net/$ << 
142         fi                                        103         fi
143                                                !! 104         echo "setting up ${VETH1}: namespace: ${NS1}"
144         ip link set ${VETH1} mtu ${MTU}        !! 105         ip link set ${VETH1} netns ${NS1}
                                                   >> 106         ip netns exec ${NS1} ip link set ${VETH1} mtu ${MTU}
145         ip link set ${VETH0} mtu ${MTU}           107         ip link set ${VETH0} mtu ${MTU}
146         ip link set ${VETH1} up                !! 108         ip netns exec ${NS1} ip link set ${VETH1} up
147         ip link set ${VETH0} up                   109         ip link set ${VETH0} up
148 }                                                 110 }
149                                                   111 
150 if [[ $list -eq 1 ]]; then                     !! 112 validate_root_exec
151         ./${XSKOBJ} -l                         !! 113 validate_veth_support ${VETH0}
152         exit                                   !! 114 validate_ip_utility
153 fi                                             !! 115 setup_vethPairs
154                                                   116 
155 if [[ $help -eq 1 ]]; then                     !! 117 retval=$?
156         ./${XSKOBJ}                            !! 118 if [ $retval -ne 0 ]; then
157         exit                                   !! 119         test_status $retval "${TEST_NAME}"
                                                   >> 120         cleanup_exit ${VETH0} ${VETH1} ${NS1}
                                                   >> 121         exit $retval
158 fi                                                122 fi
159                                                   123 
160 if [ ! -z $ETH ]; then                         !! 124 echo "${VETH0}:${VETH1},${NS1}" > ${SPECFILE}
161         VETH0=${ETH}                           << 
162         VETH1=${ETH}                           << 
163 else                                           << 
164         validate_root_exec                     << 
165         validate_veth_support ${VETH0}         << 
166         validate_ip_utility                    << 
167         setup_vethPairs                        << 
168                                                << 
169         retval=$?                              << 
170         if [ $retval -ne 0 ]; then             << 
171                 test_status $retval "${TEST_NA << 
172                 cleanup_exit ${VETH0} ${VETH1} << 
173                 exit $retval                   << 
174         fi                                     << 
175 fi                                             << 
176                                                   125 
                                                   >> 126 validate_veth_spec_file
177                                                   127 
178 if [[ $verbose -eq 1 ]]; then                  !! 128 echo "Spec file created: ${SPECFILE}"
179         ARGS+="-v "                            << 
180 fi                                             << 
181                                                   129 
182 if [ -n "$MODE" ]; then                        !! 130 test_status $retval "${TEST_NAME}"
183         ARGS+="-m ${MODE} "                    !! 131 
184 fi                                             !! 132 ## START TESTS
                                                   >> 133 
                                                   >> 134 statusList=()
                                                   >> 135 
                                                   >> 136 ### TEST 1
                                                   >> 137 TEST_NAME="XSK KSELFTEST FRAMEWORK"
                                                   >> 138 
                                                   >> 139 echo "Switching interfaces [${VETH0}, ${VETH1}] to XDP Generic mode"
                                                   >> 140 vethXDPgeneric ${VETH0} ${VETH1} ${NS1}
185                                                   141 
186 if [ -n "$TEST" ]; then                        !! 142 retval=$?
187         ARGS+="-t ${TEST} "                    !! 143 if [ $retval -eq 0 ]; then
                                                   >> 144         echo "Switching interfaces [${VETH0}, ${VETH1}] to XDP Native mode"
                                                   >> 145         vethXDPnative ${VETH0} ${VETH1} ${NS1}
188 fi                                                146 fi
189                                                   147 
190 retval=$?                                         148 retval=$?
191 test_status $retval "${TEST_NAME}"                149 test_status $retval "${TEST_NAME}"
                                                   >> 150 statusList+=($retval)
192                                                   151 
193 ## START TESTS                                 !! 152 ### TEST 2
                                                   >> 153 TEST_NAME="SKB NOPOLL"
194                                                   154 
195 statusList=()                                  !! 155 vethXDPgeneric ${VETH0} ${VETH1} ${NS1}
196                                                   156 
197 TEST_NAME="XSK_SELFTESTS_${VETH0}_SOFTIRQ"     !! 157 params=("-S")
                                                   >> 158 execxdpxceiver params
198                                                   159 
199 if [[ $debug -eq 1 ]]; then                    !! 160 retval=$?
200     echo "-i" ${VETH0} "-i" ${VETH1}           !! 161 test_status $retval "${TEST_NAME}"
201     exit                                       !! 162 statusList+=($retval)
202 fi                                             << 
203                                                   163 
204 exec_xskxceiver                                !! 164 ### TEST 3
                                                   >> 165 TEST_NAME="SKB POLL"
205                                                   166 
206 if [ -z $ETH ]; then                           !! 167 vethXDPgeneric ${VETH0} ${VETH1} ${NS1}
207         cleanup_exit ${VETH0} ${VETH1}         << 
208 else                                           << 
209         cleanup_iface ${ETH} ${MTU}            << 
210 fi                                             << 
211                                                   168 
212 if [[ $list -eq 1 ]]; then                     !! 169 params=("-S" "-p")
213     exit                                       !! 170 execxdpxceiver params
214 fi                                             !! 171 
                                                   >> 172 retval=$?
                                                   >> 173 test_status $retval "${TEST_NAME}"
                                                   >> 174 statusList+=($retval)
215                                                   175 
216 TEST_NAME="XSK_SELFTESTS_${VETH0}_BUSY_POLL"   !! 176 ### TEST 4
217 busy_poll=1                                    !! 177 TEST_NAME="DRV NOPOLL"
218                                                   178 
219 if [ -z $ETH ]; then                           !! 179 vethXDPnative ${VETH0} ${VETH1} ${NS1}
220         setup_vethPairs                        !! 180 
221 fi                                             !! 181 params=("-N")
222 exec_xskxceiver                                !! 182 execxdpxceiver params
                                                   >> 183 
                                                   >> 184 retval=$?
                                                   >> 185 test_status $retval "${TEST_NAME}"
                                                   >> 186 statusList+=($retval)
                                                   >> 187 
                                                   >> 188 ### TEST 5
                                                   >> 189 TEST_NAME="DRV POLL"
                                                   >> 190 
                                                   >> 191 vethXDPnative ${VETH0} ${VETH1} ${NS1}
                                                   >> 192 
                                                   >> 193 params=("-N" "-p")
                                                   >> 194 execxdpxceiver params
                                                   >> 195 
                                                   >> 196 retval=$?
                                                   >> 197 test_status $retval "${TEST_NAME}"
                                                   >> 198 statusList+=($retval)
                                                   >> 199 
                                                   >> 200 ### TEST 6
                                                   >> 201 TEST_NAME="SKB SOCKET TEARDOWN"
                                                   >> 202 
                                                   >> 203 vethXDPgeneric ${VETH0} ${VETH1} ${NS1}
                                                   >> 204 
                                                   >> 205 params=("-S" "-T")
                                                   >> 206 execxdpxceiver params
                                                   >> 207 
                                                   >> 208 retval=$?
                                                   >> 209 test_status $retval "${TEST_NAME}"
                                                   >> 210 statusList+=($retval)
                                                   >> 211 
                                                   >> 212 ### TEST 7
                                                   >> 213 TEST_NAME="DRV SOCKET TEARDOWN"
                                                   >> 214 
                                                   >> 215 vethXDPnative ${VETH0} ${VETH1} ${NS1}
                                                   >> 216 
                                                   >> 217 params=("-N" "-T")
                                                   >> 218 execxdpxceiver params
                                                   >> 219 
                                                   >> 220 retval=$?
                                                   >> 221 test_status $retval "${TEST_NAME}"
                                                   >> 222 statusList+=($retval)
                                                   >> 223 
                                                   >> 224 ### TEST 8
                                                   >> 225 TEST_NAME="SKB BIDIRECTIONAL SOCKETS"
                                                   >> 226 
                                                   >> 227 vethXDPgeneric ${VETH0} ${VETH1} ${NS1}
                                                   >> 228 
                                                   >> 229 params=("-S" "-B")
                                                   >> 230 execxdpxceiver params
                                                   >> 231 
                                                   >> 232 retval=$?
                                                   >> 233 test_status $retval "${TEST_NAME}"
                                                   >> 234 statusList+=($retval)
                                                   >> 235 
                                                   >> 236 ### TEST 9
                                                   >> 237 TEST_NAME="DRV BIDIRECTIONAL SOCKETS"
                                                   >> 238 
                                                   >> 239 vethXDPnative ${VETH0} ${VETH1} ${NS1}
                                                   >> 240 
                                                   >> 241 params=("-N" "-B")
                                                   >> 242 execxdpxceiver params
                                                   >> 243 
                                                   >> 244 retval=$?
                                                   >> 245 test_status $retval "${TEST_NAME}"
                                                   >> 246 statusList+=($retval)
223                                                   247 
224 ## END TESTS                                      248 ## END TESTS
225                                                   249 
226 if [ -z $ETH ]; then                           !! 250 cleanup_exit ${VETH0} ${VETH1} ${NS1}
227         cleanup_exit ${VETH0} ${VETH1}         << 
228 else                                           << 
229         cleanup_iface ${ETH} ${MTU}            << 
230 fi                                             << 
231                                                   251 
232 failures=0                                     !! 252 for _status in "${statusList[@]}"
233 echo -e "\nSummary:"                           << 
234 for i in "${!statusList[@]}"                   << 
235 do                                                253 do
236         if [ ${statusList[$i]} -ne 0 ]; then   !! 254         if [ $_status -ne 0 ]; then
237                 test_status ${statusList[$i]}  !! 255                 test_exit $ksft_fail 0
238                 failures=1                     << 
239         fi                                        256         fi
240 done                                              257 done
241                                                   258 
242 if [ $failures -eq 0 ]; then                   !! 259 test_exit $ksft_pass 0
243         echo "All tests successful!"           << 
244 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