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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/net/so_txtime.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 # Regression tests for the SO_TXTIME interface
  5 
  6 set -e
  7 
  8 readonly ksft_skip=4
  9 readonly DEV="veth0"
 10 readonly BIN="./so_txtime"
 11 
 12 readonly RAND="$(mktemp -u XXXXXX)"
 13 readonly NSPREFIX="ns-${RAND}"
 14 readonly NS1="${NSPREFIX}1"
 15 readonly NS2="${NSPREFIX}2"
 16 
 17 readonly SADDR4='192.168.1.1'
 18 readonly DADDR4='192.168.1.2'
 19 readonly SADDR6='fd::1'
 20 readonly DADDR6='fd::2'
 21 
 22 cleanup() {
 23         ip netns del "${NS2}"
 24         ip netns del "${NS1}"
 25 }
 26 
 27 trap cleanup EXIT
 28 
 29 # Create virtual ethernet pair between network namespaces
 30 ip netns add "${NS1}"
 31 ip netns add "${NS2}"
 32 
 33 ip link add "${DEV}" netns "${NS1}" type veth \
 34   peer name "${DEV}" netns "${NS2}"
 35 
 36 # Bring the devices up
 37 ip -netns "${NS1}" link set "${DEV}" up
 38 ip -netns "${NS2}" link set "${DEV}" up
 39 
 40 # Set fixed MAC addresses on the devices
 41 ip -netns "${NS1}" link set dev "${DEV}" address 02:02:02:02:02:02
 42 ip -netns "${NS2}" link set dev "${DEV}" address 06:06:06:06:06:06
 43 
 44 # Add fixed IP addresses to the devices
 45 ip -netns "${NS1}" addr add 192.168.1.1/24 dev "${DEV}"
 46 ip -netns "${NS2}" addr add 192.168.1.2/24 dev "${DEV}"
 47 ip -netns "${NS1}" addr add       fd::1/64 dev "${DEV}" nodad
 48 ip -netns "${NS2}" addr add       fd::2/64 dev "${DEV}" nodad
 49 
 50 run_test() {
 51         local readonly IP="$1"
 52         local readonly CLOCK="$2"
 53         local readonly TXARGS="$3"
 54         local readonly RXARGS="$4"
 55 
 56         if [[ "${IP}" == "4" ]]; then
 57                 local readonly SADDR="${SADDR4}"
 58                 local readonly DADDR="${DADDR4}"
 59         elif [[ "${IP}" == "6" ]]; then
 60                 local readonly SADDR="${SADDR6}"
 61                 local readonly DADDR="${DADDR6}"
 62         else
 63                 echo "Invalid IP version ${IP}"
 64                 exit 1
 65         fi
 66 
 67         local readonly START="$(date +%s%N --date="+ 0.1 seconds")"
 68 
 69         ip netns exec "${NS2}" "${BIN}" -"${IP}" -c "${CLOCK}" -t "${START}" -S "${SADDR}" -D "${DADDR}" "${RXARGS}" -r &
 70         ip netns exec "${NS1}" "${BIN}" -"${IP}" -c "${CLOCK}" -t "${START}" -S "${SADDR}" -D "${DADDR}" "${TXARGS}"
 71         wait "$!"
 72 }
 73 
 74 do_test() {
 75         run_test $@
 76         [ $? -ne 0 ] && ret=1
 77 }
 78 
 79 do_fail_test() {
 80         run_test $@
 81         [ $? -eq 0 ] && ret=1
 82 }
 83 
 84 ip netns exec "${NS1}" tc qdisc add dev "${DEV}" root fq
 85 set +e
 86 ret=0
 87 do_test 4 mono a,-1 a,-1
 88 do_test 6 mono a,0 a,0
 89 do_test 6 mono a,10 a,10
 90 do_test 4 mono a,10,b,20 a,10,b,20
 91 do_test 6 mono a,20,b,10 b,20,a,20
 92 
 93 if ip netns exec "${NS1}" tc qdisc replace dev "${DEV}" root etf clockid CLOCK_TAI delta 400000; then
 94         do_fail_test 4 tai a,-1 a,-1
 95         do_fail_test 6 tai a,0 a,0
 96         do_test 6 tai a,10 a,10
 97         do_test 4 tai a,10,b,20 a,10,b,20
 98         do_test 6 tai a,20,b,10 b,10,a,20
 99 else
100         echo "tc ($(tc -V)) does not support qdisc etf. skipping"
101         [ $ret -eq 0 ] && ret=$ksft_skip
102 fi
103 
104 if [ $ret -eq 0 ]; then
105         echo OK. All tests passed
106 elif [[ $ret -ne $ksft_skip && -n "$KSFT_MACHINE_SLOW" ]]; then
107         echo "Ignoring errors due to slow environment" 1>&2
108         ret=0
109 fi
110 exit $ret

~ [ 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