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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/net/txtimestamp.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 # Send packets with transmit timestamps over loopback with netem
  5 # Verify that timestamps correspond to netem delay
  6 
  7 set -e
  8 
  9 setup() {
 10         # set 1ms delay on lo egress
 11         tc qdisc add dev lo root netem delay 10ms
 12 
 13         # set 2ms delay on ifb0 egress
 14         modprobe ifb
 15         ip link add ifb_netem0 type ifb
 16         ip link set dev ifb_netem0 up
 17         tc qdisc add dev ifb_netem0 root netem delay 20ms
 18 
 19         # redirect lo ingress through ifb0 egress
 20         tc qdisc add dev lo handle ffff: ingress
 21         tc filter add dev lo parent ffff: \
 22                 u32 match mark 0 0xffff \
 23                 action mirred egress redirect dev ifb_netem0
 24 }
 25 
 26 run_test_v4v6() {
 27         # SND will be delayed 10ms
 28         # ACK will be delayed 60ms: 10 + 20 ms round-trip
 29         # allow +/- tolerance of 8ms
 30         # wait for ACK to be queued
 31         local -r args="$@ -v 10000 -V 60000 -t 8000 -S 80000"
 32 
 33         ./txtimestamp ${args} -4 -L 127.0.0.1
 34         ./txtimestamp ${args} -6 -L ::1
 35 }
 36 
 37 run_test_tcpudpraw() {
 38         local -r args=$@
 39 
 40         run_test_v4v6 ${args}           # tcp
 41         run_test_v4v6 ${args} -u        # udp
 42         run_test_v4v6 ${args} -r        # raw
 43         run_test_v4v6 ${args} -R        # raw (IPPROTO_RAW)
 44         run_test_v4v6 ${args} -P        # pf_packet
 45 }
 46 
 47 run_test_all() {
 48         setup
 49         run_test_tcpudpraw              # setsockopt
 50         run_test_tcpudpraw -C           # cmsg
 51         run_test_tcpudpraw -n           # timestamp w/o data
 52         echo "OK. All tests passed"
 53 }
 54 
 55 run_test_one() {
 56         setup
 57         ./txtimestamp $@
 58 }
 59 
 60 usage() {
 61         echo "Usage: $0 [ -r | --run ] <txtimestamp args> | [ -h | --help ]"
 62         echo "  (no args)  Run all tests"
 63         echo "  -r|--run  Run an individual test with arguments"
 64         echo "  -h|--help Help"
 65 }
 66 
 67 main() {
 68         if [[ $# -eq 0 ]]; then
 69                 run_test_all
 70         else
 71                 if [[ "$1" = "-r" || "$1" == "--run" ]]; then
 72                         shift
 73                         run_test_one $@
 74                 else
 75                         usage
 76                 fi
 77         fi
 78 }
 79 
 80 if [[ -z "$(ip netns identify)" ]]; then
 81         ./in_netns.sh $0 $@
 82 else
 83         main $@
 84 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