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
10 # set 1ms delay on lo egress
11 tc qdisc add dev lo root netem delay
1ms
13 # set 2ms delay on ifb0 egress
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
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
() {
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
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"
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"
66 if [[ $# -eq 0 ]]; then
69 if [[ "$1" = "-r" ||
"$1" == "--run" ]]; then
78 if [[ -z "$(ip netns identify)" ]]; then