WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / net / txtimestamp.sh
blob31637769f59f607377532695d7e1c1d1ae96d9eb
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # Send packets with transmit timestamps over loopback with netem
5 # Verify that timestamps correspond to netem delay
7 set -e
9 setup() {
10 # set 1ms delay on lo egress
11 tc qdisc add dev lo root netem delay 1ms
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 2ms
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
26 run_test_v4v6() {
27 # SND will be delayed 1000us
28 # ACK will be delayed 6000us: 1 + 2 ms round-trip
29 local -r args="$@ -v 1000 -V 6000"
31 ./txtimestamp ${args} -4 -L 127.0.0.1
32 ./txtimestamp ${args} -6 -L ::1
35 run_test_tcpudpraw() {
36 local -r args=$@
38 run_test_v4v6 ${args} # tcp
39 run_test_v4v6 ${args} -u # udp
40 run_test_v4v6 ${args} -r # raw
41 run_test_v4v6 ${args} -R # raw (IPPROTO_RAW)
42 run_test_v4v6 ${args} -P # pf_packet
45 run_test_all() {
46 setup
47 run_test_tcpudpraw # setsockopt
48 run_test_tcpudpraw -C # cmsg
49 run_test_tcpudpraw -n # timestamp w/o data
50 echo "OK. All tests passed"
53 run_test_one() {
54 setup
55 ./txtimestamp $@
58 usage() {
59 echo "Usage: $0 [ -r | --run ] <txtimestamp args> | [ -h | --help ]"
60 echo " (no args) Run all tests"
61 echo " -r|--run Run an individual test with arguments"
62 echo " -h|--help Help"
65 main() {
66 if [[ $# -eq 0 ]]; then
67 run_test_all
68 else
69 if [[ "$1" = "-r" || "$1" == "--run" ]]; then
70 shift
71 run_test_one $@
72 else
73 usage
78 if [[ -z "$(ip netns identify)" ]]; then
79 ./in_netns.sh $0 $@
80 else
81 main $@